def test_update_api_key_can_raise_operation_not_complete_exception(
         self, mock_store_wrapper):
     with self.assertRaises(OperationNotCompletedException):
         credential_provider = KeystoreCredentialsProvider()
         credential_provider.update_api_key_entry('someusertoupdate',
                                                  MockCredentials,
                                                  'newapikey')
 def test_save_calls_methods_properly(self, mock_store_wrapper):
     credential_provider = KeystoreCredentialsProvider()
     credential_provider.save(MockCredentials)
     calls = [
         call(TEST_HOSTNAME, MACHINE, TEST_HOSTNAME),
         call(TEST_HOSTNAME, USERNAME, 'somelogin'),
         call(TEST_HOSTNAME, PASSWORD, 'somepass')
     ]
     mock_store_wrapper.assert_has_calls(calls)
 def test_remove_credentials_calls_delete_password_for_each_credential(
         self, mock_keyring_name, mock_delete_password):
     credential_provider = KeystoreCredentialsProvider()
     credential_provider.remove_credentials(MockConjurrcData.conjur_url)
     calls = [
         call(TEST_HOSTNAME, MACHINE),
         call(TEST_HOSTNAME, USERNAME),
         call(TEST_HOSTNAME, PASSWORD)
     ]
     mock_delete_password.assert_has_calls(calls)
 def test_update_api_key_calls_methods_properly(self, mock_store_wrapper):
     # mock_store_wrapper.set_password.return_value=None
     credential_provider = KeystoreCredentialsProvider()
     credential_provider.update_api_key_entry('someusertoupdate',
                                              MockCredentials, 'newapikey')
     calls = [
         call(TEST_HOSTNAME, MACHINE, TEST_HOSTNAME),
         call(TEST_HOSTNAME, USERNAME, 'someusertoupdate'),
         call(TEST_HOSTNAME, PASSWORD, 'newapikey')
     ]
     mock_store_wrapper.assert_has_calls(calls)
 def test_load_credentials_calls_get_password(self, mock_credentials_data,
                                              mock_store_wrapper,
                                              mock_cred_provider):
     credential_provider = KeystoreCredentialsProvider()
     credentials_data = credential_provider.load(TEST_HOSTNAME)
     calls = [
         call(TEST_HOSTNAME, MACHINE),
         call(TEST_HOSTNAME, USERNAME),
         call(TEST_HOSTNAME, PASSWORD)
     ]
     mock_store_wrapper.assert_has_calls(calls)
     self.assertEquals(MockCredentials.machine, credentials_data.machine)
     self.assertEquals(MockCredentials.username, credentials_data.username)
     self.assertEquals(MockCredentials.password, credentials_data.password)
 def test_provider_can_return_keystore_provider_keyring(self):
     cred_store = utils.create_cred_store()
     self.assertEquals(type(cred_store), type(KeystoreCredentialsProvider()))
 def test_is_exists_raises_exception_when_exception_is_thrown_by_get_password(
         self, mock_store_wrapper):
     credential_provider = KeystoreCredentialsProvider()
     with self.assertRaises(Exception):
         credential_provider.is_exists(TEST_HOSTNAME)
 def test_is_exists_return_true_when_attr_exists(self, mock_store_wrapper):
     credential_provider = KeystoreCredentialsProvider()
     self.assertEquals(True, credential_provider.is_exists(TEST_HOSTNAME))
 def test_is_exists_return_false_if_attr_not_exists(self,
                                                    mock_store_wrapper):
     credential_provider = KeystoreCredentialsProvider()
     self.assertEquals(False, credential_provider.is_exists(TEST_HOSTNAME))
 def test_load_credentials_do_not_exist_raises_credential_retrieval_exception(
         self, mock_cred_provider):
     with self.assertRaises(CredentialRetrievalException):
         credential_provider = KeystoreCredentialsProvider()
         credential_provider.load(TEST_HOSTNAME)
 def test_save_can_raise_operation_not_complete_exception(
         self, mock_store_wrapper):
     with self.assertRaises(OperationNotCompletedException):
         credential_provider = KeystoreCredentialsProvider()
         credential_provider.save(MockCredentials)
 def test_remove_credentials_raises_keyring_error_when_delete_password_raises_keyring_error(
         self, mock_keystore_wrapper, another_mock_keystore_wrapper):
     credential_provider = KeystoreCredentialsProvider()
     with self.assertRaises(Exception):
         credential_provider.remove_credentials(MockConjurrcData.conjur_url)