Example #1
0
 def update_api_key_entry(self, user_to_update: str,
                          credential_data: CredentialsData,
                          new_api_key: str):
     """
     Method for updating user credentials in the system's keyring
     """
     try:
         KeystoreWrapper.set_password(credential_data.machine, MACHINE,
                                      credential_data.machine)
         KeystoreWrapper.set_password(credential_data.machine, USERNAME,
                                      user_to_update)
         KeystoreWrapper.set_password(credential_data.machine, PASSWORD,
                                      new_api_key)
     except Exception as incomplete_operation:
         raise OperationNotCompletedException(
             incomplete_operation) from incomplete_operation
Example #2
0
 def save(self, credential_data: CredentialsData):
     """
     Method for saving user credentials in the system's keyring
     """
     logging.debug(
         "Attempting to save credentials to the system's credential store "
         f"'{self.keyring_name}'...")
     credential_id = credential_data.machine
     try:
         KeystoreWrapper.set_password(credential_id, MACHINE,
                                      credential_data.machine)
         KeystoreWrapper.set_password(credential_id, USERNAME,
                                      credential_data.username)
         KeystoreWrapper.set_password(credential_id, PASSWORD,
                                      credential_data.password)
         logging.debug(f"Credentials saved to the '{self.keyring_name}'"
                       f" credential store")
     except Exception as incomplete_operation:
         raise OperationNotCompletedException(
             incomplete_operation) from incomplete_operation
 def test_get_set_password_use_proper_log_level(self, mock):
     logging.getLogger('keyring').setLevel(logging.DEBUG)
     KeystoreWrapper.set_password("", "", "")
     self.assertEquals(logging.getLogger('keyring').level, logging.INFO)