def test_token_no_role(self): generator = TokenGenerator(self._session) token = generator.get_token(CLUSTER_NAME, None, REGION) prefix = token[:len(TOKEN_PREFIX)] self.assertEqual(prefix, TOKEN_PREFIX) token_no_prefix = token[len(TOKEN_PREFIX):] decrypted_token = base64.urlsafe_b64decode( token_no_prefix.encode()).decode() self.assert_url_correct(decrypted_token, False)
def test_token_sess(self): generator = TokenGenerator(REGION, self._assuming_handler) token = generator.get_token(CLUSTER_NAME, "RoleArn") prefix = token[:len(TOKEN_PREFIX)] self.assertEqual(prefix, TOKEN_PREFIX) token_no_prefix = token[len(TOKEN_PREFIX):] decrypted_token = base64.urlsafe_b64decode( token_no_prefix.encode()).decode() self.assert_url_correct(decrypted_token, True)
def test_token_sess(self): generator = TokenGenerator(REGION, self._assuming_handler) token = generator.get_token(CLUSTER_NAME, "RoleArn") prefix = token[:len(TOKEN_PREFIX)] self.assertEqual(prefix, TOKEN_PREFIX) token_no_prefix = token[len(TOKEN_PREFIX):] decrypted_token = base64.urlsafe_b64decode( token_no_prefix.encode() ).decode() self.assert_url_correct(decrypted_token, True)
def test_token_sess(self, mock_create_client): mock_create_client.return_value = self.mock_sts_client generator = TokenGenerator(self._session) token = generator.get_token(CLUSTER_NAME, "arn:aws:iam::012345678910:role/RoleArn", REGION) prefix = token[:len(TOKEN_PREFIX)] self.assertEqual(prefix, TOKEN_PREFIX) token_no_prefix = token[len(TOKEN_PREFIX):] decrypted_token = base64.urlsafe_b64decode( token_no_prefix.encode()).decode() self.assert_url_correct(decrypted_token, True)
def test_token_no_padding(self, mock_presigned_url): generator = TokenGenerator(self._sts_client) tok = generator.get_token(self._cluster_name) self.assertTrue('=' not in tok)
def test_token_no_padding(self, mock_presigned_url): generator = TokenGenerator(self._session) tok = generator.get_token(CLUSTER_NAME, None, REGION) self.assertTrue('=' not in tok)
def test_token_no_padding(self, mock_presigned_url): generator = TokenGenerator(REGION, self._session_handler) tok = generator.get_token(CLUSTER_NAME, None) self.assertTrue('=' not in tok)