A Postman collection created to test the Petfinder.com RESTful API.
This project was created to practice using the Postman GUI for API testing and authentication methods, as well as exporting and automating the collection to run with the Newman CLI, and generating HTML reports of test outcomes via the Newman Reporter in a continuous integration fashion with GitHub Actions.
- Authentication using OAuth 2.0
- Automated continuous integration (CI) set to run the test collection with Newman any time an update is made to the
main
repository branch via GitHub Actions - Generates an HTML report of the test outcomes at runtime and exports the report to a folder called Artifacts
Base Url: https://api.petfinder.com/v2
Authentication
POST /oauth2/token
Steps
- Send a request for an access token, passing in encrypted variables for
client_id
andclient_secret
- Capture the access token from the response body and store in an encrypted variable to be included in the header to authorize subsequent requests
Expected Results
- Returned successful status code of
200
Happy Path API Requests
Returns one "page" of animals (default of 20 animals per page)
GET /animals
Expected Results
- Returns successful status code of
200
- Response time is less than 2 seconds
- Returns one page with the default number of animals (20)
- Returns a JSON object containing an
"animals"
array of objects
Accepts a string query parameter for location and returns animals within the default 100 mile proximity
GET /animals?location={city, state}
GET /animals?location={postal_code}
Expected Results
- Accepts a string parameter
- Returns successful status code of
200
- Response time is less than 2 seconds
- Animals returned have distance property value less than the default 100 miles
Accepts an integer query parameter for distance in miles and returns animals within the specified proximity of the set location
GET /animals?location={postal_code}&distance={miles}
Expected Results
- Accepts an integer, max: 500
- Returns successful status code of
200
- Response time is less than 2 seconds
- Animal objects returned have
distance
property values less than miles parameter requested
Returns an array with every animal type
GET /types
Expected Results
- Returns successful status code of
200
- Response time is less than 2 seconds
- Response includes every animal type in the database
Returns details on a specific animal based on an integer ID
GET /animals/{id}
Expected Results
- Accepts an integer
- Only succeeds if there is an ID match in the database
- Returns successful status code of
200
- Response time is less than 2 seconds
- Response contains an object
- Animal returned has an ID that matches the ID sent in the request
Sad Path API Requests
Attempts to make a request with an invalid token
GET /animals
header: 'Authorization: Bearer abc123'
Expected Results
- Returns status code of
401
Unauthorized - Returns message with
"Access token invalid or expired"
Attempts to make a request with an invalid token
GET /types
header: 'Authorization: Bearer abc---123'
Expected Results
- Returns status code of
401
Unauthorized - Returns message with
"Access token invalid or expired"
Attempts to make a request without a token
GET /animals
Expected Results
- Returns status code of
401
Unauthorized - Returns message with
"Access token invalid or expired"
Attempts to make a request using Basic Auth and passing a Username and Password
GET /animals
Expected Results
- Returns status code of
401
Unauthorized - Returns message with
"Access token invalid or expired"
Attempts to make a request to an invalid endpoint
GET /animal
Expected Results
- Returns status code of
404
- Returns status title
"Not Found"
- Response detail contains
"No route found"
Attempts to make a request to an invalid endpoint
GET /animals/types
Expected Results
- Returns status code of
404
- Returns status title
"Not Found"
- Response detail contains
"No route found"
Attempts to request animal by ID, where ID is a string
GET /animals/abcdefg
Expected Results
- Returns status code of
404
- Returns status title
"Not Found"
- Returns response detail
"Not Found"
Attempts to request animal by ID, where ID does not exist
GET /animals/11111111
Expected Results
- Returns status code of
404
- Returns status title
"Not Found"
- Returns response detail
"Not Found"
Attempts to request animal by ID, where ID contains special characters
GET /animals/65289840!
Expected Results
- Returns status code of
404
- Returns status title
"Not Found"
- Returns response detail
"Not Found"
Actual Results
- Returns status code of
200
- Returns an animal with ID
65289840
Attempts to request animals by city without including the state parameter
GET /animals?location=denver
Expected Results
- Returns status code of
400
bad request - Returns response detail
"The request contains invalid parameters."
- Returns error type
"ERR-00002"
- Response with
invalid-params
array indicating an error in the"query"
- Response with
invalid-params
array indicating an error in the parameter named,"location"
- Response with
invalid-params
array indicating a parameter error reason of"Could not determine location."
Attempts to request animals by state with special characters
GET /animals?location=washington*
Expected Results
- Returns status code of
400
bad request - Returns response detail
"The request contains invalid parameters."
- Returns error type
"ERR-00002"
- Response with
invalid-params
array indicating an error in the"query"
- Response with
invalid-params
array indicating an error in the parameter named,"location"
- Response with
invalid-params
array indicating a parameter error reason of"Could not determine location."
Attempts to request animals by postal code with special characters
GET /animals?location=34787!
Expected Results
- Returns status code of
400
bad request - Returns response detail
"The request contains invalid parameters."
- Returns error type
"ERR-00002"
- Response with
invalid-params
array indicating an error in the"query"
- Response with
invalid-params
array indicating an error in the parameter named,"location"
- Response with
invalid-params
array indicating a parameter error reason of"Could not determine location."
Attempts to request animals by distance from a location in miles, where distance is a string
GET /animals?location=34787&distance=twenty
Expected Results
- Returns status code of
400
bad request - Returns response detail
"The request contains invalid parameters."
- Returns error type
"ERR-00002"
- Response with
invalid-params
array indicating an error in the"query"
- Response with
invalid-params
array indicating an error in the parameter named,"distance"
- Response with
invalid-params
array indicating a parameter error reason of"This value should be a valid number."