Exemplo n.º 1
0
    def delete(self, name, check_delete=False, delete_another=False):
        self.expect('.*PS Name to Delete.*')
        self.sendline(name)
        print(f"Delete sent for {name}")
        result = self.expect([
            '.*deleted successfully.*Delete another.*', '.*SOURCE.*',
            '.*ALSO delete this replication config.*'
        ])

        if result == 0:
            if check_delete:
                get = GetAction(extra_args=self.extra_args)
                get.get(name, DELETE_ME_VALUE, expect_missing=True)

            if delete_another:
                self.sendline('y')
            else:
                self.sendline('n')

            print("Successful delete validated.")
        elif result == 2:
            self.sendline('y')
            self.expect('.*deleted successfully.*')

            if delete_another:
                self.sendline('y')
            else:
                self.sendline('n')
Exemplo n.º 2
0
    def run(self):
        put = PutAction(extra_args=self.extra_args)
        guuid = uuid.uuid4().hex
        key = f"{param_test_prefix}{guuid}"
        put.add(key, DELETE_ME_VALUE, 'desc', add_more=False)
        get = GetAction(extra_args=self.extra_args)
        get.get(key, DELETE_ME_VALUE, get_more=False)
        self.step(
            f"Sleeping {AUDIT_PROPAGATION_TIME} to allow for lambda -> dynamo audit log insert."
        )
        time.sleep(AUDIT_PROPAGATION_TIME)
        self.step(
            f"Looking up audit log for: {key}. If this fails, the lambda could be broken. "
        )
        self.audit(key)
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(key)

        new_uuid = uuid.uuid4().hex
        self.step("Testing searching for non-existent audit log.")
        self.audit(f'/doesnt/exist/{new_uuid}', expect_results=False)
Exemplo n.º 3
0
    def edit(self):
        # Get Value
        child = TestUtils.spawn(
            f'{CLI_NAME} config {edit.name} --env {DEFAULT_ENV} '
            f'--skip-upgrade {self.extra_args}')

        child.expect('.*Please input a PS Name.*')
        child.sendline(param_1)
        time.sleep(12)  # Give edit time to start
        child.send(DevEdit._VALUE)
        child.sendcontrol('n')  # <-- sends TAB
        child.send(DevEdit._DESC)
        child.sendcontrol('n')  # <-- sends TAB
        child.sendcontrol('m')  # <-- Sends ENTER
        child.expect('.*secret.*')
        child.sendline('n')
        child.expect('.*saved successfully.*')
        print("Add success. Checking successful save")

        get = GetAction(extra_args=self.extra_args)
        get.get(param_1, DevEdit._VALUE, DevEdit._DESC)
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(param_1)
Exemplo n.º 4
0
    def run(self):
        self.step("Prepping workspace, deleting any existing values.")
        self.prep()

        child = TestUtils.spawn(
            f'{CLI_NAME} {config.name} {sync.name} '
            f'--env {DEFAULT_ENV} --config figcli/test/assets/data_repl_conf.json '
            f'--skip-upgrade --replication-only {self.extra_args}',
            timeout=30)
        time.sleep(2)
        with open('figcli/test/assets/data_repl_conf.json', 'r') as file:
            content = json.loads(file.read()).get('replicate_figs')

        self.step("Running replication-only sync and adding values.")
        sources = list(content.keys())
        for source in sources:
            child.expect(f".*input a value.*")
            child.sendline(DELETE_ME_VALUE)
            child.expect(".*description.*")
            child.sendline("desc")
            child.expect(".*secret.*")
            child.sendline('y')
            child.expect('.*encryption.*')
            child.sendline('data')
            child.expect('.*added successfully.*')

        self.step("Waiting for replication propagation")
        time.sleep(50)

        self.step("Verifying successful replication")
        destinations = list(content.values())
        for dest in destinations:
            GetAction().get(dest,
                            DELETE_ME_VALUE,
                            get_more=False,
                            no_decrypt=True)

        self.step("Cleaning leftover values")
        self.prep()
Exemplo n.º 5
0
    def _setup(self, min: int, max: int, value_override: str = None):
        # Do not want to do a delete -> Put b/c it will mess up the restore, so delete_first=False is required.
        put = PutAction(extra_args=self.extra_args)
        value = value_override if value_override else DELETE_ME_VALUE
        put.add(f'{param_test_prefix}{self._guuid}/test_param',
                value,
                param_1_desc,
                add_more=True,
                delete_first=False)

        for i in range(min, max):
            put.add_another(f'{param_test_prefix}{self._guuid}/test_param-{i}',
                            value,
                            f'{param_1_desc}-{i}',
                            add_more=i < max - 1)

        get = GetAction(extra_args=self.extra_args)
        get.get(f'{param_test_prefix}{self._guuid}/test_param',
                value,
                get_more=True)
        for i in range(min, max):
            get.get(f'{param_test_prefix}{self._guuid}/test_param-{i}',
                    value,
                    get_more=i < max - 1)
