Colin-b / pytest_httpx

pytest fixture to mock HTTPX
https://colin-b.github.io/pytest_httpx/
MIT License
344 stars 32 forks source link

How can I test if the request is being proxied? #115

Closed DeoLeung closed 12 months ago

DeoLeung commented 12 months ago

hi,

I just wonder how to test if a request is sent via proxy, it's not reporting CONNECT nor the request is being proxied.

Colin-b commented 12 months ago

Hi @DeoLeung

Right now there is no way to retrieve proxy parameters linked to a request.

  1. Is this a feature you need?
  2. I assume you would want to assert the URL used for proxy? (including credentials if any?)
Colin-b commented 12 months ago

Since release 0.26.0 you can now match on proxy_url (str, regex or httpx.URL), order of query parameters does not matter (even though it's unlikely you provide any to your proxy url)

DeoLeung commented 12 months ago

thank you for the quick response!

It works, just to mention currently for the proxy_url we need to append an / at the end.

Colin-b commented 12 months ago

thank you for the quick response!

It works, just to mention currently for the proxy_url we need to append an / at the end.

I think this is the actual URL queried by httpx, I might be wrong though, I will check it and fix it if this is not the actual one :)