def test_clear_fail(self): # create a random value to put into registry original_value = "test-value-" + str(random.randint(1, 1000)) test_key = "test-key-" + str(random.randint(1, 1000)) challenge_phrase = 'test-challenge' + str(random.randint(1, 1000)) set_remote_string_w_challenge(test_key, original_value, challenge_phrase) new_value = "test-value-" + str(random.randint(1, 1000)) try: # attempt clear with a different phrase clear_entry_w_challenge(test_key, challenge_phrase + 'deviation') except RegError as e: # we expect to get an error print(e.msg) # pull value back out returned_value = get_remote_value(test_key) # test that the original value remains self.assertTrue(returned_value == original_value)
def register_service(service_name, servicefile_w_path, challenge): err = "" if os.path.exists(servicefile_w_path): service_contents_str = get_file_contents(servicefile_w_path) if service_contents_str: reg_key = service_name + YAC_SERVICE_SUFFIX # get the base path of the service file servicefile_path = os.path.dirname(servicefile_w_path) updated_service_contents_str = convert_local_files(service_name, service_contents_str, servicefile_path, challenge) # set the service in the registry set_remote_string_w_challenge(reg_key, updated_service_contents_str, challenge) else: err = "service path %s doesn't exist"%servicefile_path return err
def register_file(file_key, file_path, challenge): if os.path.exists(file_path): with open(file_path) as file_path_fp: file_contents = file_path_fp.read() reg_key = get_file_reg_key(file_key) # set the file in the registry set_remote_string_w_challenge(reg_key, file_contents, challenge) else: raise FileError("file at %s doesn't exist" % file_path)
def test_register(self): # create a random value to put into registry test_value = "test-value-" + str(random.randint(1, 1000)) test_key = "test-key-" + str(random.randint(1, 1000)) # create a key/value pair in registry with a challenge phrase challenge_phrase = 'test' set_remote_string_w_challenge(test_key, test_value, challenge_phrase) # pull value back out returned_value = get_remote_value(test_key) # clean up test key clear_entry_w_challenge(test_key, challenge_phrase) # test that the create was successful self.assertTrue(test_value == returned_value)
def test_clear(self): # create a random value to put into registry test_value = "test-value-" + str(random.randint(1, 1000)) test_key = "test-key-" + str(random.randint(1, 1000)) challenge_phrase = 'test' set_remote_string_w_challenge(test_key, test_value, challenge_phrase) test_value = "test-value-" + str(random.randint(1, 1000)) # clear the value in registry clear_entry_w_challenge(test_key, challenge_phrase) # pull value back out returned_value = get_remote_value(test_key) # test that the clear was successful self.assertTrue(not returned_value)