1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
import logging
from unittest import TestCase
from parameterized import param, parameterized
from tests import utils
from tests.utils.hvac_integration_test_case import HvacIntegrationTestCase
class TestGcp(HvacIntegrationTestCase, TestCase):
TEST_MOUNT_POINT = "test-gcp"
TEST_ROLESET_NAME = "hvac-roleset"
TEST_PROJECT_ID = "test-hvac"
def setUp(self):
super().setUp()
self.client.sys.enable_secrets_engine(
backend_type="gcp",
path=self.TEST_MOUNT_POINT,
)
def tearDown(self):
self.client.sys.disable_secrets_engine(path=self.TEST_MOUNT_POINT)
super().tearDown()
@parameterized.expand(
[
param(
"success",
),
]
)
def test_write_config(
self, label, max_ttl=3600, raises=False, exception_message=""
):
credentials = utils.load_config_file("example.jwt.json")
if raises:
with self.assertRaises(raises) as cm:
self.client.secrets.gcp.configure(
credentials=credentials,
max_ttl=max_ttl,
mount_point=self.TEST_MOUNT_POINT,
)
self.assertIn(
member=exception_message,
container=str(cm.exception),
)
else:
configure_response = self.client.secrets.gcp.configure(
credentials=credentials,
max_ttl=max_ttl,
mount_point=self.TEST_MOUNT_POINT,
)
logging.debug("configure_response: %s" % configure_response)
self.assertEqual(
first=bool(configure_response),
second=True,
)
read_configuration_response = self.client.secrets.gcp.read_config(
mount_point=self.TEST_MOUNT_POINT,
)
logging.debug(
"read_configuration_response: %s" % read_configuration_response
)
self.assertEqual(
first=read_configuration_response["data"]["max_ttl"],
second=max_ttl,
)
|