About API Connection test step
The API Connection test step is a protocol-agnostic test step that you use to send requests to and verify responses from various types of APIs. Currently, the test step supports gRPC, Kafka, and REST.
Tip: | For the full functionality of REST testing, use the REST Request test step. |
Supported Protocols
gRPC
The API Connection test step can be used for testing gRPC services. Currently, ReadyAPI supports only the Unary operation. It is similar to a usual request. ReadyAPI sends a request and waits for a single response from a server.
For more information on gRPC support, see gRPC Testing.
To use the API Connection test step for gRPC testing, you need to add a gRPC service to your project first.
Kafka
The API Connection test step can be used for working with asynchronous APIs, in particular Kafka. In their case, publishers send messages (or events) to a channel on a broker, and subscribers get those messages (events) by subscribing to the channel.
In ReadyAPI, the API Connection test step can operate in two modes:
-
In Publish mode, it acts as an event publisher (or producer): it connects to a broker, sends an event, and then disconnects.
-
In Subscribe mode, it acts as an event subscriber (or consumer): it connects to a broker and continues consuming events as long as the connection is open.
In other words, to send requests and get responses in ReadyAPI, you must take two test steps: the first one sends requests as a publisher, the second one gets responses as a subscriber.
For more information on Kafka support, see Kafka Testing.
To use the API Connection test step for Kafka testing, you need to first add a Kafka service to your project.
REST
The API Connection test step can be used for testing REST services. It offers a simplified and streamlined interface, compared to the original REST Request test step.
Editing API Connection test step
gRPC
Each API Connection test step is based on an operation defined in your API. ReadyAPI takes the protocol and operation specified for this request. You can link your test step to another request if needed.
Here is a brief description of the API Connection test step editor:
Toolbar items
Item | Description | ||||
---|---|---|---|---|---|
Protocol |
The protocol that will be used for the test step. |
||||
Endpoint |
The endpoint of the service.
|
||||
Authorization Profile |
The authorization profile that will be used to authenticate to the service. To learn more, see Authentication.
|
||||
Operation |
The gRPC method that will be used for the request.
|
||||
Method |
The method that will be called from a server.
|
||||
Link API |
Allows linking the test step to another request to change its operation or method. |
Sent Data
-
Data – A message to be sent to a server.
Received Data
-
Data – A message returned from a server.
Kafka
Each API Connection test step is based on a request defined in your API. ReadyAPI takes the protocol, operation, channel, and endpoint specified for this request. You can link your test step to another operation of the same type to change the channel. You can change the endpoint in the test step editor.
Here is a brief description of the API Connection test step editor:
Toolbar items
Item | Description | ||
---|---|---|---|
Protocol |
The protocol that will be used for the test step. |
||
Endpoint |
The endpoint of the broker.
|
||
Authorization Profile |
The authorization profile that will be used to authenticate to the broker. To learn more, see Authentication in Kafka. |
||
Operation |
The mode in which the test step will operate: Publish or Subscribe. |
||
Channel |
The channel to which the test step will connect.
|
||
Link API |
Allows linking the test step to another operation, thus changing the channel. |
||
Connection Settings |
Opens the connection settings. |
To learn specifics of using the API Connection test step for sending and receiving Kafka messages, see the following topics:
Simulating Producers (Publish mode)
Simulating Consumers (Subscribe mode)
REST
Each API Connection test step is based on a request defined in your API. ReadyAPI takes the protocol, operation, resource, endpoint and parameters specified for this request. You can link your test step to another request. The changes you make to your test step do not affect the base request.
Here is a brief description of the API Connection test step editor:
Toolbar items
Item | Description | ||
---|---|---|---|
Protocol |
The protocol that will be used for the test step. |
||
Endpoint |
The endpoint of the service.
|
||
Authorization Profile |
The authorization profile that will be used to authenticate to the service. To learn more, see Authentication. |
||
Operation |
The HTTP method that will be used for the request .
|
||
Resource |
The resource to which the request will be sent.
|
||
Parameters |
A query string used in the request. |
||
API Method |
Opens the base request. If you make changes to the underlying request (for example, change its method, endpoint, or add/remove parameters), they will affect the test step. |
||
Link API |
Allows linking the test step to another request. It changes the base request, and therefore the test step’s method, the endpoint, and the list of parameters inherited from the base request. |
Sent Data
-
Metadata – Parameters of the request. ReadyAPI takes the parameters from the base request of the test step. You can add more parameters in the test step or remove the existing ones; it won't affect the base request.
Parameters can be Encoded. In values of encoded parameters, URL-illegal characters such as the space character are percent-encoded. You can disable encoding if the values you use are already encoded.
To learn about the types of REST parameters, see REST Parameters.
-
Data – The body of the request.
Received Data
-
Metadata – The HTTP status and headers of the response.
-
Data – The body of the response.
Test step properties
Besides the test step editor, you can adjust test step behavior by using its properties:
API Connection Test Step properties | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Include default value fields |
This property specifies what to do if the message does not contain fields that are declared in the Protobuf schema.
|
Name |
The test step’s name. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
Include default value fields |
This property specifies what to do if the message does not contain fields that are declared in the Protobuf schema.
|
API Connection Test Step properties (Publish) | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Name |
The test step’s name. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
API Connection Test Step properties (Subscribe) | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Idle time |
Configures the Idle time condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
Messages Received |
Configures the Messages Received condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
Name |
The test step’s name. |
Run Time |
Configures the Run Time condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
Idle time |
Configures the Idle time condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
Messages Received |
Configures the Messages Received condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
Run Time |
Configures the Run Time condition when ReadyAPI should close the connection. To learn more, see Connection settings. |
API Connection Test Step properties | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Name |
The test step’s name. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
Validating messages
To check incoming messages, you use assertions:
For Kafka, assertions are only available in the Subscribe mode. |
Tip: To create complex verification conditions, you can organize assertions into assertion groups. This is particularly useful for Kafka services because one test step receives multiple messages. For example, you can add two JSONPath Match assertions to an assertion group and configure it so that the test step passes if either of those assertions passes.
Filter assertions
For Kafka, you can filter the messages to show only those that either passed or failed a certain assertion. To do that, point to an assertion and select the needed option from the drop-down list.
You can set a filter only for one assertion at a time. |
To delete the filter, click Clear:
Available assertions
Assertion | Description |
---|---|
Property Content |
|
Smart Assertion | Verifies the message content. |
Assertion | Description |
---|---|
Property Content |
|
Contains | Verifies that the incoming message contains the specified string. |
Equals | Verifies that some value in the incoming message is equal to the specified value. |
JSONPath Count | Counts the occurrences of the specified JSON item. |
JSONPath Existence Match | Checks whether the specified JSON item is present in the incoming message. |
JSONPath Match | Checks whether the specified item in the incoming message matches an expected value. |
JSONPath RegEx Match | Checks whether the specified item matches a regular expression. |
Not Contains | Verifies that the incoming message does not contain the specified value. |
Smart Assertion | Verifies the message content and metadata such as headers and parameters. |
Script |
|
Script Assertion | Executes a script to perform custom validation. |
Assertion | Description | ||
---|---|---|---|
Property Content |
|||
Contains | Verifies that the response contains the specified string. | ||
Not Contains | Verifies that a response does not contain the specified value. | ||
XPath Match | Checks whether the result of the specified XPath expression is equal to the specified value. | ||
JSONPath Match | Checks whether the specified element matches an expected value. | ||
JSONPath Existence Match | Checks whether the specified element exists. | ||
JSONPath Count | Counts the occurrences of the specified element. | ||
JSONPath RegEx Match | Checks whether the specified element matches a regular expression. | ||
Equals | Verifies that the value of a property is equal to the specified value. | ||
Equals (Binary) | Checks whether the binary response is equal to a file. | ||
Message Content Assertion | Verifies that the message contains expected contents. | ||
XQuery Match | Verifies that a result of the specified XQuery expression is equal to the specified value. | ||
Smart Assertion | Verifies the message content and metadata such as headers and the status code. | ||
Compliance, Status and Standards |
|||
Valid HTTP Status Codes | Checks whether the HTTP status code is on the specified list. | ||
Invalid HTTP Status Codes | Checks whether the HTTP status code is not on the specified list. | ||
Swagger Compliance Assertion | Verifies that a request and response are compliant with an OpenAPI or Swagger specification. | ||
HTTP Header Equals | Checks whether the response contains the expected value of an HTTP header. | ||
HTTP Header Exists | Verifies that the response contains the specified HTTP header. | ||
JSON Schema Compliance | Verifies that a request and response are compliant with the specified JSON schema. | ||
Schema Compliance | Checks whether the response is compliant with the inferred schema.
|
||
Script |
|||
Script Assertion | Executes a script to perform a custom assertion. | ||
SLA |
|||
Response SLA | Checks whether the response was returned within the specified timeout. | ||
Security |
|||
Sensitive Information Exposure | Verifies that the response does not contain any valuable information. |
Logging
While the test step editor is open, brief information on sent messages is listed in the Log tab. If the test step is run as part of a test case, you can see a more detailed log in the Transaction Log panel.