Exemplo n.º 1
0
 def test_create_endpoint_with_region(self):
     """EndpointV3 creates the region before creating the endpoint, if
     endpoint is provided with 'region' and no 'region_id'
     """
     ref = unit.new_endpoint_ref_with_region(service_id=self.service_id,
                                             region=uuid.uuid4().hex)
     self.post('/endpoints', body={'endpoint': ref})
     # Make sure the region is created
     self.get('/regions/%(region_id)s' % {'region_id': ref["region"]})
Exemplo n.º 2
0
 def test_create_endpoint_with_region(self):
     """EndpointV3 creates the region before creating the endpoint, if
     endpoint is provided with 'region' and no 'region_id'
     """
     ref = unit.new_endpoint_ref_with_region(service_id=self.service_id,
                                             region=uuid.uuid4().hex)
     self.post('/endpoints', body={'endpoint': ref})
     # Make sure the region is created
     self.get('/regions/%(region_id)s' % {'region_id': ref["region"]})
Exemplo n.º 3
0
    def test_create_endpoint_with_region(self):
        """EndpointV3 creates the region before creating the endpoint.

        This occurs when endpoint is provided with 'region' and no 'region_id'.
        """
        ref = unit.new_endpoint_ref_with_region(service_id=self.service_id, region=uuid.uuid4().hex)
        self.post("/endpoints", body={"endpoint": ref})
        # Make sure the region is created
        self.get("/regions/%(region_id)s" % {"region_id": ref["region"]})
Exemplo n.º 4
0
    def test_create_endpoint_on_v2(self):
        # clear the v3 endpoint so we only have endpoints created on v2
        self.delete(
            '/endpoints/%(endpoint_id)s' % {
                'endpoint_id': self.endpoint_id})

        # create a v3 endpoint ref, and then tweak it back to a v2-style ref
        ref = unit.new_endpoint_ref_with_region(service_id=self.service['id'],
                                                region=uuid.uuid4().hex,
                                                internalurl=None)
        del ref['id']
        del ref['interface']
        ref['publicurl'] = ref.pop('url')
        # don't set adminurl to ensure it's absence is handled like internalurl

        # create the endpoint on v2 (using a v3 token)
        r = self.admin_request(
            method='POST',
            path='/v2.0/endpoints',
            token=self.get_scoped_token(),
            body={'endpoint': ref})
        endpoint_v2 = r.result['endpoint']

        # test the endpoint on v3
        r = self.get('/endpoints')
        endpoints = self.assertValidEndpointListResponse(r)
        self.assertEqual(1, len(endpoints))
        endpoint_v3 = endpoints.pop()

        # these attributes are identical between both APIs
        self.assertEqual(ref['region'], endpoint_v3['region_id'])
        self.assertEqual(ref['service_id'], endpoint_v3['service_id'])
        self.assertEqual(ref['description'], endpoint_v3['description'])

        # a v2 endpoint is not quite the same concept as a v3 endpoint, so they
        # receive different identifiers
        self.assertNotEqual(endpoint_v2['id'], endpoint_v3['id'])

        # v2 has a publicurl; v3 has a url + interface type
        self.assertEqual(ref['publicurl'], endpoint_v3['url'])
        self.assertEqual('public', endpoint_v3['interface'])

        # tests for bug 1152632 -- these attributes were being returned by v3
        self.assertNotIn('publicurl', endpoint_v3)
        self.assertNotIn('adminurl', endpoint_v3)
        self.assertNotIn('internalurl', endpoint_v3)

        # test for bug 1152635 -- this attribute was being returned by v3
        self.assertNotIn('legacy_endpoint_id', endpoint_v3)

        self.assertEqual(endpoint_v2['region'], endpoint_v3['region_id'])
