Skip to content

Latest commit

 

History

History
329 lines (309 loc) · 14 KB

README.md

File metadata and controls

329 lines (309 loc) · 14 KB

REST API Testing Training

This is the project I developed as part of my REST API testing training to become a Java QA Automation Engineer within the company.

Technology Stack:

  • Programming language - Java
  • Build and project management tool - Maven
  • Testing framework - JUnit 5
  • Request handling - Apache HTTP Client & Rest Assured
  • Reporting framework - Allure
  • Integration - Docker

Overview

During the training, we will test the provided web-service from a Docker container. All requirements for the web-service must work properly only for one-thread execution. The web-service handles the storage of users and their information: name, age, sex, and zip code.

Application provides:

  • Information about all stored users;
  • Possibility to create, update, delete users;
  • Information about available zip codes;
  • Possibility to add new zip codes.

Task 1 - Authentication:

  1. Go to http://localhost:/swagger-ui/ and read information about all endpoints.
  2. Create Maven project with the dependencies needed.
  3. Develop client code to get bearer tokens with read and write scopes separately.
  4. No tests should be developed for this task

Requirements:

  • Scenario #1:
    • When I send a POST request to /oauth/token
    • And I put parameters grant_type=client_credentials and scope=write
    • And I set username and password for basic auth
    • Then I get a response with a bearer token which works for any POST, PUT, PATCH, DELETE methods of web-service
  • Scenario #2:
    • When I send a POST request to /oauth/token
    • And I put parameters grant_type=client_credentials and scope=read
    • And I set username and password for basic auth
    • Then I get a response with a bearer token which works for any GET methods of web-service

Task 2 - Zip Codes:

Write tests to cover requirements for zip codes functionality

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a GET request to the /zip-codes endpoint
    • Then I get a 200 response code
    • And I get all available zip codes in the application for now
  • Scenario #2:
    • Given I am an authorized user
    • When I send a POST request to the /zip-codes/expand endpoint
    • And the request body contains a list of zip codes
    • Then I get a 201 response code
    • And zip codes from the request body are added to the available zip codes of the application
  • Scenario #3:
    • Given I am an authorized user
    • When I send a POST request to the /zip-codes/expand endpoint
    • And the request body contains a list of zip codes
    • And the list of zip codes has duplications for available zip codes
    • Then I get a 201 response code
    • And zip codes from the request body are added to the available zip codes of the application without duplicates
  • Scenario #4:
    • Given I am an authorized user
    • When I send a POST request to the /zip-codes/expand endpoint
    • And the request body contains a list of zip codes
    • And the list of zip codes has duplications of already used zip codes
    • Then I get a 201 response code
    • And zip codes from the request body are added to the available zip codes of the application without duplicates

Task 3 - Create Users:

Write tests to cover requirements for user creation functionality

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a POST request to the /users endpoint
    • And the request body contains a user to add
    • And all fields are filled in
    • Then I get a 201 response code
    • And the user is added to the application
    • And the zip code is removed from the available zip codes of the application
  • Scenario #2:
    • Given I am an authorized user
    • When I send a POST request to the /users endpoint
    • And the request body contains a user to add
    • And only required fields are filled in
    • Then I get a 201 response code
    • And the user is added to the application
  • Scenario #3:
    • Given I am an authorized user
    • When I send a POST request to the /users endpoint
    • And the request body contains a user to add
    • And all fields are filled in
    • And the zip code is incorrect (unavailable)
    • Then I get a 424 response code
    • And the user is NOT added to the application
  • Scenario #4:
    • Given I am an authorized user
    • When I send a POST request to the /users endpoint
    • And the request body contains a user to add with the same name and sex as an existing user
    • Then I get a 400 response code
    • And the user is NOT added to the application

Task 4 - Filter Users:

