From 73781a5337f35b4e64339e71ef74e4546ad6b0df Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 11 Jan 2024 22:42:24 -0500 Subject: [PATCH] config: add fixtures for iam name/path prefixes Signed-off-by: Casey Bodley (cherry picked from commit 83af25722c2a1591d47d1e97bec3df4f8a19f6a2) --- s3tests.conf.SAMPLE | 8 ++++++++ s3tests_boto3/functional/__init__.py | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/s3tests.conf.SAMPLE b/s3tests.conf.SAMPLE index 9593fc1..60e9928 100644 --- a/s3tests.conf.SAMPLE +++ b/s3tests.conf.SAMPLE @@ -19,6 +19,14 @@ ssl_verify = False ## the prefix to 30 characters long, and avoid collisions bucket prefix = yournamehere-{random}- +# all the iam account resources (users, roles, etc) created +# will start with this name prefix +iam name prefix = s3-tests- + +# all the iam account resources (users, roles, etc) created +# will start with this path prefix +iam path prefix = /s3-tests/ + [s3 main] # main display_name set in vstart.sh display_name = M. Tester diff --git a/s3tests_boto3/functional/__init__.py b/s3tests_boto3/functional/__init__.py index a65b54c..05abb62 100644 --- a/s3tests_boto3/functional/__init__.py +++ b/s3tests_boto3/functional/__init__.py @@ -261,11 +261,12 @@ def setup(): config.tenant_email = cfg.get('s3 tenant',"email") # vars from the fixtures section - try: - template = cfg.get('fixtures', "bucket prefix") - except (configparser.NoOptionError): - template = 'test-{random}-' + template = cfg.get('fixtures', "bucket prefix", fallback='test-{random}-') prefix = choose_bucket_prefix(template=template) + template = cfg.get('fixtures', "iam name prefix", fallback="s3-tests-") + config.iam_name_prefix = choose_bucket_prefix(template=template) + template = cfg.get('fixtures', "iam path prefix", fallback="/s3-tests/") + config.iam_path_prefix = choose_bucket_prefix(template=template) alt_client = get_alt_client() tenant_client = get_tenant_client() @@ -699,6 +700,15 @@ def get_token(): def get_realm_name(): return config.webidentity_realm +def get_iam_name_prefix(): + return config.iam_name_prefix + +def make_iam_name(name): + return config.iam_name_prefix + name + +def get_iam_path_prefix(): + return config.iam_path_prefix + def get_iam_access_key(): return config.iam_access_key