Skip to content

Commit 0bf1039

Browse files
committed
test(auth): add test for mapping user pool endpoint config
1 parent fabe39d commit 0bf1039

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

packages/amplify_core/test/config/amplify_outputs_mapping/amplify_outputs_mapping_test.dart

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,22 @@ void main() {
9292
expect(mappedOutputs.auth?.appClientSecret, appClientSecret);
9393
});
9494

95-
test(
96-
'maps config with only the required options for a user pool',
97-
() async {
98-
final configJson =
99-
jsonDecode(userPoolOnlyConfig) as Map<String, Object?>;
100-
final amplifyConfig = AmplifyConfig.fromJson(configJson);
101-
final mappedOutputs = amplifyConfig.toAmplifyOutputs();
102-
expect(mappedOutputs.auth?.passwordPolicy, null);
103-
},
104-
);
95+
test('maps config with only the required options for a user pool',
96+
() async {
97+
final configJson =
98+
jsonDecode(userPoolOnlyConfig) as Map<String, Object?>;
99+
final amplifyConfig = AmplifyConfig.fromJson(configJson);
100+
final mappedOutputs = amplifyConfig.toAmplifyOutputs();
101+
expect(mappedOutputs.auth?.passwordPolicy, null);
102+
});
103+
104+
test('maps config with user pool endpoint', () async {
105+
final configJson =
106+
jsonDecode(endpointConfig) as Map<String, Object?>;
107+
final amplifyConfig = AmplifyConfig.fromJson(configJson);
108+
final mappedOutputs = amplifyConfig.toAmplifyOutputs();
109+
expect(mappedOutputs.auth?.userPoolEndpoint, userPoolEndpoint);
110+
});
105111
});
106112
});
107113
}
@@ -259,3 +265,40 @@ Map<String, Object?> updateConfig(Map<String, Object?> config) {
259265
defaultAuth['socialProviders'] = ['GOOGLE', 'FACEBOOK', 'AMAZON', 'APPLE'];
260266
return config;
261267
}
268+
269+
const userPoolEndpoint = 'https://fake-user-pool-endpoint.com';
270+
271+
const endpointConfig = r'''{
272+
"UserAgent": "aws-amplify-cli/2.0",
273+
"Version": "1.0",
274+
"auth": {
275+
"plugins": {
276+
"awsCognitoAuthPlugin": {
277+
"IdentityManager": {
278+
"Default": {}
279+
},
280+
"CredentialsProvider": {
281+
"CognitoIdentity": {
282+
"Default": {
283+
"PoolId": "fake-pool-id",
284+
"Region": "us-east-1"
285+
}
286+
}
287+
},
288+
"CognitoUserPool": {
289+
"Default": {
290+
"PoolId": "fake-pool-id",
291+
"AppClientId": "fake-client-id",
292+
"Region": "us-east-1",
293+
"Endpoint": "https://fake-user-pool-endpoint.com"
294+
}
295+
},
296+
"Auth": {
297+
"Default": {
298+
"authenticationFlowType": "USER_SRP_AUTH"
299+
}
300+
}
301+
}
302+
}
303+
}
304+
}''';

0 commit comments

Comments
 (0)