From 86723c468b8cba1afc61419d1df6363beccb34a3 Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Thu, 30 Dec 2021 16:38:46 -0500 Subject: [PATCH] Add verbose logging for getting keyring credentials --- tests/test_auth.py | 2 ++ twine/auth.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/test_auth.py b/tests/test_auth.py index 7e59b2b8..cf0fddd7 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -86,7 +86,9 @@ def get_password(system, user): assert res.password == "real_user@system sekure pa55word" assert caplog.messages == [ + "Querying keyring for username", "username set from keyring", + "Querying keyring for password", "password set from keyring", ] diff --git a/twine/auth.py b/twine/auth.py index e8dbc1e6..514a0d15 100644 --- a/twine/auth.py +++ b/twine/auth.py @@ -56,6 +56,7 @@ def system(self) -> Optional[str]: def get_username_from_keyring(self) -> Optional[str]: try: system = cast(str, self.system) + logger.info("Querying keyring for username") creds = keyring.get_credential(system, None) if creds: return cast(str, creds.username) @@ -70,6 +71,7 @@ def get_password_from_keyring(self) -> Optional[str]: try: system = cast(str, self.system) username = cast(str, self.username) + logger.info("Querying keyring for password") return cast(str, keyring.get_password(system, username)) except Exception as exc: warnings.warn(str(exc))