Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug proxy record requests/responses and mock sequence

I need to record sequence of api calls and then stub this sequense again.

For example my scripts going via this proxy to test.com and get response "1" - proxy recording request GET test.com and response "1", then I switching proxy to stub mode with this sequence and when my script call again test.com it getting response from stub.

I not need stub exact url, just queue of responses, if second response will return "2", then queue will be "1","2" and when twice calling test.com I must get 1 and 2 as recorded.

Maybe someone know tools which can do this? I know about charles proxy - but it seems can't do this. Sure it can remote map etc.. but I don't want always manually editing responses.

like image 594
rst630 Avatar asked Nov 27 '21 02:11

rst630


People also ask

How do I check my Charles response?

Open safari and go to chls.pro/ssl and install it. Then on the device go to settings->general->about->Certificate Thrust settings and enable the certificate. Then enable SSL proxy in Charles by going to Proxy tab->SSL proxy and voila. Finally solved it after doing this.

How do I read a Charles proxy log?

Check the proxy configuration. Open Charles Proxy, if it is not already open. Open your mobile device's browser and navigate to a site. Grant access when prompted that a device is trying to connect to your network. You should now see your mobile device's traffic in your Charles Sequence log.

How do I check my Charles request?

Viewing Requests Requests appear in the Session window when they are recorded. There are two different ways of viewing the session window: structure view and sequence view. Structure view lets you view the requests in a tree organised by the host name and then folders/directories within the host.

How do I run a mock server from a proxy?

MockServer can be run using the MockServerRule. The MockServerRule starts MockServer ( which now includes the proxy) on a free port before the any test runs and stops MockServer after all tests have completed. An instance of MockServerClient is assigned to any field in the unit test of type org.mockserver.client.MockServerClient.

What is the requests debugger tool?

A guide to identify and solve network related issues in requests or responses during BrowserStack test session, using the Requests Debugger tool.

What is @before and @after in MockServer proxy?

Before the MockServer Proxy can record any requests it must be started. MockServer is flexible and support numerous usage patterns. programmatically via a Java API in an @Before or @After method using a JUnit @Rule via a @Rule annotated field in a JUnit test from the command line as a stand-alone process in a test environment

What is a request and its response?

A request and its response is the basic element recorded in Charles. HTTP/HTTPS consists of request-response pairs: the request from your computer to the server and the response from the server. For generic sockets the request-response consists of the entire contents of the inbound and outbound streams.


Video Answer


1 Answers

@rst360, at Feather Finance we use Cypress to debug and subsequently automate tests in these kinds of situations.

By default, Cypress will request GET from test.com, but you can save the response from test.com in a fixture file (in Cypress a network stub is called a fixture). Then you can use Cypress's intercept() function to specify which given calls to test.com should be intercepted and responded with a stub.

Here are a few threads on how to use Cypress to stub network responses:

  • Cypress stubbing XHR response based on request
  • Cypress: Stubbing a particular key in JSON response

If what you are looking for is a tool to cache your own server's responses, I would suggest using Redis. This article tells you how to do it.

like image 109
Xavier Robitaille Avatar answered Oct 17 '22 06:10

Xavier Robitaille