Jun 29, 2021

Complete your GRPC development and testing workflow with Tap-Rpc

![Image 1](//images.contentful.com/urdv1oztwvyo/3o919w6Q3En799qLGo0Cc5/503dd0d27cb966b36405afadb6a2b304/0_U4QgldC65PnLsdQg.png)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 ready2. Significantly reduces dependency among developers and QA3. 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](//images.contentful.com/urdv1oztwvyo/76C8K9SRKWgJXs17OQZ8EV/2dfc3ba2f63356986e5839fe6bdf988e/0_WVVDVDfWqAZZwc-k.png)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 mode2. Monitor mode3. Client mode#### __Mock Rpc mode :__![Image 3](//images.ctfassets.net/urdv1oztwvyo/6o0u2zq2D70uR9bYkmn5sB/84739c6f5d50746996816ae8f2aa3ab3/0_-RfN5gO0wa_vMLWy.png)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](//images.contentful.com/urdv1oztwvyo/1i2Jki0MGpZ7fFkIoMVsmO/b9f3cb97cebbaf2966949438b2611f63/0_clVH7veYlZK3hHwu.png)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](//images.ctfassets.net/urdv1oztwvyo/6UpADQ3B1i30C1S1ttwPUh/fb5e2c9e80a9108c5c83d592460172fb/0_35cJlZGTYC2KNMAz.png)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

RELATED ARTICLES

No items found.
Written by
Full Name
Published on
22 January 2021

Get a free consultation on Segmentation strategy and
Ecosystem practices

Drop us a line.
Thank you! We'll be in touch soon.
Oops! Something went wrong while submitting the form.
Schedule a demo
Let’s Connect
We’ve received your request. We’ll be in touch soon.
Oops! Something went wrong while submitting the form.
Thank you! You can download the PDF now.
Download PDF
Oops! Something went wrong while submitting the form.