Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbose logging for querying keyring credentials #849

Merged
merged 1 commit into from Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/test_auth.py
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
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