From 0969a9ee6772c96476d3e12c6acf190ea94d2b0f Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Fri, 27 Jul 2018 12:59:45 +1000 Subject: [PATCH 1/2] Properly handle the first source having user/pass --- pipenv/utils.py | 2 +- tests/unit/test_utils.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index d07d36abcf..1f0f4ef42c 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -200,7 +200,7 @@ def prepare_pip_source_args(sources, pip_args=None): # Trust the host if it's not verified. if not sources[0].get("verify_ssl", True): pip_args.extend( - ["--trusted-host", urlparse(sources[0]["url"]).netloc.split(":")[0]] + ["--trusted-host", urlparse(sources[0]["url"]).hostname] ) # Add additional sources as extra indexes. if len(sources) > 1: diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index dd3dd6d437..ab15f5cdb9 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -371,6 +371,20 @@ def test_nix_normalize_drive(self, input_path, expected): "https://user:password@custom.example.com/simple", ], ), + ( + [ + { + "url": "https://user:password@custom.example.com/simple", + "verify_ssl": False, + }, + ], + [ + "-i", + "https://user:password@custom.example.com/simple", + "--trusted-host", + "custom.example.com", + ], + ), ], ) def test_prepare_pip_source_args(self, sources, expected_args): From fd5b4ba99d7fbc03e25f8991e5ca542305d95c2d Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 31 Jul 2018 23:02:20 -0400 Subject: [PATCH 2/2] Add news entry for pr #2656 Signed-off-by: Dan Ryan --- news/2656.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2656.bugfix diff --git a/news/2656.bugfix b/news/2656.bugfix new file mode 100644 index 0000000000..c9b26c47a4 --- /dev/null +++ b/news/2656.bugfix @@ -0,0 +1 @@ +Fixed a bug which sometimes caused pipenv to parse the ``trusted_host`` argument to pip incorrectly when parsing source URLs which specify ``verify_ssl = false``.