-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AmmarKarachi
committed
Oct 30, 2020
1 parent
86581c5
commit 66f5ea1
Showing
21 changed files
with
569 additions
and
47 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
111 changes: 111 additions & 0 deletions
111
packages/amplify-cli-core/src/__tests__/moveSecretsToDeployment.test.ts
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,111 @@ | ||
import { StateManager } from '../../lib'; | ||
|
||
const teamProviderInfoSecrets = { | ||
dev: { | ||
awscloudformation: { | ||
AuthRoleName: 'amplify-teamprovider-dev-134909-authRole', | ||
UnauthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-dev-134909-unauthRole', | ||
AuthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-dev-134909-authRole', | ||
Region: 'us-east-1', | ||
DeploymentBucketName: 'amplify-teamprovider-dev-134909-deployment', | ||
UnauthRoleName: 'amplify-teamprovider-dev-134909-unauthRole', | ||
StackName: 'amplify-teamprovider-dev-134909', | ||
StackId: 'arn:aws:cloudformation:us-east-1:1234567891011:stack/amplify-teamprovider-dev-134909/df33f4d0-1895-11eb-a8b4-0e706f74ed45', | ||
AmplifyAppId: 'd1gmlw7l76gj9', | ||
}, | ||
categories: { | ||
auth: { | ||
teamprovider1819bdce: { | ||
hostedUIProviderCreds: '[{"ProviderName":"Facebook","client_id":"asdasdasdasd","client_secret":"asdasdasd"}]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
prod: { | ||
awscloudformation: { | ||
AuthRoleName: 'amplify-teamprovider-prod-164239-authRole', | ||
UnauthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-prod-164239-unauthRole', | ||
AuthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-prod-164239-authRole', | ||
Region: 'us-east-1', | ||
DeploymentBucketName: 'amplify-teamprovider-prod-164239-deployment', | ||
UnauthRoleName: 'amplify-teamprovider-prod-164239-unauthRole', | ||
StackName: 'amplify-teamprovider-prod-164239', | ||
StackId: 'arn:aws:cloudformation:us-east-1:1234567891011:stack/amplify-teamprovider-prod-164239/1b625f60-18ae-11eb-9e65-0ab042f700a7', | ||
AmplifyAppId: 'd1gmlw7l76gj9', | ||
}, | ||
categories: { | ||
auth: { | ||
teamprovider1819bdce: { | ||
hostedUIProviderCreds: '[{"ProviderName":"Facebook","client_id":"abc","client_secret":"adb"}]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const teamProviderInfoWithoutSecrets = { | ||
dev: { | ||
awscloudformation: { | ||
AuthRoleName: 'amplify-teamprovider-dev-134909-authRole', | ||
UnauthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-dev-134909-unauthRole', | ||
AuthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-dev-134909-authRole', | ||
Region: 'us-east-1', | ||
DeploymentBucketName: 'amplify-teamprovider-dev-134909-deployment', | ||
UnauthRoleName: 'amplify-teamprovider-dev-134909-unauthRole', | ||
StackName: 'amplify-teamprovider-dev-134909', | ||
StackId: 'arn:aws:cloudformation:us-east-1:1234567891011:stack/amplify-teamprovider-dev-134909/df33f4d0-1895-11eb-a8b4-0e706f74ed45', | ||
AmplifyAppId: 'd1gmlw7l76gj9', | ||
}, | ||
categories: { | ||
auth: { | ||
teamprovider1819bdce: {}, | ||
}, | ||
}, | ||
}, | ||
prod: { | ||
awscloudformation: { | ||
AuthRoleName: 'amplify-teamprovider-prod-164239-authRole', | ||
UnauthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-prod-164239-unauthRole', | ||
AuthRoleArn: 'arn:aws:iam::1234567891011:role/amplify-teamprovider-prod-164239-authRole', | ||
Region: 'us-east-1', | ||
DeploymentBucketName: 'amplify-teamprovider-prod-164239-deployment', | ||
UnauthRoleName: 'amplify-teamprovider-prod-164239-unauthRole', | ||
StackName: 'amplify-teamprovider-prod-164239', | ||
StackId: 'arn:aws:cloudformation:us-east-1:1234567891011:stack/amplify-teamprovider-prod-164239/1b625f60-18ae-11eb-9e65-0ab042f700a7', | ||
AmplifyAppId: 'd1gmlw7l76gj9', | ||
}, | ||
categories: { | ||
auth: { | ||
teamprovider1819bdce: { | ||
hostedUIProviderCreds: '[{"ProviderName":"Facebook","client_id":"abc","client_secret":"adb"}]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
const secrets = { | ||
d1gmlw7l76gj9: { | ||
dev: { | ||
auth: { | ||
teamprovider1819bdce: { | ||
hostedUIProviderCreds: '[{"ProviderName":"Facebook","client_id":"asdasdasdasd","client_secret":"asdasdasd"}]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('test move secrests to deployment', () => { | ||
const stateManager = new StateManager(); | ||
const mockGetLocalEnvInfo = jest.spyOn(stateManager, 'getLocalEnvInfo').mockReturnValue({ envName: 'dev' }); | ||
const mockGetTeamProviderInfo = jest.spyOn(stateManager, 'getTeamProviderInfo').mockReturnValue(teamProviderInfoSecrets); | ||
const setTeamProviderInfo = jest.spyOn(stateManager, 'setTeamProviderInfo').mockImplementation(); | ||
const setDeploymentSecrets = jest.spyOn(stateManager, 'setDeploymentSecrets').mockImplementation(); | ||
it('test with migrate', () => { | ||
stateManager.moveSecretsFromDeploymentToTeamProvider(); | ||
expect(setTeamProviderInfo).toBeCalledWith(undefined, teamProviderInfoWithoutSecrets); | ||
expect(setDeploymentSecrets).toBeCalledWith(secrets); | ||
expect(mockGetLocalEnvInfo).toBeCalled(); | ||
expect(mockGetLocalEnvInfo).toBeCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.