|
1 | 1 | import { Template } from '../../../assertions';
|
2 |
| -import { Stack } from '../../../core'; |
| 2 | +import { Stack, SecretValue } from '../../../core'; |
3 | 3 | import { ProviderAttribute, UserPool, UserPoolIdentityProviderApple } from '../../lib';
|
4 | 4 |
|
5 | 5 | describe('UserPoolIdentityProvider', () => {
|
@@ -102,12 +102,51 @@ describe('UserPoolIdentityProvider', () => {
|
102 | 102 | // THEN
|
103 | 103 | Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolIdentityProvider', {
|
104 | 104 | AttributeMapping: {
|
105 |
| - family_name: 'firstName', |
106 |
| - given_name: 'lastName', |
| 105 | + family_name: 'lastName', |
| 106 | + given_name: 'firstName', |
107 | 107 | customAttr1: 'email',
|
108 | 108 | customAttr2: 'sub',
|
109 | 109 | },
|
110 | 110 | });
|
111 | 111 | });
|
| 112 | + |
| 113 | + // cannot assign both privateKey and privateKeyValue |
| 114 | + test('cannot assign both privateKey and privateKeyValue', () => { |
| 115 | + // GIVEN |
| 116 | + const stack = new Stack(); |
| 117 | + const pool = new UserPool(stack, 'userpool'); |
| 118 | + |
| 119 | + expect(() => { |
| 120 | + new UserPoolIdentityProviderApple(stack, 'userpoolidp', { |
| 121 | + userPool: pool, |
| 122 | + clientId: 'com.amzn.cdk', |
| 123 | + teamId: 'CDKTEAMCDK', |
| 124 | + keyId: 'XXXXXXXXXX', |
| 125 | + privateKey: 'PRIV_KEY_CDK', |
| 126 | + privateKeyValue: SecretValue.secretsManager('dummyId'), |
| 127 | + }); |
| 128 | + }).toThrow('Exactly one of "privateKey" or "privateKeyValue" must be configured.'); |
| 129 | + }); |
| 130 | + |
| 131 | + // should support privateKeyValue |
| 132 | + test('should support privateKeyValue', () => { |
| 133 | + // GIVEN |
| 134 | + const stack = new Stack(); |
| 135 | + const pool = new UserPool(stack, 'userpool'); |
| 136 | + |
| 137 | + new UserPoolIdentityProviderApple(stack, 'userpoolidp', { |
| 138 | + userPool: pool, |
| 139 | + clientId: 'com.amzn.cdk', |
| 140 | + teamId: 'CDKTEAMCDK', |
| 141 | + keyId: 'XXXXXXXXXX', |
| 142 | + privateKeyValue: SecretValue.secretsManager('dummyId'), |
| 143 | + }); |
| 144 | + |
| 145 | + Template.fromStack(stack).hasResourceProperties('AWS::Cognito::UserPoolIdentityProvider', { |
| 146 | + ProviderDetails: { |
| 147 | + private_key: '{{resolve:secretsmanager:dummyId:SecretString:::}}', |
| 148 | + }, |
| 149 | + }); |
| 150 | + }); |
112 | 151 | });
|
113 | 152 | });
|
0 commit comments