Test with front-end

We will try registration and login from web application to test API Gateway, Lambda function and User pool working.

  1. Open API Gateway console

    • Click API Gateway REST API to Lambda
  2. Select Stage on the left menu

    • Click staging
    • Record InvokeURL UpdateSource
  3. Open config.js file in source code folder of application - FCJ-Serverless-Workshop

    • Replace APP_API_URL with InvokeURL
  4. Run the below commands:

      yarn build
      aws s3 cp build s3://fcj-book-store --recursive
    
  5. Open Amazon S3 console. Click fcj-book-store bucket UpdateSource

  6. Click Properties tab. Scroll down to bottom, click to web endpoint UpdateSource

  7. Click Register on right corner UpdateSource

  8. Enter registration information: email, password and re-enter password

    • Click Register button
  9. A prompt will appear displaying the Register fail

    • The error due our API missing Access-Control-Allow-Headers in response headers UpdateSource

      Register with the email you are using to get the account verification code

  10. To resolve this error, open template.yaml file in source of fcj-book-store-sam-ws3.zip file

    • Add the below script for BookApi
      AllowMethods: "'GET,POST,OPTIONS,DELETE'"
      AllowHeaders: "'content-type'"
      AllowOrigin: "'*'"
    

    UpdateSource

    • Run the following commands:
     sam build
     sam deploy --guided
    
  11. Go back to the registration screen and click Register button UpdateSource

  12. Back to the Amazon Cognito console

    • At Users tab, display a user but still in Unconfirmed state UpdateSource
  13. Open the email you just registered for an account, get the confirmation code sent from no-reply@verificationemail.com

  14. Enter the confirmation code in the verification screen

    • Click Submit UpdateSource
  15. Back to the Amazon Cognito console

    • State of user changed to Confirmed UpdateSource
  16. Enter account information: email, password to login

    • Click Submit UpdateSource
  17. After successful login, the features: Create new book, Management, Order appear allowing users to use UpdateSource