Write tests to cover requirements for user filtering

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a GET request to the /users endpoint
    • Then I get a 200 response code
    • And I get all users stored in the application for now
  • Scenario #2:
    • Given I am an authorized user
    • When I send a GET request to the /users endpoint
    • And I add the olderThan parameter
    • Then I get a 200 response code
    • And I get all users older than the parameter value
  • Scenario #3:
    • Given I am an authorized user
    • When I send a GET request to the /users endpoint
    • And I add the youngerThan parameter
    • Then I get a 200 response code
    • And I get all users younger than the parameter value
  • Scenario #4:
    • Given I am an authorized user
    • When I send a GET request to the /users endpoint
    • And I add the sex parameter
    • Then I get a 200 response code
    • And I get all users with sex equal to the parameter value

Task 5 - Update Users:

Write tests to cover requirements for updating user functionality

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a PUT/PATCH request to the /users endpoint
    • And the request body contains a user to update and new values
    • Then I get a 200 response code
    • And the user is updated
  • Scenario #2:
    • Given I am an authorized user
    • When I send a PUT/PATCH request to the /users endpoint
    • And the request body contains a user to update and new values
    • And the new zip code is incorrect (unavailable)
    • Then I get a 424 response code
    • And the user is NOT updated
  • Scenario #3:
    • Given I am an authorized user
    • When I send a PUT/PATCH request to the /users endpoint
    • And the request body contains a user to update and new values
    • And the required fields are not filled in
    • Then I get a 409 response code
    • And the user is NOT updated

Task 6 - Delete Users:

Write tests to cover requirements for deleting user functionality

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a DELETE request to the /users endpoint
    • And the request body contains a user to delete
    • Then I get a 204 response code
    • And the user is deleted
    • And its zip code is returned in the list of available zip codes
  • Scenario #2:
    • Given I am an authorized user
    • When I send a DELETE request to the /users endpoint
    • And the request body contains a user to delete (required fields only)
    • Then I get a 204 response code
    • And the user is deleted
    • And its zip code is returned in the list of available zip codes
  • Scenario #3:
    • Given I am an authorized user
    • When I send a DELETE request to the /users endpoint
    • And the request body contains a user to delete (any required field not filled)
    • Then I get a 409 response code
    • And the user is deleted

Task 7 - Upload Users:

Write tests to cover requirements for uploading user functionality

Requirements:

  • Scenario #1:
    • Given I am an authorized user
    • When I send a POST request to the /users/upload endpoint
    • And the request body contains a JSON file with an array of users to upload
    • Then I get a 201 response code
    • And all users are replaced with users from the file
    • And the response contains the number of uploaded users
  • Scenario #2:
    • Given I am an authorized user
    • When I send a POST request to the /users/upload endpoint
    • And the request body contains a JSON file with an array of users to upload
    • And at least 1 user has an incorrect (unavailable) zip code
    • Then I get a 424 response code
    • And the users are NOT uploaded
  • Scenario #3:
    • Given I am an authorized user
    • When I send a POST request to the /users/upload endpoint
    • And the request body contains a JSON file with an array of users to upload
    • And at least 1 user has a required field not filled
    • Then I get a 409 response code
    • And the users are NOT uploaded

Task 8 - Allure Reporting:

  • Add the Allure Framework to the project
  • Add payload to tests in the report if required
  • Add @Step annotation for better readability of the report
  • Mark tests with bugs with the corresponding Allure annotation

Task 9 - Rest Assured

  • Add the Rest Assured to the project
  • Change approach to use RestAssured without changing the tests
  • Make sure tests work as expected

Final Task - GitHub Actions:

  • Pull one more Docker image (containing an improved web-service) and start the container
  • Execute all tests in the project with Apache HTTP Client
  • Execute all tests in the project with Rest Assured Framework
  • Make sure ALL tests are passed
  • Create and add yaml file to your repo, where you should describe pipeline to execute tests from your automation framework
  • Trigger action and make sure all test are passed and Allure report is created

YAML file should describe next steps:

  1. 1. Deploy API image to Github-hosted runner (better use ubuntu-latest)
  2. Install Java
  3. Install Maven/Gradle
  4. Check out your code from git repository
  5. Build your framework
  6. Execute tests against deployed application
  7. Publish HTML results for Allure report