diff --git a/src/config/default-config.js b/src/config/default-config.js index ec36e9df0..a207f5f71 100644 --- a/src/config/default-config.js +++ b/src/config/default-config.js @@ -82,7 +82,6 @@ const config = { adminSub: ADMIN_SUB[process.env.AWS_ACCOUNT_ID], }; - // We are in permanent develop staging environment if (config.clusterEnv === 'staging' && config.sandboxId === 'default') { config.workerInstanceConfigUrl = `https://raw.githubusercontent.com/${githubOrganisationName}/iac/master/releases/staging/worker.yaml`; diff --git a/tests/config/__snapshots__/default-config-production.test.js.snap b/tests/config/__snapshots__/default-config-production.test.js.snap index bb4b53d7d..1cbe725cd 100644 --- a/tests/config/__snapshots__/default-config-production.test.js.snap +++ b/tests/config/__snapshots__/default-config-production.test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`default-config Returns correct values for production 1`] = ` +exports[`default-config Returns correct values for BIOMAGE production 1`] = ` Object { "adminSub": "032abd44-0cd3-4d58-af21-850ca0b95ac7", "api": Object { "prefix": "/", }, - "awsAccountId": "000000000000", + "awsAccountId": "242905224710", "awsRegion": "eu-west-1", "cachingEnabled": true, "clusterEnv": "production", @@ -28,3 +28,31 @@ Object { "workerNamespace": "worker-default", } `; + +exports[`default-config Returns correct values for HMS production 1`] = ` +Object { + "adminSub": "a01e8bcc-c9a2-4c56-bd66-39de93764be8", + "api": Object { + "prefix": "/", + }, + "awsAccountId": "160782110667", + "awsRegion": "eu-west-1", + "cachingEnabled": true, + "clusterEnv": "production", + "cognitoISP": mockConstructor { + "CALL_EVENTS_BUBBLE": [MockFunction], + "MONITOR_EVENTS_BUBBLE": [MockFunction], + }, + "corsOriginUrl": "https://localhost:5000", + "domainName": "localhost:5000", + "githubToken": undefined, + "pipelineInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/production/pipeline.yaml", + "pipelineNamespace": "pipeline-default", + "podName": "local", + "port": 3000, + "rdsSandboxId": "default", + "sandboxId": "default", + "workerInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/production/worker.yaml", + "workerNamespace": "worker-default", +} +`; diff --git a/tests/config/default-config-production.test.js b/tests/config/default-config-production.test.js index 812795e66..45ca2af2c 100644 --- a/tests/config/default-config-production.test.js +++ b/tests/config/default-config-production.test.js @@ -20,11 +20,48 @@ describe('default-config', () => { process.env = OLD_ENV; }); - it('Returns correct values for production', () => { + it('Returns correct values for BIOMAGE production', () => { const prodEnvironment = 'production'; process.env.K8S_ENV = prodEnvironment; process.env.CLUSTER_ENV = prodEnvironment; process.env.AWS_DEFAULT_REGION = 'eu-west-1'; + process.env.AWS_ACCOUNT_ID = '242905224710'; + + const userPoolId = 'mockUserPoolId'; + const accountId = 'mockAccountId'; + + AWS.CognitoIdentityServiceProvider = jest.fn(() => ({ + listUserPools: { + promise: jest.fn(() => Promise.resolve( + { UserPools: [{ id: userPoolId, Name: `biomage-user-pool-case-insensitive-${prodEnvironment}` }] }, + )), + }, + })); + + AWS.STS = jest.fn(() => ({ + getCallerIdentity: { + promise: jest.fn(() => Promise.resolve({ Account: accountId })), + }, + })); + + const defaultConfig = jest.requireActual('../../src/config/default-config'); + + const defaultConfigEntries = Object.entries(defaultConfig); + const filteredEntries = defaultConfigEntries.filter(([, value]) => !isPromise(value)); + const defaultConfigFiltered = Object.fromEntries(filteredEntries); + + expect(defaultConfigFiltered).toMatchSnapshot(); + }); + + it('Returns correct values for HMS production', () => { + jest.unmock('../../src/config/default-config'); + jest.resetModules(); + + const prodEnvironment = 'production'; + process.env.K8S_ENV = prodEnvironment; + process.env.CLUSTER_ENV = prodEnvironment; + process.env.AWS_DEFAULT_REGION = 'eu-west-1'; + process.env.AWS_ACCOUNT_ID = '160782110667'; const userPoolId = 'mockUserPoolId'; const accountId = 'mockAccountId';