maksumov / rss-shop-be

3 stars 0 forks source link

Task 7 Solution #7

Closed maksumov closed 3 years ago

maksumov commented 3 years ago

Task Definition

Task definition from https://github.com/rolling-scopes-school/nodejs-aws-tasks/blob/main/task7-lambda%2Bcognito-authorization/task.md

Task 7.1

Task 7.2

Task 7.3

Self-Check

Main Tasks

Score for main tasks: 5/5

Additional (optional) tasks

Score for additional tasks: 1/1

Total score: 6/6

URLs

  1. FE App URLs:
  2. API endpoints:
  3. FE App PR: https://github.com/maksumov/nodejs-aws-fe/pull/7

How to check FE App integration with API

Poducts CSV data sample

title,description,price,count
"Ветчина HAME Славянская, 340г","Ветчина HAME Славянская – это продукт, приготовленный на основе натуральных ингредиентов",670,2
"Блинчики SИБИРСКАЯ КОЛЛЕКЦИЯ с мясом, 800г","Блинчики SИБИРСКАЯ КОЛЛЕКЦИЯ с мясом, 800 г – аппетитный продукт из первосортной говядины и нежнейшего теста",613,122
"Бекон Венгерский ВЕЛКОМ варено-копченый, 500г","Удивите гостей вкусной закуской",263,134
"Колбаса из фанеры","Колбаса из фанеры не так уж и плоха на вкус как можно подумать",300,111
"Сыр Ромашка","Сделан не из ромашек",999,99
"Ещё что-нибудь?","Да, не помешает",12,2

App FE testing steps (suggestion)

  1. Open App FE Products Manage Page in your browser.
  2. Open console in (Chrome) Dev Tools

Test HTTP 200 response

  1. Type in console following command to set authorization_token to correct value
    // This will save correct authorization_token to 
    localStorage.setItem("authorization_token", btoa("maksumov:TEST_PASSWORD"))
  2. Try to upload (import) file with products (CSV). You should receive HTTP 200 as response.

Test HTTP 403 response (Wrong credentials)

  1. For testing HTTP 403 status code change value of authorization_token with this command:
    // This will save incorrect authorization_token to 
    localStorage.setItem("authorization_token", btoa("noname:WRONG_PASSWORD"))
  2. Try to upload (import) file with products (CSV). You should receive HTTP 403 as response.

Test HTTP 401 response (auth token absent)

  1. For testing HTTP 401 response change authorization_code in localStorage by setting its value equal to "":
    // This will delete authorization_token value
    localStorage.setItem("authorization_token", "")
  2. Try to upload (import) file with products (CSV). You should receive HTTP 401 as response.