コード例 #1
0
ファイル: test_key.py プロジェクト: zaczhuym/hvac
    def test_start_generate_root_then_cancel(self):
        test_otp = utils.get_generate_root_otp()

        self.assertFalse(self.client.sys.read_root_generation_progress()['started'])
        self.client.sys.start_root_token_generation(
            otp=test_otp,
        )
        self.assertTrue(self.client.sys.read_root_generation_progress()['started'])

        self.client.sys.cancel_root_generation()
        self.assertFalse(self.client.sys.read_root_generation_progress()['started'])
コード例 #2
0
ファイル: test_system_backend.py プロジェクト: clodonil/teste
    def test_start_generate_root_then_cancel(self):
        test_otp = utils.get_generate_root_otp()

        self.assertFalse(self.client.generate_root_status['started'])
        self.client.start_generate_root(
            key=test_otp,
            otp=True,
        )
        self.assertTrue(self.client.generate_root_status['started'])

        self.client.cancel_generate_root()
        self.assertFalse(self.client.generate_root_status['started'])
コード例 #3
0
    def test_start_generate_root_then_cancel(self):
        test_otp = utils.get_generate_root_otp()

        self.assertFalse(self.client.generate_root_status['started'])
        self.client.start_generate_root(
            key=test_otp,
            otp=True,
        )
        self.assertTrue(self.client.generate_root_status['started'])

        self.client.cancel_generate_root()
        self.assertFalse(self.client.generate_root_status['started'])
コード例 #4
0
ファイル: test_key.py プロジェクト: tp6783/hvac
    def test_start_generate_root_with_completion(self):
        test_otp = utils.get_generate_root_otp()

        self.assertFalse(
            self.client.sys.read_root_generation_progress()['started'])
        start_generate_root_response = self.client.sys.start_root_token_generation(
            otp=test_otp, )
        logging.debug('generate_root_response: %s' %
                      start_generate_root_response)
        self.assertTrue(
            self.client.sys.read_root_generation_progress()['started'])

        nonce = start_generate_root_response['nonce']

        last_generate_root_response = {}
        for key in self.manager.keys[0:3]:
            last_generate_root_response = self.client.sys.generate_root(
                key=key,
                nonce=nonce,
            )
        logging.debug('last_generate_root_response: %s' %
                      last_generate_root_response)
        self.assertFalse(
            self.client.sys.read_root_generation_progress()['started'])

        new_root_token = utils.decode_generated_root_token(
            encoded_token=last_generate_root_response['encoded_root_token'],
            otp=test_otp,
        )
        logging.debug('new_root_token: %s' % new_root_token)
        token_lookup_resp = self.client.lookup_token(token=new_root_token)
        logging.debug('token_lookup_resp: %s' % token_lookup_resp)

        # Assert our new root token is properly formed and authenticated
        self.client.token = new_root_token
        if self.client.is_authenticated():
            self.manager.root_token = new_root_token
        else:
            # If our new token was unable to authenticate, set the test client's token back to the original value
            self.client.token = self.manager.root_token
            self.fail(
                'Unable to authenticate with the newly generated root token.')
コード例 #5
0
ファイル: test_system_backend.py プロジェクト: clodonil/teste
    def test_start_generate_root_with_completion(self):
        test_otp = utils.get_generate_root_otp()

        self.assertFalse(self.client.generate_root_status['started'])
        start_generate_root_response = self.client.start_generate_root(
            key=test_otp,
            otp=True,
        )
        logging.debug('generate_root_response: %s' % start_generate_root_response)
        self.assertTrue(self.client.generate_root_status['started'])

        nonce = start_generate_root_response['nonce']

        last_generate_root_response = {}
        for key in self.manager.keys[0:3]:
            last_generate_root_response = self.client.generate_root(
                key=key,
                nonce=nonce,
            )
        logging.debug('last_generate_root_response: %s' % last_generate_root_response)
        self.assertFalse(self.client.generate_root_status['started'])

        new_root_token = utils.decode_generated_root_token(
            encoded_token=last_generate_root_response['encoded_root_token'],
            otp=test_otp,
        )
        logging.debug('new_root_token: %s' % new_root_token)
        token_lookup_resp = self.client.lookup_token(token=new_root_token)
        logging.debug('token_lookup_resp: %s' % token_lookup_resp)

        # Assert our new root token is properly formed and authenticated
        self.client.token = new_root_token
        if self.client.is_authenticated():
            self.manager.root_token = new_root_token
        else:
            # If our new token was unable to authenticate, set the test client's token back to the original value
            self.client.token = self.manager.root_token
            self.fail('Unable to authenticate with the newly generated root token.')