Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Feb 12, 2022

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.

@notatallshaw
Copy link
Member Author

P.S I initially tried writing this with http.server functionality but supporting SSL to talk to pypi was making it too complicated too quickly.

@notatallshaw
Copy link
Member Author

Sorry this PR isn't ready yet. At the very least I need to disable network access on any port other than the proxy.

Comment on lines +27 to +30
"--proxy",
"http://127.0.0.1:8899",
"--trusted-host",
"127.0.0.1",
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2022
@notatallshaw notatallshaw deleted the proxy_integration branch March 30, 2023 16:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants