Course outline
Lab: API tests from one cURL command
Turn one cURL command into API tests with QAIA, run them, and find where the API differs from its own document.
An API test checks what a page never shows: status codes, data types, limits and error answers. A single cURL command holds everything needed to start: the method, the address, the headers and the body.
In this lab QAIA turns Cedar Books cURL commands into API tests. You run them, then hold each answer against the shop's OpenAPI document, its contract.
What you need
- A QAIA account on Pro or Enterprise, signed in: API Analysis is not part of the Free plan.
- The shop's API docs page, with a cURL example for every call, and its OpenAPI document.
- Optional: a terminal with cURL, to try your own requests.
Steps
- Open the API docs and copy the cURL of GET /api/books?limit=5. It needs no sign-in.
- In QAIA, open API Analysis, paste the command and analyse it. Read the tests QAIA wrote, then run them.
- Sign in through POST /api/auth/login with a demo shopper, and copy the token from the answer.
- Analyse the cURL of POST /api/basket/items with the token, then POST /api/coupons/apply. Run their tests.
- Try the edges yourself: an unknown book id, a basket line that does not exist, limit 0 and limit 51, a review with 0 stars, a wrong email and a wrong password at sign-in, six wrong passwords in a row, and an order number that is not yours.
- For every answer, compare the status code, the field types and the message with the OpenAPI document. Then sign in here and press "Check my QAIA run".
Hints
Stuck? Open one hint at a time, and try again after each one.
Hint 1
Check types, not only status codes: a number sent as text breaks the apps that read it.
Hint 2
Should "wrong email" and "wrong password" get different messages? Read REQ-01.
Hint 3
A 500 with a stack trace is never the right answer to a bad request.
Hint 4
Each demo shopper has an order of their own. Sign in as one and ask for the other's: REQ-12 says what should happen.
Done? Record it
This lab is done with QAIA, so it needs a QAIA account. Sign in, finish the run, then come back here to record it.
Finished it in QAIA? The Academy looks for your own finished run, and reads only that it happened. What counts: A finished API Analysis of a cURL command that calls https://practice.qaia.io.
The planted bugs
This lab is about 8 of the shop's planted bugs. Compare what you found with the planted bugs of this lab below: there are more in the API than on the pages.
Sign in to see the planted bugs this lab is about. They are kept off this page, so nobody reads them by accident before trying.
Try the lab before you look: a bug you find yourself teaches far more than one you read about.
Learn the skill
Free tools that help with this lab