API Connection

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.

Important

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, and the second one gets responses as a subscriber.

For more information on Kafka support, see Kafka Testing.

Important

To use the API Connection test step for Kafka testing, you need to first add a gRPC 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:

Test step editor overview: gRPC request

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.

Important

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.

Important

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:

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:

go.gifSimulate Producers (Publish mode)

go.gifSimulate 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:

api-connection-rest-overview.png

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.

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

API Connection test step properties

To check incoming messages, you use assertions:

Simulating Kafka consumer: Add an assertion

Important

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.

Important

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
Available assertions

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

Publication date: