Logo: Relish

  1. Sign up
  2. Sign in

Project: Gavel 1.2.0

Gavel 1.2.0

Behavior spec for Gavel, validator of HTTP transactions

GitHub repository npm version

Gavel - Validator of HTTP Transactions

What is Gavel?

Gavel detects important differences between actual and expected HTTP transactions (HTTP request and response pairs). Gavel also decides whether the actual HTTP transaction is valid or not.

Input:

  • Expected HTTP request and corresponding response
  • Actual HTTP request and corresponding response

Output:

  • Validation verdict (boolean) or validation result (complex information about what's different)

Gavel is useful specifically in testing HTTP APIs. It enables specification by example and BDD approach. The most prominent project built on top of Gavel is Dredd, framework which tests HTTP APIs against their documentation.

Implementations

Command-line Interface

Gavel's CLI works well together with curl --trace and the curl-trace-parser utility:

$ curl --trace - http://httpbin.org/ip | curl-trace-parser > expected
$ curl --trace - http://httpbin.org/ip | curl-trace-parser > actual
$ cat actual | gavel expected
$ echo $?
0

To learn more about the CLI, head to the Command-line interface topic.

Expectations

See following paragraphs for a basic overview of how Gavel works. To learn more about the expectations, head to the General validation behavior topic.

Response status

Status code of the expected response must be the same as the one in the actual response.

Request and response headers

  • All expected request headers must be present in the actual request. The same applies for responses.
  • Names of headers are validated in case-insensitive way.
  • Only values of headers significant for content negotiation are validated.
  • All other header values can differ.

For more information see the respective topic.

Request and response body

Topics

  1. Gavel.js - JavaScript implementation
  2. General Validation Behavior
  3. add-implementation
  4. Command-line interface
  5. Data model
  6. Data validators and output format

Last published 7 days ago by honzajavorek.