From fb4f54dd029f7ffa24f771d4c7420c814e24bb6d Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Tue, 7 Jan 2025 15:38:16 -0800 Subject: [PATCH 1/7] chore(authenticator): TEST --- .../lib/src/widgets/form_fields/sign_in_form_field.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/sign_in_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/sign_in_form_field.dart index d65618fa04..6da34e9f68 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/sign_in_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/sign_in_form_field.dart @@ -159,6 +159,7 @@ class _SignInTextFieldState extends _SignInFormFieldState return (v) => state.username = v; case SignInField.password: return (v) => state.password = v; + //This is a Test PR default: return super.onChanged; } From 10669aebbf4fd35dd50aa2e209b5cacfa4061a98 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Tue, 7 Jan 2025 17:00:27 -0800 Subject: [PATCH 2/7] chore(authenticator): test --- .../integration_test/custom_authorizer_test.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index 3b6ff9fb6d..35f3a5cb76 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -64,29 +64,35 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { + print('TestTestTest - 1'); final username = generateUsername(); final password = generatePassword(); + print('TestTestTest - 2'); final signUpRes = await Amplify.Auth.signUp( username: username, password: password, ); expect(signUpRes.isSignUpComplete, isTrue); + print('TestTestTest - 3'); final signInRes = await Amplify.Auth.signIn( username: username, password: password, ); expect(signInRes.isSignedIn, isTrue); + print('TestTestTest - 4'); final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession; expect(session.userPoolTokensResult.valueOrNull, isNotNull); + print('TestTestTest - 5'); final apiUrl = config.api!.awsPlugin!.values .singleWhere((e) => e.endpointType == EndpointType.rest) .endpoint; + print('TestTestTest - 6'); // Verifies invocation with the ID token. Invocation with an access // token requires integration with a resource server/OAuth and is, thus, // not tested. @@ -105,25 +111,31 @@ void main() { }, body: HttpPayload.json({'request': 'hello'}), ); + print('TestTestTest - 7'); final resp = await client.send(request).response; + print('TestTestTest - 8'); final body = await resp.decodeBody(); + print('TestTestTest - 9'); expect(resp.statusCode, 200, reason: body); expect( jsonDecode(body), equals({'response': 'hello'}), ); + print('TestTestTest - 10'); customHeaders.forEach((key, value) { expect( resp.headers, containsPair(key, value), ); }); + print('TestTestTest - 11'); queryParameters.forEach((key, value) { expect( resp.headers, containsPair('x-query-$key', value), ); }); + print('TestTestTest - 12'); }); asyncTest('can invoke with API plugin', (_) async { From bdc3a1abaf8826dfed231503f53eb8e2889a20f6 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Tue, 7 Jan 2025 17:21:53 -0800 Subject: [PATCH 3/7] chore():Test --- .../example/integration_test/custom_authorizer_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index 35f3a5cb76..26105ee0a1 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -64,6 +64,7 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { + // ignore_for_file: avoid_print print('TestTestTest - 1'); final username = generateUsername(); final password = generatePassword(); From e88f838665f9a240a15cf4b92b459ac21eff8f0a Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Wed, 8 Jan 2025 11:30:18 -0800 Subject: [PATCH 4/7] chore(): test --- .../custom_authorizer_test.dart | 251 ++++++++++-------- 1 file changed, 139 insertions(+), 112 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index 26105ee0a1..0273075bef 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -64,79 +64,84 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { - // ignore_for_file: avoid_print - print('TestTestTest - 1'); - final username = generateUsername(); - final password = generatePassword(); + List checkpoints = []; + try { + checkpoints.add('TestTestTest - 1'); + final username = generateUsername(); + final password = generatePassword(); - print('TestTestTest - 2'); - final signUpRes = await Amplify.Auth.signUp( - username: username, - password: password, - ); - expect(signUpRes.isSignUpComplete, isTrue); + checkpoints.add('TestTestTest - 2'); + final signUpRes = await Amplify.Auth.signUp( + username: username, + password: password, + ); + expect(signUpRes.isSignUpComplete, isTrue); - print('TestTestTest - 3'); - final signInRes = await Amplify.Auth.signIn( - username: username, - password: password, - ); - expect(signInRes.isSignedIn, isTrue); + checkpoints.add('TestTestTest - 3'); + final signInRes = await Amplify.Auth.signIn( + username: username, + password: password, + ); + expect(signInRes.isSignedIn, isTrue); - print('TestTestTest - 4'); - final session = - await Amplify.Auth.fetchAuthSession() as CognitoAuthSession; - expect(session.userPoolTokensResult.valueOrNull, isNotNull); + checkpoints.add('TestTestTest - 4'); + final session = + await Amplify.Auth.fetchAuthSession() as CognitoAuthSession; + expect(session.userPoolTokensResult.valueOrNull, isNotNull); - print('TestTestTest - 5'); - final apiUrl = config.api!.awsPlugin!.values - .singleWhere((e) => e.endpointType == EndpointType.rest) - .endpoint; + checkpoints.add('TestTestTest - 5'); + final apiUrl = config.api!.awsPlugin!.values + .singleWhere((e) => e.endpointType == EndpointType.rest) + .endpoint; - print('TestTestTest - 6'); - // Verifies invocation with the ID token. Invocation with an access - // token requires integration with a resource server/OAuth and is, thus, - // not tested. - // - // https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html + checkpoints.add('TestTestTest - 6'); + // Verifies invocation with the ID token. Invocation with an access + // token requires integration with a resource server/OAuth and is, thus, + // not tested. + // + // https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html - final request = AWSStreamedHttpRequest.post( - Uri.parse(apiUrl).replace( - queryParameters: queryParameters, - ), - headers: { - AWSHeaders.accept: 'application/json;charset=utf-8', - AWSHeaders.authorization: - session.userPoolTokensResult.value.idToken.raw, - ...customHeaders, - }, - body: HttpPayload.json({'request': 'hello'}), - ); - print('TestTestTest - 7'); - final resp = await client.send(request).response; - print('TestTestTest - 8'); - final body = await resp.decodeBody(); - print('TestTestTest - 9'); - expect(resp.statusCode, 200, reason: body); - expect( - jsonDecode(body), - equals({'response': 'hello'}), - ); - print('TestTestTest - 10'); - customHeaders.forEach((key, value) { - expect( - resp.headers, - containsPair(key, value), + final request = AWSStreamedHttpRequest.post( + Uri.parse(apiUrl).replace( + queryParameters: queryParameters, + ), + headers: { + AWSHeaders.accept: 'application/json;charset=utf-8', + AWSHeaders.authorization: + session.userPoolTokensResult.value.idToken.raw, + ...customHeaders, + }, + body: HttpPayload.json({'request': 'hello'}), ); - }); - print('TestTestTest - 11'); - queryParameters.forEach((key, value) { + checkpoints.add('TestTestTest - 7'); + final resp = await client.send(request).response; + checkpoints.add('TestTestTest - 8'); + final body = await resp.decodeBody(); + checkpoints.add('TestTestTest - 9'); + expect(resp.statusCode, 200, reason: body); expect( - resp.headers, - containsPair('x-query-$key', value), + jsonDecode(body), + equals({'response': 'hello'}), ); - }); - print('TestTestTest - 12'); + checkpoints.add('TestTestTest - 10'); + customHeaders.forEach((key, value) { + expect( + resp.headers, + containsPair(key, value), + ); + }); + checkpoints.add('TestTestTest - 11'); + queryParameters.forEach((key, value) { + expect( + resp.headers, + containsPair('x-query-$key', value), + ); + }); + checkpoints.add('TestTestTest - 12'); + } catch (e) { + checkpoints.add('TestTestTest - Error: $e'); + throw Exception('$e - CheckPoints1 = $checkpoints'); + } }); asyncTest('can invoke with API plugin', (_) async { @@ -220,59 +225,81 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { - final cognitoPlugin = Amplify.Auth.getPlugin( - AmplifyAuthCognito.pluginKey, - ); - final session = await cognitoPlugin.fetchAuthSession(); - expect(session.credentialsResult.valueOrNull, isNotNull); + List checkpoints = []; + try { + checkpoints.add('TestTestTest - 1'); + final cognitoPlugin = Amplify.Auth.getPlugin( + AmplifyAuthCognito.pluginKey, + ); + checkpoints.add('TestTestTest - 2'); + final session = await cognitoPlugin.fetchAuthSession(); + checkpoints.add('TestTestTest - 3'); + expect(session.credentialsResult.valueOrNull, isNotNull); + checkpoints.add('TestTestTest - 4'); - final restApi = config.api!.awsPlugin!.values - .singleWhere((e) => e.endpointType == EndpointType.rest); - final apiUrl = Uri.parse(restApi.endpoint); + final restApi = config.api!.awsPlugin!.values.singleWhere( + (e) => e.endpointType == EndpointType.rest); + checkpoints.add('TestTestTest - 5'); + final apiUrl = Uri.parse(restApi.endpoint); + checkpoints.add('TestTestTest - 6'); - final payload = jsonEncode({'request': 'hello'}); - final request = AWSHttpRequest.post( - apiUrl.replace( - queryParameters: queryParameters, - ), - headers: const { - AWSHeaders.accept: 'application/json;charset=utf-8', - ...customHeaders, - }, - body: utf8.encode(payload), - ); - final signer = AWSSigV4Signer( - credentialsProvider: AWSCredentialsProvider( - session.credentialsResult.value, - ), - ); - final scope = AWSCredentialScope( - region: restApi.region, - service: AWSService.apiGatewayManagementApi, - ); - final signedRequest = await signer.sign( - request, - credentialScope: scope, - ); - final resp = await client.send(signedRequest).response; - final body = await resp.decodeBody(); - expect(resp.statusCode, 200, reason: body); - expect( - jsonDecode(body), - equals({'response': 'hello'}), - ); - customHeaders.forEach((key, value) { - expect( - resp.headers, - containsPair(key, value), + final payload = jsonEncode({'request': 'hello'}); + final request = AWSHttpRequest.post( + apiUrl.replace( + queryParameters: queryParameters, + ), + headers: const { + AWSHeaders.accept: 'application/json;charset=utf-8', + ...customHeaders, + }, + body: utf8.encode(payload), + ); + checkpoints.add('TestTestTest - 7'); + final signer = AWSSigV4Signer( + credentialsProvider: AWSCredentialsProvider( + session.credentialsResult.value, + ), + ); + checkpoints.add('TestTestTest - 8'); + final scope = AWSCredentialScope( + region: restApi.region, + service: AWSService.apiGatewayManagementApi, ); - }); - queryParameters.forEach((key, value) { + checkpoints.add('TestTestTest - 9'); + final signedRequest = await signer.sign( + request, + credentialScope: scope, + ); + checkpoints.add('TestTestTest - 10'); + final resp = await client.send(signedRequest).response; + checkpoints.add('TestTestTest - 11'); + final body = await resp.decodeBody(); + checkpoints.add('TestTestTest - 12'); + expect(resp.statusCode, 200, reason: body); + checkpoints.add('TestTestTest - 13'); expect( - resp.headers, - containsPair('x-query-$key', value), + jsonDecode(body), + equals({'response': 'hello'}), ); - }); + checkpoints.add('TestTestTest - 14'); + customHeaders.forEach((key, value) { + expect( + resp.headers, + containsPair(key, value), + ); + }); + checkpoints.add('TestTestTest - 15'); + queryParameters.forEach((key, value) { + expect( + resp.headers, + containsPair('x-query-$key', value), + ); + }); + checkpoints.add('TestTestTest - 16'); + } catch (e) { + checkpoints.add('TestTestTest - Error: $e'); + throw Exception('$e - CheckPoints2 = $checkpoints'); + } }); asyncTest('can invoke with API plugin', (_) async { From 431324a411b130acd8a2abda792a168d93415c44 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Wed, 8 Jan 2025 11:37:18 -0800 Subject: [PATCH 5/7] chore():test --- .../example/integration_test/custom_authorizer_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index 0273075bef..709e004653 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -64,7 +64,7 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { - List checkpoints = []; + final checkpoints = []; try { checkpoints.add('TestTestTest - 1'); final username = generateUsername(); @@ -225,7 +225,7 @@ void main() { }); asyncTest('can invoke with HTTP client', (_) async { - List checkpoints = []; + final checkpoints = []; try { checkpoints.add('TestTestTest - 1'); final cognitoPlugin = Amplify.Auth.getPlugin( From ba761e47facd38a4fc83409c1ff9492dc3c0a5f4 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Wed, 8 Jan 2025 11:42:42 -0800 Subject: [PATCH 6/7] chore(): test --- .../example/integration_test/custom_authorizer_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index 709e004653..ea9922db1a 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -238,7 +238,8 @@ void main() { checkpoints.add('TestTestTest - 4'); final restApi = config.api!.awsPlugin!.values.singleWhere( - (e) => e.endpointType == EndpointType.rest); + (e) => e.endpointType == EndpointType.rest, + ); checkpoints.add('TestTestTest - 5'); final apiUrl = Uri.parse(restApi.endpoint); checkpoints.add('TestTestTest - 6'); From 999c9e2110b09f29e096332b19108ea813dfa883 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Wed, 8 Jan 2025 11:47:38 -0800 Subject: [PATCH 7/7] chore(): test --- .../example/integration_test/custom_authorizer_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart index ea9922db1a..fdf7f96396 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_authorizer_test.dart @@ -138,7 +138,7 @@ void main() { ); }); checkpoints.add('TestTestTest - 12'); - } catch (e) { + } on Object catch (e) { checkpoints.add('TestTestTest - Error: $e'); throw Exception('$e - CheckPoints1 = $checkpoints'); } @@ -297,7 +297,7 @@ void main() { ); }); checkpoints.add('TestTestTest - 16'); - } catch (e) { + } on Object catch (e) { checkpoints.add('TestTestTest - Error: $e'); throw Exception('$e - CheckPoints2 = $checkpoints'); }