Skip to content

Commit 9009639

Browse files
authored
Merge pull request #11134 from q0w/revert-10998-handle-netrc
Revert "Prioritize url credentials over netrc"
2 parents 7a42bce + f8df946 commit 9009639

File tree

3 files changed

+3
-46
lines changed

3 files changed

+3
-46
lines changed

news/10979.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Revert `#10979 <https://github.com/pypa/pip/issues/10979>`_ since it introduced a regression in certain edge cases.

src/pip/_internal/network/auth.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ def _get_index_url(self, url: str) -> Optional[str]:
109109
def _get_new_credentials(
110110
self,
111111
original_url: str,
112-
*,
113-
allow_netrc: bool = False,
112+
allow_netrc: bool = True,
114113
allow_keyring: bool = False,
115114
) -> AuthInfo:
116115
"""Find and return credentials for the specified URL."""
@@ -261,7 +260,7 @@ def handle_401(self, resp: Response, **kwargs: Any) -> Response:
261260
# Query the keyring for credentials:
262261
username, password = self._get_new_credentials(
263262
resp.url,
264-
allow_netrc=True,
263+
allow_netrc=False,
265264
allow_keyring=True,
266265
)
267266

tests/functional/test_install_config.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -415,46 +415,3 @@ def get_credential(url, username):
415415
assert "get_credential was called" in result.stderr
416416
else:
417417
assert "get_credential was called" not in result.stderr
418-
419-
420-
def test_prioritize_url_credentials_over_netrc(
421-
script: PipTestEnvironment,
422-
data: TestData,
423-
cert_factory: CertFactory,
424-
) -> None:
425-
cert_path = cert_factory()
426-
ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
427-
ctx.load_cert_chain(cert_path, cert_path)
428-
ctx.load_verify_locations(cafile=cert_path)
429-
ctx.verify_mode = ssl.CERT_REQUIRED
430-
431-
server = make_mock_server(ssl_context=ctx)
432-
server.mock.side_effect = [
433-
package_page(
434-
{
435-
"simple-3.0.tar.gz": "/files/simple-3.0.tar.gz",
436-
}
437-
),
438-
authorization_response(str(data.packages / "simple-3.0.tar.gz")),
439-
]
440-
441-
url = f"https://USERNAME:PASSWORD@{server.host}:{server.port}/simple"
442-
443-
netrc = script.scratch_path / ".netrc"
444-
netrc.write_text(
445-
f"machine {server.host} login wrongusername password wrongpassword"
446-
)
447-
with server_running(server):
448-
script.environ["NETRC"] = netrc
449-
script.pip(
450-
"install",
451-
"--no-cache-dir",
452-
"--index-url",
453-
url,
454-
"--cert",
455-
cert_path,
456-
"--client-cert",
457-
cert_path,
458-
"simple",
459-
)
460-
script.assert_installed(simple="3.0")

0 commit comments

Comments
 (0)