-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from hms-dbmi-cellenics/1932-remove-account-s…
…pecific-hardcodings Remove account specific hardcodings in the api code
- Loading branch information
Showing
19 changed files
with
317 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const mockLogger = { | ||
log: jest.fn(() => { }), | ||
error: jest.fn(() => { }), | ||
debug: jest.fn(() => { }), | ||
trace: jest.fn(() => { }), | ||
warn: jest.fn(() => { }), | ||
}; | ||
|
||
module.exports = jest.fn(() => mockLogger); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function isPromise(value) { | ||
return Boolean(value && typeof value.then === 'function'); | ||
} | ||
|
||
module.exports = isPromise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Object { | |
Hello, <br/> | ||
Your collaborator [email protected] has invited you to explore their single cell RNA-seq project in Cellenics. <br/><br/> | ||
Access it with the link below: <br/> | ||
<a href=\\"scp.biomage.net/experiments/experimentId/data-exploration\\">scp.biomage.net/experiments/experimentId/data-exploration</a> <br/> <br/> | ||
<a href=\\"scp.mockDomainName.com/experiments/experimentId/data-exploration\\">scp.mockDomainName.com/experiments/experimentId/data-exploration</a> <br/> <br/> | ||
Cellenics is a user-friendly online tool for single cell RNA-seq data analysis. <br/> | ||
The platform is designed specifically for biologists, and it's completely free for academic researchers.<br/><br/> | ||
More information about Cellenics can be found at <a href=\\"https://biomage.net\\">biomage.net</a>.<br/><br/> | ||
|
@@ -42,7 +42,7 @@ Object { | |
Hello, <br/> | ||
Your collaborator [email protected] has invited you to explore their single cell RNA-seq project in Cellenics. <br/><br/> | ||
Access it with the link below: <br/> | ||
<a href=\\"scp.biomage.net/experiments/experimentId/data-exploration\\">scp.biomage.net/experiments/experimentId/data-exploration</a> <br/> <br/> | ||
<a href=\\"scp.mockDomainName.com/experiments/experimentId/data-exploration\\">scp.mockDomainName.com/experiments/experimentId/data-exploration</a> <br/> <br/> | ||
Cellenics is a user-friendly online tool for single cell RNA-seq data analysis. <br/> | ||
The platform is designed specifically for biologists, and it's completely free for academic researchers.<br/><br/> | ||
More information about Cellenics can be found at <a href=\\"https://biomage.net\\">biomage.net</a>.<br/><br/> | ||
|
@@ -83,7 +83,7 @@ Object { | |
Hello, <br/> | ||
Your collaborator [email protected] has invited you to explore their single cell RNA-seq project in Cellenics. <br/><br/> | ||
You need to create a Cellenics account in order to access the project. <br/> | ||
Register at <a href=\\"https://scp.biomage.net\\">scp.biomage.net</a> using this email address.<br/> <br/> | ||
Register at <a href=\\"https://scp.mockDomainName.com\\">https://scp.mockDomainName.com</a> using this email address.<br/> <br/> | ||
Cellenics is a user-friendly online tool for single cell RNA-seq data analysis. <br/> | ||
The platform is designed specifically for biologists, and it's completely free for academic researchers.<br/><br/> | ||
|
@@ -106,7 +106,7 @@ Object { | |
Hello, <br/> | ||
Your collaborator [email protected] has invited you to explore their single cell RNA-seq project in Cellenics. <br/><br/> | ||
You need to create a Cellenics account in order to access the project. <br/> | ||
Register at <a href=\\"https://scp.biomage.net\\">scp.biomage.net</a> using this email address.<br/> <br/> | ||
Register at <a href=\\"https://scp.mockDomainName.com\\">https://scp.mockDomainName.com</a> using this email address.<br/> <br/> | ||
Cellenics is a user-friendly online tool for single cell RNA-seq data analysis. <br/> | ||
The platform is designed specifically for biologists, and it's completely free for academic researchers.<br/><br/> | ||
|
29 changes: 29 additions & 0 deletions
29
tests/config/__snapshots__/default-config-production.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`default-config Returns correct values for production 1`] = ` | ||
Object { | ||
"adminSub": "032abd44-0cd3-4d58-af21-850ca0b95ac7", | ||
"api": Object { | ||
"prefix": "/", | ||
}, | ||
"awsRegion": "eu-west-1", | ||
"cachingEnabled": true, | ||
"clusterEnv": "production", | ||
"cognitoISP": Object { | ||
"listUserPools": Object { | ||
"promise": [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", | ||
} | ||
`; |
29 changes: 29 additions & 0 deletions
29
tests/config/__snapshots__/default-config-staging-sandboxid.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`default-config Returns correct values for staging sandboxid 1`] = ` | ||
Object { | ||
"adminSub": "0b17683f-363b-4466-b2e2-5bf11c38a76e", | ||
"api": Object { | ||
"prefix": "/", | ||
}, | ||
"awsRegion": "eu-west-1", | ||
"cachingEnabled": false, | ||
"clusterEnv": "staging", | ||
"cognitoISP": Object { | ||
"listUserPools": Object { | ||
"promise": [MockFunction], | ||
}, | ||
}, | ||
"corsOriginUrl": "https://ui-mockedSandboxId.scp-staging.biomage.net", | ||
"domainName": "scp-staging.biomage.net", | ||
"githubToken": undefined, | ||
"pipelineInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/staging/mockedSandboxId.yaml", | ||
"pipelineNamespace": "pipeline-mockedSandboxId", | ||
"podName": "local", | ||
"port": 3000, | ||
"rdsSandboxId": "default", | ||
"sandboxId": "mockedSandboxId", | ||
"workerInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/staging/mockedSandboxId.yaml", | ||
"workerNamespace": "worker-mockedSandboxId", | ||
} | ||
`; |
29 changes: 29 additions & 0 deletions
29
tests/config/__snapshots__/default-config-staging.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`default-config Returns correct values for staging default 1`] = ` | ||
Object { | ||
"adminSub": "0b17683f-363b-4466-b2e2-5bf11c38a76e", | ||
"api": Object { | ||
"prefix": "/", | ||
}, | ||
"awsRegion": "eu-west-1", | ||
"cachingEnabled": false, | ||
"clusterEnv": "staging", | ||
"cognitoISP": Object { | ||
"listUserPools": Object { | ||
"promise": [MockFunction], | ||
}, | ||
}, | ||
"corsOriginUrl": "https://ui-default.scp-staging.biomage.net", | ||
"domainName": "scp-staging.biomage.net", | ||
"githubToken": undefined, | ||
"pipelineInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/staging/pipeline.yaml", | ||
"pipelineNamespace": "pipeline-default", | ||
"podName": "local", | ||
"port": 3000, | ||
"rdsSandboxId": "default", | ||
"sandboxId": "default", | ||
"workerInstanceConfigUrl": "https://raw.githubusercontent.com/hms-dbmi-cellenics/iac/master/releases/staging/worker.yaml", | ||
"workerNamespace": "worker-default", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// @ts-nocheck | ||
const _ = require('lodash'); | ||
|
||
const AWS = require('aws-sdk'); | ||
const isPromise = require('../../src/utils/isPromise'); | ||
|
||
jest.mock('aws-sdk'); | ||
jest.mock('../../src/utils/getLogger'); | ||
|
||
describe('default-config', () => { | ||
const OLD_ENV = _.cloneDeep(process.env); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
process.env = OLD_ENV; | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
process.env = OLD_ENV; | ||
}); | ||
|
||
it('Returns correct values for production', () => { | ||
const prodEnvironment = 'production'; | ||
process.env.K8S_ENV = prodEnvironment; | ||
process.env.CLUSTER_ENV = prodEnvironment; | ||
process.env.AWS_DEFAULT_REGION = 'eu-west-1'; | ||
|
||
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(); | ||
}); | ||
}); |
Oops, something went wrong.