@@ -2,18 +2,17 @@ import { beforeEach, describe, it, mock } from 'node:test';
2
2
import assert from 'assert' ;
3
3
import { BackendIdentifier } from '@aws-amplify/plugin-types' ;
4
4
import { AWSAmplifyBackendOutputs } from '../../../client-config/src/client-config-schema/client_config_v1.3.js' ;
5
- import {
6
- CognitoIdentityProviderClient ,
7
- DescribeUserPoolClientCommandInput ,
8
- DescribeUserPoolClientCommandOutput ,
9
- UserPoolType ,
10
- } from '@aws-sdk/client-cognito-identity-provider' ;
11
5
import { generateSeedPolicyTemplate } from './generate_seed_policy_template.js' ;
12
6
import { generateClientConfig } from '@aws-amplify/client-config' ;
13
7
import { AmplifyUserError } from '@aws-amplify/platform-core' ;
14
8
import { App , Stack } from 'aws-cdk-lib' ;
15
9
import { AccountPrincipal , Policy , Role } from 'aws-cdk-lib/aws-iam' ;
16
10
import { Template } from 'aws-cdk-lib/assertions' ;
11
+ import {
12
+ GetCallerIdentityCommandInput ,
13
+ GetCallerIdentityCommandOutput ,
14
+ STSClient ,
15
+ } from '@aws-sdk/client-sts' ;
17
16
18
17
const testBackendId = 'testBackendId' ;
19
18
const testSandboxName = 'testSandboxName' ;
@@ -42,35 +41,34 @@ void describe('generate inline policy for seed', () => {
42
41
} ,
43
42
} as AWSAmplifyBackendOutputs )
44
43
) ;
45
- const mockCognitoIdProviderClient = {
44
+
45
+ const mockStsClient = {
46
46
send : mock . fn <
47
47
(
48
- input : DescribeUserPoolClientCommandInput
49
- ) => Promise < DescribeUserPoolClientCommandOutput >
48
+ input : GetCallerIdentityCommandInput
49
+ ) => Promise < GetCallerIdentityCommandOutput >
50
50
> ( async ( ) =>
51
51
Promise . resolve ( {
52
- $metadata : { } ,
53
- UserPool : {
54
- UserPoolId : testUserpoolId ,
55
- Arn : testArn ,
56
- } as UserPoolType ,
57
- } )
52
+ Account : '123456789012' ,
53
+ Arn : '' ,
54
+ UserId : '' ,
55
+ } as GetCallerIdentityCommandOutput )
58
56
) ,
59
57
} ;
60
58
61
59
const app = new App ( ) ;
62
60
const stack = new Stack ( app ) ;
63
61
64
62
beforeEach ( ( ) => {
65
- mockCognitoIdProviderClient . send . mock . resetCalls ( ) ;
66
63
mockConfigGenerator . mock . resetCalls ( ) ;
64
+ mockStsClient . send . mock . resetCalls ( ) ;
67
65
} ) ;
68
66
69
67
void it ( 'returns a policy with expected seed permissions' , async ( ) => {
70
68
const policyDoc = await generateSeedPolicyTemplate (
71
69
testBackendIdentifier ,
72
70
mockConfigGenerator as unknown as typeof generateClientConfig ,
73
- mockCognitoIdProviderClient as unknown as CognitoIdentityProviderClient
71
+ mockStsClient as unknown as STSClient
74
72
) ;
75
73
76
74
const policy = new Policy ( stack , 'testSeedPolicy' , { document : policyDoc } ) ;
0 commit comments