Merge "Add endpoint and service ids to fixtures"
This commit is contained in:
		@@ -21,12 +21,13 @@ from keystoneclient.fixture import exception
 | 
			
		||||
class _Service(dict):
 | 
			
		||||
 | 
			
		||||
    def add_endpoint(self, public, admin=None, internal=None,
 | 
			
		||||
                     tenant_id=None, region=None):
 | 
			
		||||
                     tenant_id=None, region=None, id=None):
 | 
			
		||||
        data = {'tenantId': tenant_id or uuid.uuid4().hex,
 | 
			
		||||
                'publicURL': public,
 | 
			
		||||
                'adminURL': admin or public,
 | 
			
		||||
                'internalURL': internal or public,
 | 
			
		||||
                'region': region}
 | 
			
		||||
                'region': region,
 | 
			
		||||
                'id': id or uuid.uuid4().hex}
 | 
			
		||||
 | 
			
		||||
        self.setdefault('endpoints', []).append(data)
 | 
			
		||||
        return data
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,9 @@ class _Service(dict):
 | 
			
		||||
    this object and then you can add_endpoints to the service.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def add_endpoint(self, interface, url, region=None):
 | 
			
		||||
        data = {'interface': interface,
 | 
			
		||||
    def add_endpoint(self, interface, url, region=None, id=None):
 | 
			
		||||
        data = {'id': id or uuid.uuid4().hex,
 | 
			
		||||
                'interface': interface,
 | 
			
		||||
                'url': url,
 | 
			
		||||
                'region': region,
 | 
			
		||||
                'region_id': region}
 | 
			
		||||
@@ -354,8 +355,8 @@ class Token(dict):
 | 
			
		||||
        roles.append(data)
 | 
			
		||||
        return data
 | 
			
		||||
 | 
			
		||||
    def add_service(self, type, name=None):
 | 
			
		||||
        service = _Service(type=type)
 | 
			
		||||
    def add_service(self, type, name=None, id=None):
 | 
			
		||||
        service = _Service(type=type, id=id or uuid.uuid4().hex)
 | 
			
		||||
        if name:
 | 
			
		||||
            service['name'] = name
 | 
			
		||||
        self.root.setdefault('catalog', []).append(service)
 | 
			
		||||
 
 | 
			
		||||
@@ -84,6 +84,7 @@ class V2TokenTests(utils.TestCase):
 | 
			
		||||
    def test_services(self):
 | 
			
		||||
        service_type = uuid.uuid4().hex
 | 
			
		||||
        service_name = uuid.uuid4().hex
 | 
			
		||||
        endpoint_id = uuid.uuid4().hex
 | 
			
		||||
        region = uuid.uuid4().hex
 | 
			
		||||
 | 
			
		||||
        public = uuid.uuid4().hex
 | 
			
		||||
@@ -96,7 +97,8 @@ class V2TokenTests(utils.TestCase):
 | 
			
		||||
        svc.add_endpoint(public=public,
 | 
			
		||||
                         admin=admin,
 | 
			
		||||
                         internal=internal,
 | 
			
		||||
                         region=region)
 | 
			
		||||
                         region=region,
 | 
			
		||||
                         id=endpoint_id)
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(1, len(token['access']['serviceCatalog']))
 | 
			
		||||
        service = token['access']['serviceCatalog'][0]['endpoints'][0]
 | 
			
		||||
@@ -105,6 +107,7 @@ class V2TokenTests(utils.TestCase):
 | 
			
		||||
        self.assertEqual(internal, service['internalURL'])
 | 
			
		||||
        self.assertEqual(admin, service['adminURL'])
 | 
			
		||||
        self.assertEqual(region, service['region'])
 | 
			
		||||
        self.assertEqual(endpoint_id, service['id'])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class V3TokenTests(utils.TestCase):
 | 
			
		||||
@@ -218,13 +221,16 @@ class V3TokenTests(utils.TestCase):
 | 
			
		||||
    def test_catalog(self):
 | 
			
		||||
        service_type = uuid.uuid4().hex
 | 
			
		||||
        service_name = uuid.uuid4().hex
 | 
			
		||||
        service_id = uuid.uuid4().hex
 | 
			
		||||
        region = uuid.uuid4().hex
 | 
			
		||||
        endpoints = {'public': uuid.uuid4().hex,
 | 
			
		||||
                     'internal': uuid.uuid4().hex,
 | 
			
		||||
                     'admin': uuid.uuid4().hex}
 | 
			
		||||
 | 
			
		||||
        token = fixture.V3Token()
 | 
			
		||||
        svc = token.add_service(type=service_type, name=service_name)
 | 
			
		||||
        svc = token.add_service(type=service_type,
 | 
			
		||||
                                name=service_name,
 | 
			
		||||
                                id=service_id)
 | 
			
		||||
        svc.add_standard_endpoints(region=region, **endpoints)
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(1, len(token['token']['catalog']))
 | 
			
		||||
@@ -233,6 +239,12 @@ class V3TokenTests(utils.TestCase):
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(service_name, service['name'])
 | 
			
		||||
        self.assertEqual(service_type, service['type'])
 | 
			
		||||
        self.assertEqual(service_id, service['id'])
 | 
			
		||||
 | 
			
		||||
        for endpoint in service['endpoints']:
 | 
			
		||||
            # assert an id exists for each endpoint, remove it to make testing
 | 
			
		||||
            # the endpoint content below easier.
 | 
			
		||||
            self.assertTrue(endpoint.pop('id'))
 | 
			
		||||
 | 
			
		||||
        for interface, url in six.iteritems(endpoints):
 | 
			
		||||
            endpoint = {'interface': interface, 'url': url,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user