The Message Content assertion has been superseded by the Smart Assertion as of ReadyAPI 3.9.0. The assertions will continue to be available, but we recommend transitioning to Smart Assertions. |
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
Setting up properties
-
Specify the header name in the Header field.
-
Specify the expected header value in the Value edit box.
-
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.
Examples
-
The following assertion checks if the response has the
Content-Type
header with theapplication/json
value:Header Value RegEx Content-Type application/json
No -
The following assertion will pass if the response has the
Content-Type
header with theapplication/json
orapplication/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
Other assertions for status codes and headers
Add more assertions for HTTP status codes and response headers:
See Also
Smart Assertion
Compliance, Status and Standards Assertions
Header Exists Assertion