liveBook · Manning

API testing

As explained in Secure APIs

API security testing is the systematic evaluation of an API's behavior, interfaces, data handling, and security properties.

API testing evaluates whether an API behaves as intended and resists exploitable behavior. Security testing complements threat modeling and best practices by providing confidence that implementations are not vulnerable to attacks. section 12.0

A practical API security testing strategy combines:

  • Penetration testing for expert, API-specific assessment; its results are strong but the work is expensive, slow, and difficult to scale. section 12.0
  • Automated tools for fast malicious-injection and configuration checks; they depend on good configuration and can miss business-logic flaws. section 12.0
  • Custom tests that target API-specific flaws, including authorization failures and unexpected business-flow behavior. section 12.0 section 12.5

Testing coupon abuse

A pytest test registers one student to obtain a voucher, authenticates as another student, and submits that voucher to a course-registration endpoint. The expected response is 403. A successful registration exposes missing user-based access control and may combine with a BOLA flaw. Repeating similar unit tests on every code change helps detect regressions and unexpected behavior. section 12.5

How Secure APIs covers it

How deep it goes
Combines strategy guidance with pytest fixtures, endpoint requests, expected status codes, and repeatable business-flow tests.
Examples
Uses pytest fixtures, coupon reuse checks, cross-user coupon abuse, registration endpoints, bearer tokens, and expected 403 responses.
What it assumes
Assumes an API design, implementation, threat model, and knowledge of its user flows, while using concrete tests to expose their weaknesses.
What you can do after
Diagnose authorization and business-flow flaws with repeatable unit tests and combine automated checks with targeted penetration testing.
How it connects
Connects threat modeling, penetration testing, automated testing, business logic, access control, BOLA, CI/CD, and API design.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.