A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
fix: resolves oracle switf storage integration issue
towfiqi1a3f37d90fa9
diff --git a/backend/__tests__/utils/providers.test.ts b/backend/__tests__/utils/providers.test.tsindex 19eab3e..fe50f41 100644--- a/backend/__tests__/utils/providers.test.ts+++ b/backend/__tests__/utils/providers.test.ts@@ -314,7 +314,7 @@ describe('providers setup()', () => {});describe('swift', () => {- const creds = { user: 'u', key: 'k', authUrl: 'https://auth', tenant: 't' };+ const creds = { user: 'u', key: 'k', auth: 'https://auth', tenant: 't' };const args = ['user', 'u', 'key', 'k', 'auth', 'https://auth', 'tenant', 't'];it('sends auth_token when set', () => {@@ -328,6 +328,42 @@ describe('providers setup()', () => {it('omits auth_token when blank', () => {expect(providers.swift.setup({ ...creds, auth_token: '' })).toEqual(args);});++ it('omits tenant when blank', () => {+ const result = providers.swift.setup({ ...creds, tenant: '' }) as string[];++ expect(result).toEqual(['user', 'u', 'key', 'k', 'auth', 'https://auth']);+ expect(result).not.toContain(undefined);+ });++ it('password: sends storage_url when set', () => {+ expect(+ providers.swift.setup({ ...creds, storage_url: 'https://store' }, 'password')+ ).toEqual([...args, 'storage_url', 'https://store']);+ });++ it.each(['user', 'key', 'auth'])('password: returns false without %s', key => {+ expect(providers.swift.setup({ ...creds, [key]: '' }, 'password')).toBe(false);+ });++ it('client: sends only auth_token and storage_url', () => {+ expect(+ providers.swift.setup(+ { ...creds, auth_token: 'at', storage_url: 'https://store' },+ 'client'+ )+ ).toEqual(['auth_token', 'at', 'storage_url', 'https://store']);+ });++ it.each(['auth_token', 'storage_url'])('client: returns false without %s', key => {+ const tokenCreds = { auth_token: 'at', storage_url: 'https://store', [key]: '' };++ expect(providers.swift.setup(tokenCreds, 'client')).toBe(false);+ });++ it('lists password as the default auth type', () => {+ expect(providers.swift.authTypes[0]).toBe('password');+ });});describe('webdav', () => {diff --git a/backend/src/utils/providers.ts b/backend/src/utils/providers.tsindex df8b8db..14a14a7 100644--- a/backend/src/utils/providers.ts+++ b/backend/src/utils/providers.ts@@ -332,18 +332,28 @@ export const providers: Record<string, ProviderConfig> = {name: 'Oracle Swift',doc: '/storages/connecting-openstack-swift',settings: swiftSettings,- authTypes: ['client', 'password'],- setup: creds => [- 'user',- creds.user,- 'key',- creds.key,- 'auth',- creds.authUrl,- 'tenant',- creds.tenant,- ...optionalCreds(creds, ['auth_token']),- ],+ authTypes: ['password', 'client'],+ setup: (creds, type) => {+ // Client login uses a pre-issued token and skips the auth server.+ if (type === 'client') {+ if (!creds.auth_token || !creds.storage_url) {+ return false;+ }+ return ['auth_token', creds.auth_token, 'storage_url', creds.storage_url];+ }+ if (!creds.user || !creds.key || !creds.auth) {+ return false;+ }+ return [+ 'user',+ creds.user,+ 'key',+ creds.key,+ 'auth',+ creds.auth,+ ...optionalCreds(creds, ['tenant', 'storage_url', 'auth_token']),+ ];+ },features: providerFeatures['swift'],},storj: {diff --git a/backend/src/utils/providers/swift.ts b/backend/src/utils/providers/swift.tsindex 7517f3d..96e6be1 100644--- a/backend/src/utils/providers/swift.ts+++ b/backend/src/utils/providers/swift.ts@@ -37,6 +37,7 @@ const swiftSettings = [{ label: 'Blomp Cloud Storage', value: 'https://authenticate.ain.net' },{ label: 'Custom', value: 'custom' },],+ allowCustom: true,command: '--swift-auth',},{@@ -73,7 +74,8 @@ const swiftSettings = [label: 'Tenant Name',value: 'tenant',fieldType: 'string',- required: true,+ authFieldType: 'password',+ required: false,default: '',description:'Tenant name. Optional for v1 auth, otherwise this or Tenant ID is required.',@@ -113,8 +115,10 @@ const swiftSettings = [value: 'storage_url',fieldType: 'string',required: false,+ authFieldType: 'all',default: '',- description: 'Storage URL (optional).',+ description:+ 'Storage URL. Required with Auth Token login. Optional with User/Pass login, where it overrides the URL from the auth server.',command: '--swift-storage-url',},{@@ -124,7 +128,8 @@ const swiftSettings = [required: false,authFieldType: 'all',default: '',- description: 'Auth token from alternate authentication (optional).',+ description:+ 'Auth token from alternate authentication. Required with Auth Token login, together with Storage URL.',command: '--swift-auth-token',},{