API Connection Test Step

Applies to ReadyAPI 3.57, last modified on December 20, 2024

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

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.

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.

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

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:

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

gRPC requests support only OAuth 2.0 authentication.
Operation

The gRPC 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.
Currently, ReadyAPI supports only Unary operations.
Method

The method that will be called from a server.

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

Allows linking the test step to another request to change its operation or method.

  • Data – A message to be sent to a server.

  • Data – A message returned from a server.

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

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

Test step properties

Besides the test step editor, you can adjust test step behavior by using its properties:

API Connection test step properties

Click the image to enlarge it.

API Connection Test Step properties   | View
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.

  • true - ReadyAPI includes such fields with default values.

  • false - ReadyAPI leaves the message as it is.

Name Description
Name

The test step’s name.

Description

Text describing the test step.

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
Name

The test step’s name.

Description

Text describing the test step.

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