Exemplo n.º 5
0
    def test_create_endpoint_on_v2(self):
        # clear the v3 endpoint so we only have endpoints created on v2
        self.delete(
            '/endpoints/%(endpoint_id)s' % {
                'endpoint_id': self.endpoint_id})

        # create a v3 endpoint ref, and then tweak it back to a v2-style ref
        ref = unit.new_endpoint_ref_with_region(service_id=self.service['id'],
                                                region=uuid.uuid4().hex,
                                                internalurl=None)
        del ref['id']
        del ref['interface']
        ref['publicurl'] = ref.pop('url')
        # don't set adminurl to ensure it's absence is handled like internalurl

        # create the endpoint on v2 (using a v3 token)
        r = self.admin_request(
            method='POST',
            path='/v2.0/endpoints',
            token=self.get_scoped_token(),
            body={'endpoint': ref})
        endpoint_v2 = r.result['endpoint']

        # test the endpoint on v3
        r = self.get('/endpoints')
        endpoints = self.assertValidEndpointListResponse(r)
        self.assertEqual(1, len(endpoints))
        endpoint_v3 = endpoints.pop()

        # these attributes are identical between both APIs
        self.assertEqual(ref['region'], endpoint_v3['region_id'])
        self.assertEqual(ref['service_id'], endpoint_v3['service_id'])
        self.assertEqual(ref['description'], endpoint_v3['description'])

        # a v2 endpoint is not quite the same concept as a v3 endpoint, so they
        # receive different identifiers
        self.assertNotEqual(endpoint_v2['id'], endpoint_v3['id'])

        # v2 has a publicurl; v3 has a url + interface type
        self.assertEqual(ref['publicurl'], endpoint_v3['url'])
        self.assertEqual('public', endpoint_v3['interface'])

        # tests for bug 1152632 -- these attributes were being returned by v3
        self.assertNotIn('publicurl', endpoint_v3)
        self.assertNotIn('adminurl', endpoint_v3)
        self.assertNotIn('internalurl', endpoint_v3)

        # test for bug 1152635 -- this attribute was being returned by v3
        self.assertNotIn('legacy_endpoint_id', endpoint_v3)

        self.assertEqual(endpoint_v2['region'], endpoint_v3['region_id'])
Exemplo n.º 6
0
    def test_create_endpoint_on_v2(self):
        # clear the v3 endpoint so we only have endpoints created on v2
        self.delete("/endpoints/%(endpoint_id)s" % {"endpoint_id": self.endpoint_id})

        # create a v3 endpoint ref, and then tweak it back to a v2-style ref
        ref = unit.new_endpoint_ref_with_region(
            service_id=self.service["id"], region=uuid.uuid4().hex, internalurl=None
        )
        del ref["id"]
        del ref["interface"]
        ref["publicurl"] = ref.pop("url")
        # don't set adminurl to ensure it's absence is handled like internalurl

        # create the endpoint on v2 (using a v3 token)
        r = self.admin_request(
            method="POST", path="/v2.0/endpoints", token=self.get_scoped_token(), body={"endpoint": ref}
        )
        endpoint_v2 = r.result["endpoint"]

        # test the endpoint on v3
        r = self.get("/endpoints")
        endpoints = self.assertValidEndpointListResponse(r)
        self.assertEqual(1, len(endpoints))
        endpoint_v3 = endpoints.pop()

        # these attributes are identical between both APIs
        self.assertEqual(ref["region"], endpoint_v3["region_id"])
        self.assertEqual(ref["service_id"], endpoint_v3["service_id"])
        self.assertEqual(ref["description"], endpoint_v3["description"])

        # a v2 endpoint is not quite the same concept as a v3 endpoint, so they
        # receive different identifiers
        self.assertNotEqual(endpoint_v2["id"], endpoint_v3["id"])

        # v2 has a publicurl; v3 has a url + interface type
        self.assertEqual(ref["publicurl"], endpoint_v3["url"])
        self.assertEqual("public", endpoint_v3["interface"])

        # tests for bug 1152632 -- these attributes were being returned by v3
        self.assertNotIn("publicurl", endpoint_v3)
        self.assertNotIn("adminurl", endpoint_v3)
        self.assertNotIn("internalurl", endpoint_v3)

        # test for bug 1152635 -- this attribute was being returned by v3
        self.assertNotIn("legacy_endpoint_id", endpoint_v3)

        self.assertEqual(endpoint_v2["region"], endpoint_v3["region_id"])