-
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 6 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 |
---|---|---|
|
@@ -118,6 +118,34 @@ def test_get_html_response_no_head(url): | |
] | ||
|
||
|
||
def test_get_html_response_dont_log_clear_text_password(caplog): | ||
""" | ||
`_get_html_response()` shouldn't send a HEAD request if the URL does not | ||
look like an archive, only the GET request that retrieves data. | ||
""" | ||
password = "my_password" | ||
url_template = "https://user:{}@example.com/simple/" | ||
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. You won't need these two variables (see below). |
||
session = mock.Mock(PipSession) | ||
|
||
# Mock the headers dict to ensure it is accessed. | ||
session.get.return_value = mock.Mock(headers=mock.Mock(**{ | ||
"get.return_value": "text/html", | ||
})) | ||
|
||
caplog.set_level(logging.DEBUG) | ||
|
||
resp = _get_html_response(url_template.format(password), session=session) | ||
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. Instead of using |
||
|
||
assert resp is not None | ||
|
||
assert len(caplog.records) == 1 | ||
record = caplog.records[0] | ||
assert record.levelname == 'DEBUG' | ||
assert record.message.splitlines() == [ | ||
"Getting page {}".format(url_template.format("****")), | ||
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. Again, you can just check that actual string instead of using nested format strings, so |
||
] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url, vcs_scheme", | ||
[ | ||
|
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.
Looks like this docstring was copied without updating.