Skip to content

Commit

Permalink
Test a keyring raising KeyringError on access.
Browse files Browse the repository at this point in the history
* tests/utils/test_authenticator.py
* tests/conftest.py
  • Loading branch information
real-yfprojects authored and radoering committed Oct 3, 2023
1 parent 6292400 commit 5e00b18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import keyring
import pytest

from keyring import backends
from keyring.backend import KeyringBackend
from keyring.errors import KeyringError
from keyring.errors import KeyringLocked

from poetry.config.config import Config as BaseConfig
Expand Down Expand Up @@ -133,10 +135,6 @@ def delete_password(self, service: str, username: str | None) -> None:
raise KeyringLocked()


from keyring import backends
from keyring.errors import KeyringError


class ErroneousBackend(backends.fail.Keyring):
@classmethod
def priority(cls) -> int:
Expand Down
13 changes: 13 additions & 0 deletions tests/utils/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ def test_authenticator_ignores_locked_keyring(
assert request.headers["Authorization"] == "Basic Zm9vMDAxOg=="


def test_authenticator_ignores_failing_keyring(
mock_config: Config,
mock_remote: None,
http: type[httpretty.httpretty],
with_erroneous_keyring: None,
) -> None:
authenticator = Authenticator(mock_config, NullIO())
authenticator.request("get", "https://[email protected]/files/foo-0.1.0.tar.gz")
request = http.last_request()

assert request.headers["Authorization"] == "Basic Zm9vMDAxOg=="


def test_authenticator_uses_password_only_credentials(
mock_config: Config, mock_remote: None, http: type[httpretty.httpretty]
) -> None:
Expand Down

0 comments on commit 5e00b18

Please sign in to comment.