Victoria BanjoBack to Projects

PROJECT 02 / API TESTING

Restful BookerAPI Testing

Automated REST API testing with Postman, JavaScript assertions and Newman, covering the booking lifecycle and input validation.

COMPLETE COLLECTIONPOSTMAN
12 REQUESTS33 ASSERTIONS
API requests
12
Assertions
33

7 CRUD · 4 negative · 1 retrieval · 2 potential defects found

REST API Testing and AutomationPOSTMAN / NEWMAN / JAVASCRIPT

01 / OVERVIEW

Testing the API directly.

Project overview

A Postman collection testing the Restful Booker API end to end: authentication, the full booking lifecycle and input validation. JavaScript assertions check every response, Newman runs the collection from the command line, and GitHub Actions runs the core CRUD workflow in CI.

TECHNOLOGIES

  • Postman
  • JavaScript
  • Newman
  • REST APIs
  • JSON
  • GitHub Actions

02 / API TEST COVERAGE

Twelve requests,
three purposes.

API test coverage

A chained CRUD workflow validates the happy path; negative tests probe how the API handles bad input and missing authentication.

01

CRUD Workflow

07REQUESTS

Create, read, update and delete a single booking, chained through its ID.

  1. 01POSTCreate Auth Token
  2. 02POSTCreate Booking
  3. 03GETGet Booking by ID
  4. 04PUTUpdate Booking
  5. 05GETVerify Updated Booking
  6. 06DELETEDelete Booking
  7. 07GETVerify Deleted Booking
02

Negative Testing

04REQUESTS

Missing resources, missing authentication and invalid payloads.

  1. 01GETGet Nonexistent Booking
  2. 02PUTUpdate Booking Without Authentication
  3. 03POSTCreate Booking With Missing Fields
  4. 04POSTCreate Booking With Invalid Data Types
03

Booking Retrieval

01REQUEST

Lists all bookings independently of the lifecycle.

  1. 01GETGet All Bookings

03 / AUTOMATION APPROACH

Connected requests,
dynamic data.

Automation approach

Create Booking returns a bookingid. A test script stores it as an environment variable, and every later request in the lifecycle reuses it, so the workflow runs against fresh data each time.

  1. 01Create Booking
  2. 02Extract bookingid
  3. 03Store as environment variable
  4. 04Reuse in later requests
REQUEST CHAININGJAVASCRIPT
const responseData = pm.response.json();

if (pm.response.code === 200 && responseData.bookingid) {
  pm.environment.set("bookingId", responseData.bookingid);
}
01

Beyond status codes

pm.test and pm.expect assertions check JSON structure, data types, booking details and dates.

02

Environment variables

Base URL, auth token and bookingId live in the environment, not in individual requests.

03

Newman execution

The collection runs headlessly from the command line, making it CI-ready.

04 / TEST EXECUTION RESULTS

Core workflow versus full collection.

Test execution results

Both runs used Newman. All 12 requests executed without errors; the three failed assertions come from negative tests exposing the two findings below.

NEWMAN RUN

Core CRUD Workflow

100%ASSERTIONS PASSED
Requests
7
Assertions
21
Passed
21
Failed
0
Duration
1.735 seconds
Average response time
228 milliseconds

All assertions passed.

NEWMAN RUN

Complete API Collection

90.9%ASSERTIONS PASSED
Requests
12
Assertions
33
Passed
30
Failed
3
Duration
2.7 seconds
Average response time
207 milliseconds

Three failed assertions trace to two potential validation defects.

05 / DEFECT DISCOVERY

Beyond the happy path

Beyond the happy path

Negative testing exposed two reproducible input validation issues. I documented both and kept the failing assertions in the collection rather than weakening them.

FINDING 01

Missing required fields cause a server error

ENDPOINTPOST /booking

Request payload

{
  "totalprice": 250,
  "depositpaid": true
}
Expected behaviour
The API should reject incomplete booking information with an appropriate 4xx validation response, such as HTTP 400 Bad Request.
Observed behaviour
  • HTTP 500 Internal Server Error.
Potential impact
Incomplete requests are not handled gracefully and may provide insufficient feedback to API consumers.
Failed assertions: 1

Reproducible; pending confirmation against API requirements.

FINDING 02

API accepts invalid data types

ENDPOINTPOST /booking

Invalid input

  • totalprice supplied as "not-a-number"
  • depositpaid supplied as "yes"
Expected behaviour
The API should reject invalid data types with an appropriate client-side validation error.
Observed behaviour
  • HTTP 200 OK and a booking is created.
  • totalprice is returned as null.
  • depositpaid is converted to true.
Potential impact
Invalid input may be accepted without appropriate validation, creating a risk to booking data integrity.
Failed assertions: 2

Reproducible; pending confirmation against API requirements.

06 / CONTINUOUS INTEGRATION

A stable regression gate.

Continuous integration

GitHub Actions runs the seven-request CRUD workflow through Newman. The negative tests stay in the full collection, so known findings don't block the pipeline.

WORKFLOW HISTORY

3 SUCCESSFUL RUNS
  1. 01

    Add Postman API tests and Newman CI workflow

    15 seconds
  2. 02

    Add project documentation

    13 seconds
  3. 03

    Add API negative testing bug reports

    11 seconds

07 / EVIDENCE

From the project

Project evidence

POSTMAN

Collection and assertions

NEWMAN / GITHUB ACTIONS

Execution and CI

DOCUMENTATION

Defect reports