-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add Proxy Integration Test #10901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Proxy Integration Test #10901
Conversation
P.S I initially tried writing this with |
Sorry this PR isn't ready yet. At the very least I need to disable network access on any port other than the proxy. |
"--proxy", | ||
"http://127.0.0.1:8899", | ||
"--trusted-host", | ||
"127.0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test would pass even if these options were changed to be no-ops. Ideally, the test should fail if the proxy server isn't used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I realized this also, I'm experimenting with disabling the network first, I tried a few different options including https://github.com/best-doctor/pytest_network but I am struggling to get the test to fail. I think there are some nuances to pytest I do not understand correctly. I am going to close the PR for now until I understand the situation better, sorry for using up your time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it was how the test was working that I failed to understand correctly, script.pip
is creating a subproces rather than calling the functions inside the same python process. Which is why I couldn't patch how it accesses to the network. I will investigate further if there is a solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not have the proxy write something to a file (essentially just "Hi, I was used") and then check the existence of the file? Or just set the proxy to write log output and check that, if that's easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfmoore That makes a lot of sense. Unfortunately it seems that "proxy.py" has issues outputting access logs on Windows, I've raised an issue over there to see if there's an easy fix.
In the mean time I am checking if I could use it's plugin architecture to extract the details in another way or find another proxy tool that gives me the details more simply.
Initial proxy Integration test.
Uses proxy.py which seems to be a very fast well maintained Python proxy server. Seems it could be expanded to test lots of other possible proxy configurations (e.g. TLS interception for custom certificate authority).
Currently just using all default settings, but easy enough to add port number and other configuration.