Commit 4687ef89 by Sébastien Eustace Committed by GitHub

Fix how repository credentials are retrieved from env vars (#1909)

# Conflicts:
#	poetry/utils/password_manager.py
parent 4897a70e
......@@ -155,11 +155,14 @@ class PasswordManager:
def get_http_auth(self, name):
auth = self._config.get("http-basic.{}".format(name))
if not auth:
return None
username, password = auth["username"], auth.get("password")
if password is None:
password = self.keyring.get_password(name, username)
username = self._config.get("http-basic.{}.username".format(name))
password = self._config.get("http-basic.{}.password".format(name))
if not username and not password:
return None
else:
username, password = auth["username"], auth.get("password")
if password is None:
password = self.keyring.get_password(name, username)
return {
"username": username,
......
import os
import pytest
from keyring.backend import KeyringBackend
......@@ -208,3 +210,17 @@ def test_keyring_with_chainer_backend_and_not_compatible_only_should_be_unavaila
key_ring = KeyRing("poetry")
assert not key_ring.is_available()
def test_get_http_auth_from_environment_variables(
environ, config, mock_available_backend
):
os.environ["POETRY_HTTP_BASIC_FOO_USERNAME"] = "bar"
os.environ["POETRY_HTTP_BASIC_FOO_PASSWORD"] = "baz"
manager = PasswordManager(config)
auth = manager.get_http_auth("foo")
assert "bar" == auth["username"]
assert "baz" == auth["password"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment