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.
-
Temporarily disabled the option to create a gRPC Virt Service.
Add a gRPC definition to a project
-
Click next to the APIs node and select Import API Definition:
— or —
Right-click the APIs section in the Navigator and select Import API Definition:
-
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.
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:
-
Configure the test step according to your needs:
To learn more, see API Connection Test Step.
-
Add assertions to verify the service response:
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.
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: