gRPC Testing

About gRPC

gRPC is a remote procedure call system created by Google. It allows a client application to call methods on a server machine over the network.

One of the pillars of gRPC is protocol buffers. Protocol buffers are a mechanism for describing structured data. gRPC uses it for two main reasons:

  • Protocol buffers act as an interface definition language. They describe what functions a client can call from the server as well as the structure of the messages.

  • gRPC uses protocol buffers to serialize and deserialize messages.

A single protocol buffer is a text file with the *.proto extension. The file contains description of the used data types, and available methods of one or several gRPC services.

Requirements

To send requests to gRPC services, you use the API Connection test step. To add it to a test case, you need a ReadyAPI Test Pro license. If you do not have it yet, start the ReadyAPI trial.

Working with gRPC in ReadyAPI

In ReadyAPI, you use a protocol buffer as a service definition. When you import it to create an API, ReadyAPI creates a structure of the service and shows all the available operations in the Navigator tree.

To send requests to and get responses from gRPC services in ReadyAPI, you use the API Connection test step.

In ReadyAPI, you use a protocol buffer as a service definition. When you import it to create an API, ReadyAPI creates a structure of the service and shows all the available operations in the Navigator tree.

To send requests to and get responses from gRPC services in ReadyAPI, you use the API Connection test step.

ReadyAPI now supports .proto files that import other .proto files.

Limitations

  • Currently, ReadyAPI supports only a Unary operation. This operation works as a usual functional call or a request - a client sends a request and the server responses with the result of the operation.

Add a gRPC definition to a project

  1. Click flyout-ellipsis.pngnext to the APIs node and select Import API Definition:

    API testing: Add APIs flyout menu

    — or —

    Right-click the APIs section in the Navigator and select Import API Definition:

    API testing: Add APIs menu item
  2. Enter the path to the .proto file in the My Computer tab if the definition is stored on your computer, or enter its URL in the URL tab if it is stored online. ReadyAPI will determine the type of the definition automatically, so just click Import API.

    Figure 1. My Computer
    My Computer

    Importing the definition from My Computer.



    Figure 2. URL
    URL

    Importing the definition from the URL.



Add a gRPC request to a test case

  • Make sure you add a gRPC API to your project as described above.

  • Add the API Connection test step to a test case:

    gRPC testing in ReadyAPI: Adding the API Connection test step
  • Configure the test step according to your needs:

    gRPC testing in ReadyAPI: Configuring the API Connection test step

    To learn more, see API Connection Test Step.

  • Add assertions to verify the service response:

    gRPC testing in ReadyAPI: Verifying gRPC request

    To learn more, see Smart Assertion.

Authentication in gRPC services

ReadyAPI supports the following authentication mechanisms built in gRPC:

  • SSL/TLS - ReadyAPI uses the Transport Layer Security protocol to authenticate a server and encrypt sent and received messages.

    Tip

    It is also possible to use client authentication with a certificate. However, to do this, you must add the certificate to a keystore specified in ReadyAPI preferences. The API Connection test step does not support request-specific keystores. To learn more, see SSL Client Auth.

  • SSL/TLS + Google OAuth 2.0 token - ReadyAPI uses token-based authentication with Google. To learn how to configure it, see OAuth 2.0 and OAuth 2.0 (Azure). This method also requires sending messages over the SSL/TLS protocol.

  • No Authentication - ReadyAPI sends messages without authentication data and without encryption.

Important

By default, ReadyAPI uses the SSL/TLS method, so it expects the server has a certificate. If the server does not have it, ReadyAPI cannot establish a connection and shows an error. If your server does not use an SSL/TLS certificate, set the Transport Security property to false:

Transport Security property

Next Steps

go.gifAPI Connection Test Step

go.gifEnabling OAuth 2.0 Authentication

See Also

Publication date: