Ejemplo n.º 1
0
def find_and_delete_remotes_leaf(item, challenge):

    # see if the value is a file
    if file_in_registry(str(item)):

        clear_entry_w_challenge(str(item), challenge)
        
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
def clear_file_from_registry(file_path, challenge):

    # if file is in fact registered
    if get_file_from_registry(file_path):

        # clear file entry
        reg_key = get_file_reg_key(file_path)

        clear_entry_w_challenge(reg_key, challenge)

    else:
        raise FileError("file with key %s doesn't exist" % file_path)
Ejemplo n.º 4
0
def clear_service(service_name, challenge):

    # if service is in fact registered
    service = get_service_by_name(service_name)

    if service:

        # clear service entry registry
        reg_key = service_name + YAC_SERVICE_SUFFIX
        clear_entry_w_challenge(reg_key, challenge)

        # clear any files referenced
        find_and_delete_remotes(service.serialize(), challenge)

    else:
        raise ServiceError("service with key %s doesn't exist"%service_name)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)