summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-04-04 17:17:03 +0000
committerGerrit Code Review <review@openstack.org>2023-04-04 17:17:03 +0000
commit3c7eebaaf35c9e8a3f00c76cd1741457bdec9fab (patch)
tree9c0bb91626563749e175d67ffa4cd546c1c38676
parent94649e792e08fcfb3859a4f7cf314070287f985c (diff)
parentb15ff9b0f28b0a3de70f02c05d107acf589d758d (diff)
downloadtempest-3c7eebaaf35c9e8a3f00c76cd1741457bdec9fab.tar.gz
Merge "Add project reader to account-generator"
-rwxr-xr-xtempest/cmd/account_generator.py9
-rw-r--r--tempest/tests/cmd/test_account_generator.py42
2 files changed, 30 insertions, 21 deletions
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index ad0b54768..f4f4b17d1 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -155,7 +155,7 @@ def generate_resources(cred_provider, admin):
# Create the list of resources to be provisioned for each process
# NOTE(andreaf) get_credentials expects a string for types or a list for
# roles. Adding all required inputs to the spec list.
- spec = ['primary', 'alt']
+ spec = ['primary', 'alt', 'project_reader']
if CONF.service_available.swift:
spec.append([CONF.object_storage.operator_role])
spec.append([CONF.object_storage.reseller_admin_role])
@@ -163,8 +163,13 @@ def generate_resources(cred_provider, admin):
spec.append('admin')
resources = []
for cred_type in spec:
+ scope = None
+ if "_" in cred_type:
+ scope = cred_type.split("_")[0]
+ cred_type = cred_type.split("_")[1:2]
+
resources.append((cred_type, cred_provider.get_credentials(
- credential_type=cred_type)))
+ credential_type=cred_type, scope=scope)))
return resources
diff --git a/tempest/tests/cmd/test_account_generator.py b/tempest/tests/cmd/test_account_generator.py
index 7d764be73..9647467c9 100644
--- a/tempest/tests/cmd/test_account_generator.py
+++ b/tempest/tests/cmd/test_account_generator.py
@@ -153,13 +153,14 @@ class TestGenerateResourcesV2(base.TestCase, MockHelpersMixin):
resources = account_generator.generate_resources(
self.cred_provider, admin=False)
resource_types = [k for k, _ in resources]
- # No admin, no swift, expect two credentials only
- self.assertEqual(2, len(resources))
- # Ensure create_user was invoked twice (two distinct users)
- self.assertEqual(2, self.user_create_fixture.mock.call_count)
+ # No admin, no swift, expect three credentials only
+ self.assertEqual(3, len(resources))
+ # Ensure create_user was invoked three times (three distinct users)
+ self.assertEqual(3, self.user_create_fixture.mock.call_count)
self.assertIn('primary', resource_types)
self.assertIn('alt', resource_types)
self.assertNotIn('admin', resource_types)
+ self.assertIn(['reader'], resource_types)
self.assertNotIn(['fake_operator'], resource_types)
self.assertNotIn(['fake_reseller'], resource_types)
self.assertNotIn(['fake_owner'], resource_types)
@@ -178,12 +179,13 @@ class TestGenerateResourcesV2(base.TestCase, MockHelpersMixin):
self.cred_provider, admin=True)
resource_types = [k for k, _ in resources]
# Admin, no swift, expect three credentials only
- self.assertEqual(3, len(resources))
- # Ensure create_user was invoked 3 times (3 distinct users)
- self.assertEqual(3, self.user_create_fixture.mock.call_count)
+ self.assertEqual(4, len(resources))
+ # Ensure create_user was invoked 4 times (4 distinct users)
+ self.assertEqual(4, self.user_create_fixture.mock.call_count)
self.assertIn('primary', resource_types)
self.assertIn('alt', resource_types)
self.assertIn('admin', resource_types)
+ self.assertIn(['reader'], resource_types)
self.assertNotIn(['fake_operator'], resource_types)
self.assertNotIn(['fake_reseller'], resource_types)
self.assertNotIn(['fake_owner'], resource_types)
@@ -201,13 +203,14 @@ class TestGenerateResourcesV2(base.TestCase, MockHelpersMixin):
resources = account_generator.generate_resources(
self.cred_provider, admin=True)
resource_types = [k for k, _ in resources]
- # all options on, expect five credentials
- self.assertEqual(5, len(resources))
- # Ensure create_user was invoked 5 times (5 distinct users)
- self.assertEqual(5, self.user_create_fixture.mock.call_count)
+ # all options on, expect six credentials
+ self.assertEqual(6, len(resources))
+ # Ensure create_user was invoked 6 times (6 distinct users)
+ self.assertEqual(6, self.user_create_fixture.mock.call_count)
self.assertIn('primary', resource_types)
self.assertIn('alt', resource_types)
self.assertIn('admin', resource_types)
+ self.assertIn(['reader'], resource_types)
self.assertIn(['fake_operator'], resource_types)
self.assertIn(['fake_reseller'], resource_types)
for resource in resources:
@@ -224,13 +227,14 @@ class TestGenerateResourcesV2(base.TestCase, MockHelpersMixin):
resources = account_generator.generate_resources(
self.cred_provider, admin=False)
resource_types = [k for k, _ in resources]
- # No Admin, swift, expect four credentials only
- self.assertEqual(4, len(resources))
- # Ensure create_user was invoked 4 times (4 distinct users)
- self.assertEqual(4, self.user_create_fixture.mock.call_count)
+ # No Admin, swift, expect five credentials only
+ self.assertEqual(5, len(resources))
+ # Ensure create_user was invoked 5 times (5 distinct users)
+ self.assertEqual(5, self.user_create_fixture.mock.call_count)
self.assertIn('primary', resource_types)
self.assertIn('alt', resource_types)
self.assertNotIn('admin', resource_types)
+ self.assertIn(['reader'], resource_types)
self.assertIn(['fake_operator'], resource_types)
self.assertIn(['fake_reseller'], resource_types)
self.assertNotIn(['fake_owner'], resource_types)
@@ -284,14 +288,14 @@ class TestDumpAccountsV2(base.TestCase, MockHelpersMixin):
# Ordered args in [0], keyword args in [1]
accounts, f = yaml_dump_mock.call_args[0]
self.assertEqual(handle, f)
- self.assertEqual(5, len(accounts))
+ self.assertEqual(6, len(accounts))
if self.domain_is_in:
self.assertIn('domain_name', accounts[0].keys())
else:
self.assertNotIn('domain_name', accounts[0].keys())
self.assertEqual(1, len([x for x in accounts if
x.get('types') == ['admin']]))
- self.assertEqual(2, len([x for x in accounts if 'roles' in x]))
+ self.assertEqual(3, len([x for x in accounts if 'roles' in x]))
for account in accounts:
self.assertIn('resources', account)
self.assertIn('network', account.get('resources'))
@@ -315,14 +319,14 @@ class TestDumpAccountsV2(base.TestCase, MockHelpersMixin):
# Ordered args in [0], keyword args in [1]
accounts, f = yaml_dump_mock.call_args[0]
self.assertEqual(handle, f)
- self.assertEqual(5, len(accounts))
+ self.assertEqual(6, len(accounts))
if self.domain_is_in:
self.assertIn('domain_name', accounts[0].keys())
else:
self.assertNotIn('domain_name', accounts[0].keys())
self.assertEqual(1, len([x for x in accounts if
x.get('types') == ['admin']]))
- self.assertEqual(2, len([x for x in accounts if 'roles' in x]))
+ self.assertEqual(3, len([x for x in accounts if 'roles' in x]))
for account in accounts:
self.assertIn('resources', account)
self.assertIn('network', account.get('resources'))