def test_keyring_get_password(monkeypatch, url, expect): keyring = KeyringModuleV1() monkeypatch.setattr('pip._internal.network.auth.keyring', keyring) auth = MultiDomainBasicAuth(index_urls=["http://example.com/path2"]) actual = auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True) assert actual == expect
def test_keyring_get_credential(monkeypatch, url, expect): monkeypatch.setattr(pip._internal.network.auth, 'keyring', KeyringModuleV2()) auth = MultiDomainBasicAuth(index_urls=["http://example.com/path2"]) assert auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True) == expect
def test_broken_keyring_disables_keyring(monkeypatch): keyring_broken = KeyringModuleBroken() monkeypatch.setattr(pip._internal.network.auth, 'keyring', keyring_broken) auth = MultiDomainBasicAuth(index_urls=["http://example.com/"]) assert keyring_broken._call_count == 0 for i in range(5): url = "http://example.com/path" + str(i) assert auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True) == (None, None) assert keyring_broken._call_count == 1
def test_keyring_get_password( monkeypatch: pytest.MonkeyPatch, url: str, expect: Tuple[Optional[str], Optional[str]], ) -> None: keyring = KeyringModuleV1() monkeypatch.setattr("pip._internal.network.auth.keyring", keyring) auth = MultiDomainBasicAuth(index_urls=["http://example.com/path2"]) actual = auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True) assert actual == expect