Ejemplo n.º 1
0
    def sync_multi_level_success(self):
        missing_key = '/app/dev/thing/ci-test2/app/ci-test/v1/config12'
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(missing_key)

        put = PutAction(extra_args=self.extra_args)
        put.add('/app/dev/thing/ci-test2/config9', DELETE_ME_VALUE, desc='desc', add_more=True)
        put.add('/app/dev/thing/ci-test2/config11', DELETE_ME_VALUE, desc='desc', add_more=True)
        put.add('/shared/jordan/testrepl', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
        put.add('/shared/jordan/testrepl2', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
        put.add('/shared/jordan/testrepl3', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
        put.add('/shared/jordan/testrepl4', DELETE_ME_VALUE, desc='desc', add_more=False, delete_first=False)

        print(f"Testing: {CLI_NAME} config {sync.name} --env {DEFAULT_ENV} "
              f"--config figcli/test/assets/success/multi-level-ns.json")
        child = TestUtils.spawn(f'{CLI_NAME} config {sync.name} --env {DEFAULT_ENV} '
                                f'--config figcli/test/assets/success/multi-level-ns.json --skip-upgrade'
                                f' {self.extra_args}', timeout=45)

        child.expect(f'.*Please input a value for.*{missing_key}.*')
        child.sendline(DELETE_ME_VALUE)
        child.expect('.*optional description:.*')
        child.sendline('desc')
        child.expect('.*value a secret.*')
        child.sendline('n')
        child.expect('.*Sync completed with no errors.*')
Ejemplo n.º 2
0
    def run(self):
        self.step(f"Preparing get by adding: {param_1}")
        put = PutAction(extra_args=self.extra_args)
        put.add(param_1, param_1_val, param_1_desc, add_more=False)

        self.step(f"Testing GET for {param_1}")
        self.get(param_1, param_1_val, get_more=False)

        self.step(f"Cleaning up: {param_1}")
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(param_1, check_delete=True, delete_another=False)
Ejemplo n.º 3
0
 def prep_sync(self):
     put = PutAction(extra_args=self.extra_args)
     put.add('/app/ci-test/v1/config9', DELETE_ME_VALUE, desc='desc', add_more=True)
     put.add('/app/ci-test/v1/config11', DELETE_ME_VALUE, desc='desc', add_more=True)
     put.add('/shared/jordan/testrepl', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
     put.add('/shared/jordan/testrepl2', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
     put.add('/shared/jordan/testrepl3', DELETE_ME_VALUE, desc='desc', add_more=True, delete_first=False)
     put.add('/shared/jordan/testrepl4', DELETE_ME_VALUE, desc='desc', add_more=False, delete_first=False)
     print("EXECUTING DELETE!!!!")
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete(self.missing_key)
Ejemplo n.º 4
0
 def validate_error(self):
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete(self.missing_key)
     print(
         f"Testing: {CLI_NAME} config {validate.name} --env {DEFAULT_ENV} "
         f"--config figcli/test/assets/error/figgy.json {self.extra_args}")
     child = TestUtils.spawn(
         f'{CLI_NAME} config {validate.name} --env {DEFAULT_ENV} '
         f'--config figcli/test/assets/error/figgy.json --skip-upgrade {self.extra_args}'
     )
     child.expect('.*missing at least one.*')
     print("VALIDATE ERROR VERIFIED")
Ejemplo n.º 5
0
    def sync_with_orphans(self):
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(self.missing_key)
        print("Successful sync + prune passed!")

        print(f"Testing: {CLI_NAME} config {sync.name} --env {DEFAULT_ENV} "
              f"--config figcli/test/assets/error/figgy.json")
        child = TestUtils.spawn(f'{CLI_NAME} config {sync.name} --env {DEFAULT_ENV} '
                                f'--config figcli/test/assets/error/figgy.json --skip-upgrade {self.extra_args}',
                                timeout=45)
        child.expect('.*Unused Parameter:.*/app/ci-test/v1/config11.*')
        child.expect('.*Sync failed.*')
        print("Sync with stray configs passed!")
Ejemplo n.º 6
0
 def prune(self):
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete('/app/test-promote/v1/config9',
                   delete_another=True,
                   check_delete=False)
     delete.delete('/app/test-promote/v1/config11',
                   delete_another=True,
                   check_delete=False)
     delete.delete('/app/test-promote/v1/config12',
                   delete_another=True,
                   check_delete=False)
     delete.delete('/app/test-promote/v1/config13',
                   delete_another=False,
                   check_delete=False)
Ejemplo n.º 7
0
    def add(self, key, value, desc, delete_first=True, add_more=False):
        if delete_first:
            delete = DeleteAction(extra_args=self.extra_args)
            delete.delete(key)

        self.expect('.*Please input a PS Name.*')
        self.sendline(key)
        self.expect('.*Please input a value.*')
        self.sendline(value)
        self.expect('.*Please input an optional.*')
        self.sendline(desc)
        self.expect('.*secret?.*')
        self.sendline('n')
        self.expect('.*another.*')
        if add_more:
            self.sendline('y')
        else:
            self.sendline('n')
Ejemplo n.º 8
0
    def add_encrypt_app(self, key, value, desc, add_more=False):
        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(key)
        self.expect('.*Please input a PS Name.*')
        self.sendline(key)
        self.expect('.*Please input a value.*')
        self.sendline(value)
        self.expect('.*Please input an optional.*')
        self.sendline(desc)
        self.expect('.*secret?.*')
        self.sendline('y')
        index = self.expect(['.*key.*', '.*another.*'])
        if index == 0:
            self.sendline('app')
            self.expect('.*another.*')

        if add_more:
            self.sendline('y')
        else:
            self.sendline('n')
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
    def run(self):
        put = PutAction(extra_args=self.extra_args)

        # Use a number > 10 so paging is tested
        minimum, maximum = 1, 12
        put.add(param_1,
                param_1_val,
                param_1_desc,
                add_more=True,
                delete_first=False)

        for i in range(minimum, maximum):
            more = i < maximum - 1
            put.add_another(f'{param_1}-{i}',
                            param_1_val,
                            f'{param_1_desc}-{i}',
                            add_more=more)

        child = TestUtils.spawn(
            f'{CLI_NAME} config {dump.name} --env {DEFAULT_ENV} {self.extra_args}'
            f' --skip-upgrade')

        self.step(
            f"Testing `{CLI_NAME} config {dump.name} --env {DEFAULT_ENV}`")
        child.expect('.*to dump from.*')
        child.sendline(dump_prefix)
        child.expect(f'.*{param_1}-{minimum}.*{param_1}-{maximum-1}.*')
        print(f"Dump was successful.")

        delete = DeleteAction(extra_args=self.extra_args)
        delete.delete(param_1, delete_another=True, check_delete=False)
        for i in range(minimum, maximum):
            delete.delete(f'{param_1}-{i}', delete_another=i < maximum - 1)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
 def run(self):
     self.step(f"Testing PUT for {param_1}")
     self.add(param_1, param_1_val, param_1_desc)
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete(param_1, check_delete=True)
Ejemplo n.º 13
0
 def _cleanup(self, min: int, max: int):
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete(param_1, delete_another=True)
     for i in range(min, max):
         delete.delete(f'{param_1}-{i}', delete_another=i < max - 1)
Ejemplo n.º 14
0
 def _cleanup(self):
     delete = DeleteAction(extra_args=self.extra_args)
     delete.delete(KEY_PATH, delete_another=False)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
    def prep(self):
        with open('figcli/test/assets/data_repl_conf.json', 'r') as file:
            content = json.loads(file.read()).get('replicate_figs')

        delete = DeleteAction()
        destinations = list(content.values())
        for i in range(0, len(destinations)):
            print(f"DELETING: {destinations[i]}")

            if i < len(destinations):
                delete.delete(destinations[i], delete_another=True)
            else:
                delete.delete(destinations[i], delete_another=False)

        delete = DeleteAction()
        sources = list(content.keys())
        print(f"SOURCES: {sources}")
        for i in range(0, len(sources)):
            print(f"DELETING: {destinations[i]}")
            if i < len(sources):
                delete.delete(sources[i], delete_another=True)
            else:
                delete.delete(sources[i], delete_another=False)