Complete your GRPC development and testing workflow with Tap-Rpc

Natesh Bhat & Manu KJ | Tue 29th Jun, 2021

Image 1

We at Nuclei use GRPC for our services, mainly because of the rich benefits that GRPC provides such as simple service definition through proto files, offers scalability, works across languages and platforms, supports bi-directional streaming with http2 support.

Despite these benefits, we address some of the inevitable limitations and nuances of the development and testing workflow which we often face.

Problems that we are trying to solve

The usual development and testing workflow of any project involves frontend and backend development along with QA who will be testing the project.

Frontend Concerns : Frontend developers always have the dependency on backend services to be ready, in order to build the UI and many times services would still be work in progress. Without services ready, front-end would have to manually mock the responses, which is extremely time-consuming and tedious.

Backend Concerns : Testing of backend service solely depends on the test-case that they write, and backend developers cannot modify requests in real-time coming from the application client which makes it harder to find issues.

QA Concerns : Mocking certain edge cases and scenarios at backend or client side is very difficult and time consuming which often requires changes in codebase of both client and backend. QA has no easy way to see or modify the request and responses exchanged between client and backend in real time which reveal bugs and unhandled cases many times. To tackle all the above concerns, we needed a tool that’s sits in between frontend ( client-app ) and backend ( service ).

  • A tool that lets developers see the request and response in a better way in real time, than the usual logs.
  • Allows you to modify the request and responses exchanged between client app and server in real time.
  • Allows you to generate mock responses with relevant information needed for the client-app and provide ways to send mock requests to services.

And that is where Tap-Rpc (inspired by Bloom Rpc grpc client) comes into picture.

TAP-RPC :

Tap-Rpc solves the above problems in an effective way.

  1. Eases frontend development and unblocks frontend even when backend apis are not ready
  2. Significantly reduces dependency among developers and QA
  3. Helps in effective app and backend testing

Installation and Usage :

Download the latest release from here :

https://github.com/nateshmbhat/tap-rpc/releases

Image 2

  1. In your client app, set the host and port for the grpc service to point to the Tap-Rpc’s ip address and port shown at the middle of the Tap-Rpc window title. In above picture, the address as shown in the window title is “192.168.6.54:50051”.
  2. Set the default target server URL, which is needed for the monitor and client modes. In above picture, the target server is set as “dev-01.gonuclei.com:80” which is the address of the real grpc service.
  3. User selects the proto files containing the services. Once you select proto files, all the services and Rpcs in those services appear in a tree structure and you can select a particular rpc.
  4. At this point any requests coming from the client will be forwarded to the default target server in the background.
  5. Now your client app is ready to access all the features of Tap-Rpc.

Tap-Rpc provides 3 modes of operation, each addressing a different set of problems :

  1. Mock Rpc mode
  2. Monitor mode
  3. Client mode

Mock Rpc mode :

Image 3

  1. Mock rpc mode serves mock responses to clients which can be customized. This is the mode which tries to remove the dependency on backend services. The client just needs to point to the address given in the window title to start using Tap-Rpc as a mock server.
  2. The generated mock response is dependent on the proto property names and the type of the properties which helps in generating realistic responses. Eg : image urls, address text, phone, File paths, email, names etc.
  3. The mock response can be edited on the fly.
  4. You can also choose to send mock grpc error codes with custom error messages to test error scenarios.
  5. In essence, every user of the tap-rpc tool will have the ability to have his own server that serves requests with realistic responses without the client needing to manually hardcode mock responses.

Monior mode :

Image 4

Monitor mode is the most interesting feature of Tap-Rpc which acts as a bridge between the application client and the real backend server (target server) and allows you to monitor and modify the requests and responses in real time.

  1. Users can see the requests and responses in real time as they are exchanged between client app and the server.
  2. Users can modify requests coming from clients before it reaches the backend.
  3. Users can modify responses coming back from the server before it reaches the client.
  4. User can also access and modify metadata, toggle TLS usage, forward errors, change target server to forward the requests on the fly etc.

Client mode :

0 35cJlZGTYC2KNMAz

In client mode, you can independently test your backend services by sending realistic mock requests to the target server.

  1. Use the client mode to send realistic mock requests to the backend services.
  2. Helps in testing each backend service and rpc for all various scenarios.
  3. Generates mock requests with realistic data.

Using REST and not GRPC?

If you’re using a REST service instead of grpc, we still got you covered with another tool built specifically for handling REST services and requests which you can get here : https://github.com/nateshmbhat/tap-rest/releases


divider

Liked it? Why not share it with others