question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Proxies mocking support

See original GitHub issue

Is there a way to mock a proxied request?

Something in the false line of:

@mock_proxies("proxy_server_ip:port")
def test_my_responses_tester():
    pass

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
LucaCappelletti94commented, Dec 11, 2018

Could you provide a basic example on how to achieve this?

1reaction
beliaev-maksimcommented, Apr 6, 2022

@LucaCappelletti94 @thehappydinoa can you please provide a minimal reproducible of desired behaviour?

don’t think example provided by @asfaltboy will work. Proxied request is not just a change of the URL destination. when we set a proxy, then HTTPConnection is established to the required proxy server, while destination of the URL (eg http://example.com) is preserved.

That basically means, that proxy is served on the lower level compared to requests.adapters and from user perspective it looks identical if request is sent with/without proxy. Let’s assume your proxy server changes content of the response (eg filters data), then you can just add responses.Response with required content. Next, you need to ensure, that actually proxy was applied, then you can just use matchers.request_kwargs_matcher and check that proxies were supplied

I would be glad to discuss the topic based on an example you provide

CC: @markstory

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - [Feature Request] Proxies mocking support -
Is there a way to mock a proxied request? Something in the false line of: @mock_proxies("proxy_server_ip:port") def test_my_responses_tester(): pass.
Read more >
Partial API mocking with proxy mode - Mockoon
Partially mock APIs using the proxy mode. Mockoon supports partial mocking of an API endpoints by forwarding the requests that does not match...
Read more >
Prism | Open-Source HTTP Mock and Proxy Server - Stoplight
Prism, an Open-Source HTTP Mock & Proxy Server. Accelerate API development with realistic mock servers, powered by OpenAPI documents.
Read more >
RspecProxies | Simplify Rspec mocking with test proxies !
RSpec now features minimal supports for proxies with partial mocks, spies and the and_call_original and and_wrap_original expectations.
Read more >
Requestly - Lightweight Proxy to Intercept & Modify HTTP(s ...
Requestly allows you to Intercept & Modify network requests. Main features include Mocking APIs Response, Modifying headers, Setting up redirects, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found