Exemplo n.º 6
0
 def _validate_delete(self, key, value):
     print(f"Validating successfully deletion of {key}")
     get = GetAction(extra_args=self.extra_args)
     get.get(key, value, get_more=False, expect_missing=True)
     print("Delete success validated.")
Exemplo n.º 7
0
    def run(self):
        minimum, maximum = 1, 3
        first_val = 'FIRST_VAL'
        second_val = 'SECOND_VAL'
        self.step("Adding new configs. To Restore")
        self._setup(minimum, maximum, value_override=first_val)
        print("Waiting for propagation...")
        time.sleep(RESTORE_PROPAGATION_TIME)
        print("Validating")
        self._audit(minimum, maximum)
        restore_breakpoint_1 = int(time.time() * 1000)
        print(
            f"First restore breakpoint: {restore_breakpoint_1} - would expect val of {first_val}"
        )

        time.sleep(15)
        self._setup(minimum, maximum, value_override=second_val)
        print("Waiting for propagation...")
        time.sleep(RESTORE_PROPAGATION_TIME)
        print("Validating")
        self._audit(minimum, maximum)
        restore_breakpoint_2 = int(time.time() * 1000)
        print(
            f"Second restore breakpoint: {restore_breakpoint_1} - would expect val of {second_val}"
        )

        time.sleep(25)

        restore_prefix = f'{param_test_prefix}{self._guuid}/'
        self.step(
            f"Attempting restore to time: {restore_breakpoint_1} with prefix: {restore_prefix}"
        )
        child = TestUtils.spawn(
            f'{CLI_NAME} config {restore.name} --env {DEFAULT_ENV} --skip-upgrade'
            f' --point-in-time {self.extra_args}')
        child.expect('.*Which.*recursively restore.*')
        child.sendline(restore_prefix)
        child.expect('.*Seconds.*restore.*')
        child.sendline(f'{restore_breakpoint_1}')
        child.expect('.*Are you sure.*')
        child.sendline('y')
        print("Checking restore output...\r\n\r\n")
        child.expect(f'.*Value.*{param_test_prefix}{self._guuid}/test_param.*')
        child.expect(
            f'.*restored successfully!.*'
        )  ## <-- this is needed or else the child proccess exits too early

        time.sleep(5)
        self.step("Validating values were rolled back... Part 1")

        get = GetAction(extra_args=self.extra_args)
        get.get(f'{param_test_prefix}{self._guuid}/test_param',
                first_val,
                get_more=True)
        for i in range(minimum, maximum):
            get.get(f'{param_test_prefix}{self._guuid}/test_param-{i}',
                    first_val,
                    get_more=i < maximum - 1)

        print("Values were rolled back successfully")
        time.sleep(30)
        print("Testing restore to second restore point")

        restore_prefix = f'{param_test_prefix}{self._guuid}/'
        self.step(
            f"Attempting restore to time: {restore_breakpoint_2} with prefix: {restore_prefix}"
        )
        child = TestUtils.spawn(
            f'{CLI_NAME} config {restore.name} --env {DEFAULT_ENV} --skip-upgrade'
            f' --point-in-time {self.extra_args}')
        child.expect('.*Which.*recursively restore.*')
        child.sendline(restore_prefix)
        child.expect('.*Seconds.*restore.*')
        child.sendline(f'{restore_breakpoint_2}')
        child.expect('.*Are you sure.*')
        child.sendline('y')
        print("Checking restore output...\r\n\r\n")
        child.expect(
            f'.*Restoring.*{param_test_prefix}{self._guuid}/test_param.*{second_val}.*'
        )
        child.expect(
            f'.*restored successfully!.*'
        )  ## <-- this is needed or else the child proccess exits too early

        time.sleep(5)
        self.step("Validating values were rolled back... Part 2")

        get = GetAction(extra_args=self.extra_args)
        get.get(f'{param_test_prefix}{self._guuid}/test_param',
                second_val,
                get_more=True)
        for i in range(minimum, maximum):
            get.get(f'{param_test_prefix}{self._guuid}/test_param-{i}',
                    second_val,
                    get_more=i < maximum - 1)

        print("Values were rolled forward successfully. Cleaning up...")

        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(f'{param_test_prefix}{self._guuid}/test_param',
                      delete_another=True)
        for i in range(minimum, maximum):
            delete.delete(f'{param_test_prefix}{self._guuid}/test_param-{i}',
                          delete_another=i < maximum - 1)