Skip to content

Commit

Permalink
Merge pull request #849 from bhrutledge/847-log-keyring
Browse files Browse the repository at this point in the history
Add verbose logging for querying keyring credentials
  • Loading branch information
sigmavirus24 authored Dec 31, 2021
2 parents d82cd00 + 86723c4 commit 5f1a5a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
2 changes: 2 additions & 0 deletions twine/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down

0 comments on commit 5f1a5a4

Please sign in to comment.