This is the project I developed as part of my REST API testing training to become a Java QA Automation Engineer within the company.
- 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
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.
- Go to http://localhost:/swagger-ui/ and read information about all endpoints.
- Create Maven project with the dependencies needed.
- Develop client code to get bearer tokens with read and write scopes separately.
- No tests should be developed for this task
- Scenario #1:
- When I send a POST request to
/oauth/token
- And I put parameters
grant_type=client_credentials
andscope=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
- When I send a POST request to
- Scenario #2:
- When I send a POST request to
/oauth/token
- And I put parameters
grant_type=client_credentials
andscope=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
- When I send a POST request to
Write tests to cover requirements for zip codes functionality
- 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
Write tests to cover requirements for user creation functionality
- 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
Write tests to cover requirements for user filtering
- 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
Write tests to cover requirements for updating user functionality
- 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
Write tests to cover requirements for deleting user functionality
- 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
Write tests to cover requirements for uploading user functionality
- 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
- 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
- Add the Rest Assured to the project
- Change approach to use RestAssured without changing the tests
- Make sure tests work as expected
- 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. Deploy API image to Github-hosted runner (better use ubuntu-latest)
- Install Java
- Install Maven/Gradle
- Check out your code from git repository
- Build your framework
- Execute tests against deployed application
- Publish HTML results for Allure report