-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Redact URL to hide password #6295
Changes from 3 commits
00b872f
34b123d
5c232bc
ddb7320
70dee95
c33535b
1214941
5bfb47c
137a7ab
b37ad3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,24 @@ def test_command_line_options_override_env_vars(script, virtualenv): | |
assert "Getting page https://download.zope.org/ppix" in result.stdout | ||
|
||
|
||
def test_no_password_in_debug_message(script, virtualenv): | ||
""" | ||
Test that password in the URL is not logged | ||
""" | ||
password = "my_password" | ||
|
||
script.environ['PIP_INDEX_URL'] = ( | ||
'https://user:{}@example.com/simple/'.format(password) | ||
) | ||
result = script.pip('install', '-vvv', 'INITools', expect_error=True) | ||
|
||
assert password not in result.stdout | ||
assert ( | ||
"Getting page https://user:***@example.com/simple/initools" | ||
in result.stdout | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition, you might as well assert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
|
||
@pytest.mark.network | ||
def test_env_vars_override_config_file(script, virtualenv): | ||
""" | ||
|
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 the environ options instead of passing
'--index-url', 'https://user:{}@example.com/simple/'.format(password)
to script.pip ?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.
@xavfernandez Can you confirm if this test hits the network as written? It would be a lot better IMO if it didn't as I think such cases should be reduced to a minimum.
@expobrain It might be better to write a unit test (so in the
unit
directory rather thanfunctional
) of_get_html_response()
to avoid hitting the network. You can look attest_get_legacy_build_wheel_path__no_names()
and nearby functions for examples of using thecaplog
fixture (since the code wouldn't be running in a separate subprocess).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.
PS - it looks like there are already a number of unit tests of that function (search for
test_get_html_response_
), and you can follow the examples there of mocking the session response.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.
I confirm it should (I was actually thinking about suggesting to add the
network
marker to the test) and I don't see a way around that for a functional test.An unit test could indeed also remove the need for network.
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.
FYI, here's an example of a test failing because of flakiness due to installing
INITools
in the test: https://dev.azure.com/pypa/pip/_build/results?buildId=5274&view=logs&jobId=c897e773-a04c-5d18-b461-2c6584d92c5aThere 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.
@cjerdonek I've moved the test into
unit
, please have a look at it