API Connection Test Step

Applies to ReadyAPI 3.10, last modified on October 07, 2021

About API Connection test step

The API Connection test step is a protocol-agnostic test step that can be used for working with various types of APIs. Currently, the test step supports two protocols: Kafka and REST BETA.

Tip: For the full functionality of REST testing, use the REST Request test step.

Supported protocols

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.

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.

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.

The functionality of testing REST services via the API Connection test step is still in beta, so some features, like attachments, are missing. Use the original REST Request test step if you need them.

Editing API Connection test step

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:

Test step editor overview: Publish mode

Click the image to enlarge it.

Test step editor overview: Subscribe mode

Click the image to enlarge it.

Item Description
Protocol

The protocol that will be used for the test step.

Endpoint

The endpoint of the broker.

Tip: You can use environments to set up the endpoint.
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.

Tip: To change the channel, use the Link API button to link the test step to another operation.
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)

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:

REST request editor overview

Click the image to enlarge it.

Item Description
Protocol

The protocol that will be used for the test step.

Endpoint

The endpoint of the service.

Tip: You can use environments to set up the endpoint.
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 .

Tip: To change the method, use the Link API button to link the test step to another request.
Resource

The resource to which the request will be sent.

Tip: To change the resource, use the Link API button to link the test step to another request.
Link API

Allows linking the test step to another request. If you make changes to the underlying request (for example, change a method or endpoint or add or remove parameters), they will affect the test step.

  • 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.

  • Metadata – The HTTP status and headers of the response.

  • Data – The body of the response.

Validating messages

To check incoming messages, you use assertions:

Simulating Kafka consumer: Add an assertion

Click the image to enlarge it.

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.
Simulating Kafka consumer: Filter assertions

To delete the filter, click Clear:

Simulating Kafka consumer: Clear assertion filtering

Click the image to enlarge it.

Available assertions
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.
The API Connection does not support specifying a schema from a service definition.
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.

See Also

Test Steps
Kafka Testing
REST Request Test Step

Highlight search results