def create_credential_store(cls) -> CredentialsProviderInterface: """ Factory method for determining which store to use """ keyring_name = KeystoreWrapper.get_keyring_name() if keyring_name in SUPPORTED_BACKENDS: # If the keyring is unlocked then we will use it if KeystoreWrapper.is_keyring_accessible(): return KeystoreCredentialsProvider() return FileCredentialsProvider()
def test_is_keyring_accessible_returns_false_on_keyring_error(self, mock_keyring): self.assertEquals(False, KeystoreWrapper.is_keyring_accessible())
def test_is_keyring_accessible_return_true_when_get_password(self, mock_keyring): keyring_accessible = KeystoreWrapper.is_keyring_accessible() mock_keyring.assert_called_once_with('test-system', 'test-accessibility') self.assertEquals(True, keyring_accessible)