How to automate API an User login if the authentication of application is using AWS Auth - Cognito

 Cognito AWS Auth

You can refer to this link: AWS Cognito

https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html


Automated test script to login app with Cognito:

In order to do E2E automated test script for your application with Auth Cognito AWS, we follow Cognito Guide from AWS.

https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html

Before we implement more test scripts to cover testing for internal function of your app, you need to login your app by your credential information, then you can have the token of your test-account.

The below command in CURL command helps you to make an auth request to AWS Cognito to get account token.



curl --location --request POST 'https://cognito-idp.{{region}}.amazonaws.com/' \
--header 'Content-Type: application/x-amz-json-1.1' \
--header 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
--data-raw '{
"AuthParameters" : {
"USERNAME" : {{username}},
"PASSWORD" : {{password}}
},
"AuthFlow" : "USER_PASSWORD_AUTH",
"ClientId" : {{client_id}}
}'





Comments