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

when "disabled", keyring uses a "null" keyring and should be unavaila… #5251

Merged
merged 6 commits into from
Apr 12, 2022

Conversation

lakinwecker
Copy link
Contributor

@lakinwecker lakinwecker commented Feb 28, 2022

…ble.

Pull Request Check List

Resolves: #5250

  • Added tests for changed code.
  • Updated documentation for changed code.

I didn't see any tests or docs for this part of the code, happy to update them as required.

@abn
Copy link
Member

abn commented Mar 5, 2022

@lakinwecker can you add some regression test coverage for this?

@lakinwecker
Copy link
Contributor Author

@abn I looked for tests related to this stuff and failed to find any. Are there any other unit tests that do things similarily that I can follow to make tests? If so, I can try and add them, yes.

@radoering
Copy link
Member

@lakinwecker Tests are in test_password_manager.py. Probably, you should add two tests similar to

def test_keyring_with_chainer_backend_and_not_compatible_only_should_be_unavailable(
with_chained_keyring: None,
):
key_ring = KeyRing("poetry")
assert not key_ring.is_available()

one with a simple null and one with a chained null. (And maybe you should rename the fixture with_chained_keyring to with_chained_fail_keyring so you can add with_chained_null_keyring). The fixtures are here:

poetry/tests/conftest.py

Lines 109 to 127 in 15f6ec1

@pytest.fixture()
def with_fail_keyring() -> None:
import keyring
from keyring.backends.fail import Keyring
keyring.set_keyring(Keyring())
@pytest.fixture()
def with_chained_keyring(mocker: MockerFixture) -> None:
from keyring.backends.fail import Keyring
mocker.patch("keyring.backend.get_all_keyring", [Keyring()])
import keyring
from keyring.backends.chainer import ChainerBackend
keyring.set_keyring(ChainerBackend())

@lakinwecker
Copy link
Contributor Author

test_keyring_with_chainer_backend_and_not_compatible_only_should_be_unavailable doesn't fail when you mess with the "fail" code that I modified. So I'm not convinced this test properly exercises it.

@lakinwecker
Copy link
Contributor Author

Alright, the mocks were wrong for those chainer tests. I fixed them and now the tests fail if I change the name of the 'bad' keyrings in the password_manager.py checks. So, I think this adds to tests to properly exercise it.

Is there documentation I should also update?

@lakinwecker
Copy link
Contributor Author

I fixed the formatting issues, I'm happy to squash the commits if you prefer. Otherwise let me know if there is anything else you need for this to be reviewed.

@radoering radoering merged commit f462b7f into python-poetry:master Apr 12, 2022
@kasteph kasteph mentioned this pull request May 30, 2022
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When keyring is disabled, poetry tries to use it anyways.
3 participants