Make all fixture project_ids into uuids

The Fernet tests for Python 3.4 fail if they are given
project_ids that are not uuids. Since all issued
project IDs in a live deployment are UUIDs, it is more
correct to fix the tests than to change the formatter.

Change-Id: I485c02cbb6484e52b4bb4563e2842c45a34e66eb
This commit is contained in:
Adam Young 2016-04-15 22:37:48 -04:00 committed by Brant Knudson
parent 3a266929cf
commit 36da34f02f
4 changed files with 26 additions and 18 deletions

View File

@ -732,7 +732,8 @@ class TestCase(BaseTestCase):
fixtures_to_cleanup.append(attrname)
for tenant in fixtures.TENANTS:
if hasattr(self, 'tenant_%s' % tenant['id']):
tenant_attr_name = 'tenant_%s' % tenant['name'].lower()
if hasattr(self, tenant_attr_name):
try:
# This will clear out any roles on the project as well
self.resource_api.delete_project(tenant['id'])
@ -741,9 +742,8 @@ class TestCase(BaseTestCase):
rv = self.resource_api.create_project(
tenant['id'], tenant)
attrname = 'tenant_%s' % tenant['id']
setattr(self, attrname, rv)
fixtures_to_cleanup.append(attrname)
setattr(self, tenant_attr_name, rv)
fixtures_to_cleanup.append(tenant_attr_name)
for role in fixtures.ROLES:
try:

View File

@ -14,12 +14,17 @@
# NOTE(dolph): please try to avoid additional fixtures if possible; test suite
# performance may be negatively affected.
import uuid
BAR_TENANT_ID = uuid.uuid4().hex
BAZ_TENANT_ID = uuid.uuid4().hex
MTU_TENANT_ID = uuid.uuid4().hex
SERVICE_TENANT_ID = uuid.uuid4().hex
DEFAULT_DOMAIN_ID = 'default'
TENANTS = [
{
'id': 'bar',
'id': BAR_TENANT_ID,
'name': 'BAR',
'domain_id': DEFAULT_DOMAIN_ID,
'description': 'description',
@ -27,7 +32,7 @@ TENANTS = [
'parent_id': DEFAULT_DOMAIN_ID,
'is_domain': False,
}, {
'id': 'baz',
'id': BAZ_TENANT_ID,
'name': 'BAZ',
'domain_id': DEFAULT_DOMAIN_ID,
'description': 'description',
@ -35,7 +40,7 @@ TENANTS = [
'parent_id': DEFAULT_DOMAIN_ID,
'is_domain': False,
}, {
'id': 'mtu',
'id': MTU_TENANT_ID,
'name': 'MTU',
'description': 'description',
'enabled': True,
@ -43,7 +48,7 @@ TENANTS = [
'parent_id': DEFAULT_DOMAIN_ID,
'is_domain': False,
}, {
'id': 'service',
'id': SERVICE_TENANT_ID,
'name': 'service',
'description': 'description',
'enabled': True,
@ -69,7 +74,7 @@ USERS = [
'name': 'FOO',
'domain_id': DEFAULT_DOMAIN_ID,
'password': 'foo2',
'tenants': ['bar'],
'tenants': [BAR_TENANT_ID],
'enabled': True,
'email': 'foo@bar.com',
}, {
@ -78,8 +83,8 @@ USERS = [
'domain_id': DEFAULT_DOMAIN_ID,
'password': 'two2',
'enabled': True,
'default_project_id': 'baz',
'tenants': ['baz'],
'default_project_id': BAZ_TENANT_ID,
'tenants': [BAZ_TENANT_ID],
'email': 'two@three.com',
}, {
'id': 'badguy',
@ -87,8 +92,8 @@ USERS = [
'domain_id': DEFAULT_DOMAIN_ID,
'password': 'bad',
'enabled': False,
'default_project_id': 'baz',
'tenants': ['baz'],
'default_project_id': BAZ_TENANT_ID,
'tenants': [BAZ_TENANT_ID],
'email': 'bad@guy.com',
}, {
'id': 'sna',
@ -96,7 +101,7 @@ USERS = [
'domain_id': DEFAULT_DOMAIN_ID,
'password': 'snafu',
'enabled': True,
'tenants': ['bar'],
'tenants': [BAR_TENANT_ID],
'email': 'sna@snl.coom',
}
]
@ -137,7 +142,7 @@ ROLES = [
ROLE_ASSIGNMENTS = [
{
'user': 'reqadmin',
'tenant_id': 'service',
'tenant_id': SERVICE_TENANT_ID,
'role_id': 'admin'
},
]

View File

@ -223,7 +223,7 @@ class RestfulTestCase(unit.TestCase):
'username': self.user_reqadmin['name'],
'password': self.user_reqadmin['password']
},
'tenantId': 'service'
'tenantId': default_fixtures.SERVICE_TENANT_ID
}
})

View File

@ -24,6 +24,7 @@ from testtools import matchers
from keystone.common import extension as keystone_extension
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit import ksfixtures
from keystone.tests.unit import rest
from keystone.tests.unit.schema import v2
@ -180,7 +181,8 @@ class CoreApiTests(object):
self.tenant_service['id'],
self.role_service['id'])
token = self.get_scoped_token(tenant_id='service')
token = self.get_scoped_token(
tenant_id=default_fixtures.SERVICE_TENANT_ID)
r = self.admin_request(
path='/v2.0/tokens/%s' % token,
token=token)
@ -192,7 +194,8 @@ class CoreApiTests(object):
self.tenant_service['id'],
self.role_service['id'])
token = self.get_scoped_token(tenant_id='service')
token = self.get_scoped_token(
tenant_id=default_fixtures.SERVICE_TENANT_ID)
r = self.admin_request(
path='/v2.0/tokens/%s' % token,
token=token)