@contextlib.contextmanager
-def create_users(ctx, config):
+def create_users(ctx, config, s3tests_conf):
"""
Create a main and an alternate s3 user.
"""
- assert isinstance(config, dict)
log.info('Creating rgw users...')
testdir = teuthology.get_testdir(ctx)
users = {'s3 main': 'foo', 's3 alt': 'bar', 's3 tenant': 'testx$tenanteduser', 'iam': 'foobar'}
- for client in config['clients']:
- s3tests_conf = config['s3tests_conf'][client]
- s3tests_conf.setdefault('fixtures', {})
- s3tests_conf['fixtures'].setdefault('bucket prefix', 'test-' + client + '-{random}-')
+ for client, cconfig in config.items():
+ conf = s3tests_conf[client]
+ conf.setdefault('fixtures', {})
+ conf['fixtures'].setdefault('bucket prefix', 'test-' + client + '-{random}-')
for section, user in users.items():
- _config_user(s3tests_conf, section, '{user}.{client}'.format(user=user, client=client))
- log.debug('Creating user {user} on {host}'.format(user=s3tests_conf[section]['user_id'], host=client))
+ _config_user(conf, section, '{user}.{client}'.format(user=user, client=client))
+ log.debug('Creating user {user} on {host}'.format(user=conf[section]['user_id'], host=client))
cluster_name, daemon_type, client_id = teuthology.split_role(client)
client_with_id = daemon_type + '.' + client_id
# create user
'radosgw-admin',
'-n', client_with_id,
'user', 'create',
- '--uid', s3tests_conf[section]['user_id'],
- '--display-name', s3tests_conf[section]['display_name'],
- '--email', s3tests_conf[section]['email'],
+ '--uid', conf[section]['user_id'],
+ '--display-name', conf[section]['display_name'],
+ '--email', conf[section]['email'],
'--caps', 'user-policy=*',
- '--access-key', s3tests_conf[section]['access_key'],
- '--secret', s3tests_conf[section]['secret_key'],
+ '--access-key', conf[section]['access_key'],
+ '--secret', conf[section]['secret_key'],
'--cluster', cluster_name,
],
)
'radosgw-admin',
'-n', client_with_id,
'mfa', 'create',
- '--uid', s3tests_conf[section]['user_id'],
- '--totp-serial', s3tests_conf[section]['totp_serial'],
- '--totp-seed', s3tests_conf[section]['totp_seed'],
- '--totp-seconds', s3tests_conf[section]['totp_seconds'],
+ '--uid', conf[section]['user_id'],
+ '--totp-serial', conf[section]['totp_serial'],
+ '--totp-seed', conf[section]['totp_seed'],
+ '--totp-seconds', conf[section]['totp_seconds'],
'--totp-window', '8',
'--totp-seed-type', 'base32',
'--cluster', cluster_name,
'radosgw-admin',
'-n', client_with_id,
'caps', 'add',
- '--uid', s3tests_conf[section]['user_id'],
+ '--uid', conf[section]['user_id'],
'--caps', 'roles=*',
'--cluster', cluster_name,
],
'radosgw-admin',
'-n', client_with_id,
'caps', 'add',
- '--uid', s3tests_conf[section]['user_id'],
+ '--uid', conf[section]['user_id'],
'--caps', 'oidc-provider=*',
'--cluster', cluster_name,
],
)
if "TOKEN" in os.environ:
- s3tests_conf.setdefault('webidentity', {})
- s3tests_conf['webidentity'].setdefault('token',os.environ['TOKEN'])
- s3tests_conf['webidentity'].setdefault('aud',os.environ['AUD'])
- s3tests_conf['webidentity'].setdefault('sub',os.environ['SUB'])
- s3tests_conf['webidentity'].setdefault('azp',os.environ['AZP'])
- s3tests_conf['webidentity'].setdefault('user_token',os.environ['USER_TOKEN'])
- s3tests_conf['webidentity'].setdefault('thumbprint',os.environ['THUMBPRINT'])
- s3tests_conf['webidentity'].setdefault('KC_REALM',os.environ['KC_REALM'])
+ conf.setdefault('webidentity', {})
+ conf['webidentity'].setdefault('token',os.environ['TOKEN'])
+ conf['webidentity'].setdefault('aud',os.environ['AUD'])
+ conf['webidentity'].setdefault('sub',os.environ['SUB'])
+ conf['webidentity'].setdefault('azp',os.environ['AZP'])
+ conf['webidentity'].setdefault('user_token',os.environ['USER_TOKEN'])
+ conf['webidentity'].setdefault('thumbprint',os.environ['THUMBPRINT'])
+ conf['webidentity'].setdefault('KC_REALM',os.environ['KC_REALM'])
try:
yield
finally:
- for client in config['clients']:
+ for client in config.keys():
for user in users.values():
uid = '{user}.{client}'.format(user=user, client=client)
cluster_name, daemon_type, client_id = teuthology.split_role(client)
with contextutil.nested(
lambda: download(ctx=ctx, config=config),
- lambda: create_users(ctx=ctx, config=dict(
- clients=clients,
- s3tests_conf=s3tests_conf,
- )),
+ lambda: create_users(ctx=ctx, config=config, s3tests_conf=s3tests_conf),
lambda: configure(ctx=ctx, config=dict(
clients=config,
s3tests_conf=s3tests_conf,