uv/scripts/packages/keyring_test_plugin/keyrings/test_keyring.py
konsti 0b0d0f44f8
Publish: Warn when keyring has no password (#8827)
When trying to upload without a password but with the keyring, check
that the keyring has a password for the upload URL and username and warn
if it doesn't.

Fixes #8781
2024-11-27 20:54:49 +01:00

23 lines
648 B
Python

import json
import os
import sys
from keyring import backend
class KeyringTest(backend.KeyringBackend):
priority = 9
def get_password(self, service, username):
print(f"Request for {username}@{service}", file=sys.stderr)
credentials = json.loads(os.environ.get("KEYRING_TEST_CREDENTIALS", "{}"))
return credentials.get(service, {}).get(username)
def set_password(self, service, username, password):
raise NotImplementedError()
def delete_password(self, service, username):
raise NotImplementedError()
def get_credential(self, service, username):
raise NotImplementedError()