Access credential fields as attributes
Some tests access credentials attributes using dictionary syntax (e.g. with get method); changed to use the Credentials attribute directly. Partially implements: bp multi-keystone-api-version-tests Change-Id: Ic5b68af18d9a2dda581bdc1500d064e0ba732ec4
This commit is contained in:
parent
422fbdf0a0
commit
86ad28d568
|
@ -28,8 +28,7 @@ class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
|
|||
|
||||
# NOTE(afazekas): these test cases should always create and use a new
|
||||
# tenant most of them should be skipped if we can't do that
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
|
||||
'tenantId')
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
|
||||
cls.default_quota_set = set(('injected_file_content_bytes',
|
||||
'metadata_items', 'injected_files',
|
||||
|
|
|
@ -33,8 +33,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||
|
||||
# NOTE(afazekas): these test cases should always create and use a new
|
||||
# tenant most of them should be skipped if we can't do that
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
|
||||
'tenantId')
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
|
||||
@test.attr(type=['negative', 'gate'])
|
||||
def test_update_quota_normal_user(self):
|
||||
|
|
|
@ -32,8 +32,7 @@ class QuotasAdminV3Test(base.BaseV3ComputeAdminTest):
|
|||
|
||||
# NOTE(afazekas): these test cases should always create and use a new
|
||||
# tenant most of them should be skipped if we can't do that
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
|
||||
'tenantId')
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
|
||||
cls.default_quota_set = set(('metadata_items',
|
||||
'ram', 'floating_ips',
|
||||
|
|
|
@ -30,8 +30,7 @@ class QuotasAdminNegativeV3Test(base.BaseV3ComputeAdminTest):
|
|||
|
||||
# NOTE(afazekas): these test cases should always create and use a new
|
||||
# tenant most of them should be skipped if we can't do that
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
|
||||
'tenantId')
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
|
||||
# TODO(afazekas): Add dedicated tenant to the skiped quota tests
|
||||
# it can be moved into the setUpClass as well
|
||||
|
|
|
@ -38,9 +38,7 @@ class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
|
|||
cls.force_tenant_isolation = True
|
||||
manager = cls.get_client_manager()
|
||||
cls.client = manager.network_client
|
||||
primary_creds = cls.isolated_creds.get_primary_creds()
|
||||
cls.tenant_id = cls.os_adm.identity_client.get_tenant_by_name(
|
||||
primary_creds.tenant_name)['id']
|
||||
cls.tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
cls.network = cls.create_network()
|
||||
cls.subnet = cls.create_subnet(cls.network)
|
||||
cls.pool = cls.create_pool(data_utils.rand_name('pool-'),
|
||||
|
|
|
@ -29,8 +29,7 @@ class VolumeQuotasAdminTestJSON(base.BaseVolumeV1AdminTest):
|
|||
def setUpClass(cls):
|
||||
super(VolumeQuotasAdminTestJSON, cls).setUpClass()
|
||||
cls.admin_volume_client = cls.os_adm.volumes_client
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
|
||||
'tenantId')
|
||||
cls.demo_tenant_id = cls.isolated_creds.get_primary_creds().tenant_id
|
||||
|
||||
@test.attr(type='gate')
|
||||
def test_list_quotas(self):
|
||||
|
|
|
@ -140,15 +140,19 @@ class RestClient(object):
|
|||
|
||||
@property
|
||||
def user(self):
|
||||
return self.auth_provider.credentials.get('username', None)
|
||||
return self.auth_provider.credentials.username
|
||||
|
||||
@property
|
||||
def tenant_name(self):
|
||||
return self.auth_provider.credentials.get('tenant_name', None)
|
||||
return self.auth_provider.credentials.tenant_name
|
||||
|
||||
@property
|
||||
def tenant_id(self):
|
||||
return self.auth_provider.credentials.tenant_id
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
return self.auth_provider.credentials.get('password', None)
|
||||
return self.auth_provider.credentials.password
|
||||
|
||||
@property
|
||||
def base_url(self):
|
||||
|
|
|
@ -102,11 +102,6 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
self.manager = clients.OfficialClientManager(credentials)
|
||||
# Credentials from manager are filled with both names and IDs
|
||||
self.creds = self.manager.credentials
|
||||
self.keypair = None
|
||||
self.tenant_id = credentials.tenant_id
|
||||
self.tenant_name = credentials.tenant_name
|
||||
self.tenant_user = credentials.username
|
||||
self.tenant_pass = credentials.password
|
||||
self.network = None
|
||||
self.subnet = None
|
||||
self.router = None
|
||||
|
@ -119,12 +114,14 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
self.router = router
|
||||
|
||||
def _get_tenant_credentials(self):
|
||||
return self.tenant_user, self.tenant_pass, self.tenant_name
|
||||
# FIXME(andreaf) Unused method
|
||||
return self.creds
|
||||
|
||||
@classmethod
|
||||
def check_preconditions(cls):
|
||||
super(TestSecurityGroupsBasicOps, cls).check_preconditions()
|
||||
if (cls.alt_tenant_id is None) or (cls.tenant_id is cls.alt_tenant_id):
|
||||
if (cls.alt_creds is None) or \
|
||||
(cls.tenant_id is cls.alt_creds.tenant_id):
|
||||
msg = 'No alt_tenant defined'
|
||||
cls.enabled = False
|
||||
raise cls.skipException(msg)
|
||||
|
@ -140,7 +137,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
super(TestSecurityGroupsBasicOps, cls).setUpClass()
|
||||
cls.alt_creds = cls.alt_credentials()
|
||||
cls.alt_manager = clients.OfficialClientManager(cls.alt_creds)
|
||||
cls.alt_tenant_id = cls.alt_manager.identity_client.tenant_id
|
||||
# Credentials from the manager are filled with both IDs and Names
|
||||
cls.alt_creds = cls.alt_manager.credentials
|
||||
cls.check_preconditions()
|
||||
# TODO(mnewby) Consider looking up entities as needed instead
|
||||
# of storing them as collections on the class.
|
||||
|
@ -150,7 +148,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
cls.primary_tenant = cls.TenantProperties(creds)
|
||||
cls.alt_tenant = cls.TenantProperties(cls.alt_creds)
|
||||
for tenant in [cls.primary_tenant, cls.alt_tenant]:
|
||||
cls.tenants[tenant.tenant_id] = tenant
|
||||
cls.tenants[tenant.creds.tenant_id] = tenant
|
||||
cls.floating_ip_access = not CONF.network.public_router_id
|
||||
|
||||
def cleanup_wrapper(self, resource):
|
||||
|
@ -171,14 +169,14 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
def _create_tenant_security_groups(self, tenant):
|
||||
access_sg = self._create_empty_security_group(
|
||||
namestart='secgroup_access-',
|
||||
tenant_id=tenant.tenant_id
|
||||
tenant_id=tenant.creds.tenant_id
|
||||
)
|
||||
self.addCleanup(self.cleanup_wrapper, access_sg)
|
||||
|
||||
# don't use default secgroup since it allows in-tenant traffic
|
||||
def_sg = self._create_empty_security_group(
|
||||
namestart='secgroup_general-',
|
||||
tenant_id=tenant.tenant_id
|
||||
tenant_id=tenant.creds.tenant_id
|
||||
)
|
||||
self.addCleanup(self.cleanup_wrapper, def_sg)
|
||||
tenant.security_groups.update(access=access_sg, default=def_sg)
|
||||
|
@ -235,7 +233,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
],
|
||||
'key_name': tenant.keypair.name,
|
||||
'security_groups': security_groups,
|
||||
'tenant_id': tenant.tenant_id
|
||||
'tenant_id': tenant.creds.tenant_id
|
||||
}
|
||||
server = self.create_server(name=name, create_kwargs=create_kwargs)
|
||||
self.addCleanup(self.cleanup_wrapper, server)
|
||||
|
@ -244,7 +242,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
def _create_tenant_servers(self, tenant, num=1):
|
||||
for i in range(num):
|
||||
name = 'server-{tenant}-gen-{num}-'.format(
|
||||
tenant=tenant.tenant_name,
|
||||
tenant=tenant.creds.tenant_name,
|
||||
num=i
|
||||
)
|
||||
name = data_utils.rand_name(name)
|
||||
|
@ -258,8 +256,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
workaround ip namespace
|
||||
"""
|
||||
secgroups = [sg.name for sg in tenant.security_groups.values()]
|
||||
name = 'server-{tenant}-access_point-'.format(tenant=tenant.tenant_name
|
||||
)
|
||||
name = 'server-{tenant}-access_point-'.format(
|
||||
tenant=tenant.creds.tenant_name)
|
||||
name = data_utils.rand_name(name)
|
||||
server = self._create_server(name, tenant,
|
||||
security_groups=secgroups)
|
||||
|
@ -273,7 +271,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
self.floating_ips.setdefault(server, floating_ip)
|
||||
|
||||
def _create_tenant_network(self, tenant):
|
||||
network, subnet, router = self._create_networks(tenant.tenant_id)
|
||||
network, subnet, router = self._create_networks(tenant.creds.tenant_id)
|
||||
for r in [network, router, subnet]:
|
||||
self.addCleanup(self.cleanup_wrapper, r)
|
||||
tenant.set_network(network, subnet, router)
|
||||
|
@ -296,7 +294,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||
tenant_id = tenant_or_id
|
||||
else:
|
||||
tenant = tenant_or_id
|
||||
tenant_id = tenant.tenant_id
|
||||
tenant_id = tenant.creds.tenant_id
|
||||
self._set_compute_context(tenant)
|
||||
self._create_tenant_keypairs(tenant_id)
|
||||
self._create_tenant_network(tenant)
|
||||
|
|
Loading…
Reference in New Issue