HTTP Header Equals Assertion (Deprecated)

Applies to ReadyAPI 3.9, last modified on July 16, 2021
The HTTP Header Equals assertion has been superseded by the Smart Assertion and is deprecated as of ReadyAPI 3.9.0. It will remain available for the time being, but we suggest that you switch to the Smart Assertion.

The HTTP Header Equals assertion checks whether the header exists in the request or response and has the value you need.

This assertion works with test steps and virtual APIs that receive HTTP messages.

Availability

This assertion is available in multiple ReadyAPI applications. Depending on the application, it validates the following data:

In... Checks... To learn more...
Functional tests The request or response header. See Working With Assertions in Functional Tests.
Security tests The response header. See Security Assertions.
Virtual services The request header. See Assertions in Virtual Services.

Create an assertion

Follow these steps:

Functional test: The Assertions panel

Click the image to enlarge it.

  1. Open a test step.

  2. Click Add assertion.

In the New Assertions dialog, search for the HTTP Header Equals assertion or select it manually in the Compliance, Status and Standards category.

Follow these steps:

Security tests: The Assertions panel

Click the image to enlarge it.

  1. Open a security test.

  2. Click Response Assertion next to any scan.

  3. Click in the Assertions panel

In the New Assertions dialog, search for the HTTP Header Equals assertion or select it manually in the Compliance, Status and Standards category.

Follow these steps:

Virtual service: The Assertions panel

Click the image to enlarge it.

  1. Open a virtual service.

  2. Open the Assertions drop-down panel.

  3. Click in the Assertions panel

In the New Assertions dialog, search for the HTTP Header Equals assertion or select it manually in the Compliance, Status and Standards category.

Setting up properties

  1. Specify the header name in the Header field.

    ReadyAPI: Configuring the HTTP Header Equals assertion
  2. Specify the expected header value in the Value edit box.

  3. Select additional options to narrow down the expected value:

    Option Description
    Ignore case Make the search case insensitive.
    Regular Expression Treat the entered value as a regular expression.
    To learn more about the syntax of regular expressions, see the Oracle documentation.
  • The following assertion checks if the response has the Content-Type header with the application/json value:

    Header Value RegEx
    Content-Type application/json No
  • The following assertion will pass if the response has the Content-Type header with the application/json or application/xml value:

    Header Value RegEx
    Content-Type application/(json|xml) Yes
  • The following assertion checks if the format of the Date header complies with the standard:

    Header Value RegEx
    Date [a-zA-Z]{3}, \d{2} [a-zA-Z]{3}, \d{4} \d{2}:\d{2}:\d{2} GMT Yes
  • The following assertion checks if the server sends the PHPSESSID cookie and sets a valid lifetime for it in seconds:

    Header Value RegEx
    Set-Cookie PHPSESSID=\w*;.*Max-Age=\d* Yes

See Also

Smart Assertion
Compliance, Status and Standards Assertions
Header Exists Assertion

Highlight search results