caposcar1998 / back-bootcamp

Backend bootcamp
0 stars 0 forks source link

Backend #2

Open alamrios opened 2 years ago

alamrios commented 2 years ago
alamrios commented 2 years ago

Scenario: Set-up development environment

Given: Golang microservice project template And: Aurora database working When: Project created And: Project could be started And: Aurora database accessible Then: Development environment ready to use

Scenario: Set-up development environment (fail Aurora database)

Given: Golang microservice project template When: Aurora database not working Then: Deploy Aurora database When: Project created And: Project could be started And: Aurora database accessible Then: Development environment ready to use

Testing

  1. Test that the server can communicate with the database
    • Create a connection with the database
    • SELECT FROM
    • Return should bring all the information
  2. Test that the microservice is running -Run go run .
    • Server should start
alamrios commented 2 years ago

Scenario: Golang microservice for users (CREATE)

Given: Using API to create a new user When: Call to users microservice using POST /users/ And: Valid user found in request body And: Password can be decoded using SHA-256 Then: Return 201 http status and same user object created in json format

Scenario: Golang microservice for users (CREATE fail)

Given: Using API to create a new user When: Call to users microservice using POST /users/ And: Invalid user found in request body or password can not be decoded using SHA-256 Then: Return 400 http status and error message

Testing

  1. Create user with complete information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with all correct information
    • Response should return 200
  2. Create user with incomplete information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 without all values
    • Response should return 400
  3. Create user with no information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with empty json
    • Response should return 400
  4. Create user without json formation
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with XML structure
    • Response should return 400
  5. Create user with incorrect format password
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with password less than 5 characters
    • Response should return 400
  6. Create user with password not decoded
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with password not decoded
    • Response should return 400
alamrios commented 2 years ago

Scenario: Golang microservice for users (UPDATE)

Given: Using API to update a new user When: Call to users microservice using PUT /users/{id_user} And: Valid id_user found in request And: Valid user found in request body And: Password can be decoded using SHA-256 Then: Return 200 http status and updated user object in json format

Scenario: Golang microservice for users (UPDATE)

Given: Using API to update a new user When: Call to users microservice using PUT /users/{id_user} And: Invalid id_user found in request or invalid user found in request body or password can not be decoded using SHA-256 Then: Return 400 http status and error message

Testing

  1. Edit user with complete information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with all correct information
    • Response should return 200
  2. Edit user with incomplete information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 without all values
    • Response should return 400
  3. Edit user with no information
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with empty json
    • Response should return 400
  4. Edit user without json formation
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with XML structure
    • Response should return 400
  5. Edit user with incorrect format password
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with password less than 5 characters
    • Response should return 400
  6. Edit user with password not decoded
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make POST HTTP Request to endpoint with port 8002 with password not decoded
    • Response should return 400
alamrios commented 2 years ago

Scenario: Golang microservice for users (READ by id)

Given: Using API to retrieve a user When: Call to users microservice using GET /users/{id_user} And: Valid id_user found in request Then: Return 200 http status and user object in json format

Scenario: Golang microservice for users (READ all)

Given: Using API to retrieve all users When: Call to users microservice using GET /users/ Then: Return 200 http status and user object lists in json format

Testing

  1. Read user with existing id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make GET HTTP Request to endpoint with port 8002 with id
    • Response should return 200
  2. Read user with no existing id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make GET HTTP Request to endpoint with port 8002 with an no existing id
    • Response should return 400
  3. Read user with letter id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make GET HTTP Request to endpoint with port 8002 with id as a letter
    • Response should return 400
  4. Read user without id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make GET HTTP Request to endpoint with port 8002 without id
    • Response should return 200
alamrios commented 2 years ago

Scenario: Golang microservice for users (DELETE)

Given: Using API to delete a user When: Call to users microservice using DELETE /users/{id_user} And: Valid id_user found in request Then: Return 200 http status

Scenario: Golang microservice for users (DELETE user not found)

Given: Using API to delete a user When: Call to users microservice using DELETE /users/{id_user} And: No user found with given id_user Then: Return 400 http status and error message

Testing

  1. Delete user with existing id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make DELETE HTTP Request to endpoint with port 8002 with id
    • Response should return 200
  2. Delete user with no existing id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make DELETE HTTP Request to endpoint with port 8002 with an no existing id
    • Response should return 400
  3. Delete user with letter id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make DELETE HTTP Request to endpoint with port 8002 with id as a letter
    • Response should return 400
  4. Delete user without id
    • Build mock for SQL database
    • Inject SQL mock to repository
    • Make DELETE HTTP Request to endpoint with port 8002 without id
    • Response should return 200
alamrios commented 2 years ago

Scenario: Golang microservice for users deploy

Given: Development environment ready to use When: New users microservice deploy And: Port 8001 free to use Then: Deploy golang microservice for users in port 8001

alamrios commented 2 years ago

Scenario: Golang microservice for login deploy

Given: Development environment ready to use When: New login microservice deploy And: Port 8002 free to use Then: Deploy golang microservice for users in port 8002

Test case

  1. Build mock for SQL database with an existing user
  2. Inject SQL mock to repository
  3. Make HTTP Request to endpoint with port 8002 and mocked parameters in request body
  4. Response should return 200

Scenario: Golang microservice for login success

Given: User tries to access the application When: Call to login microservice using POST /login/ And: Valid user found in request body And: Password can be decoded using SHA-256 And: Users exists Then: Returns 200 http status

Test case

  1. Build mock for SQL database with an existing user
  2. Inject SQL mock to repository
  3. Make POST HTTP Request to endpoint with port 8002 and mocked parameters in request body (existing user and password)
  4. Response should return 200

Scenario: Golang microservice for login fail

Given: User tries to access the application When: Call to login microservice using POST /login/ And: Invalid user found in request body or user does not exists or password can not be decoded Then: Returns 400 http status and error message

Test case 1

  1. Build mock for SQL database with an existing user
  2. Inject SQL mock to repository
  3. Make POST HTTP Request to endpoint with port 8002 with wrong username but proper password
  4. Response should return 400

Test case 2

  1. Build mock for SQL database with an existing user
  2. Inject SQL mock to repository
  3. Make POST HTTP Request to endpoint with port 8002 with wrong password but proper username
  4. Response should return 400