Пример #1
0
    def test_delete_region_with_endpoint(self):
        # create a region
        region = unit.new_region_ref()
        self.catalog_api.create_region(region)

        # create a child region
        child_region = unit.new_region_ref(parent_region_id=region['id'])
        self.catalog_api.create_region(child_region)
        # create a service
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        # create an endpoint attached to the service and child region
        child_endpoint = unit.new_endpoint_ref(region_id=child_region['id'],
                                               service_id=service['id'])

        self.catalog_api.create_endpoint(child_endpoint['id'], child_endpoint)
        self.assertRaises(exception.RegionDeletionError,
                          self.catalog_api.delete_region,
                          child_region['id'])

        # create an endpoint attached to the service and parent region
        endpoint = unit.new_endpoint_ref(region_id=region['id'],
                                         service_id=service['id'])

        self.catalog_api.create_endpoint(endpoint['id'], endpoint)
        self.assertRaises(exception.RegionDeletionError,
                          self.catalog_api.delete_region,
                          region['id'])
Пример #2
0
    def test_v3_catalog_domain_scoped_token(self):
        # test the case that tenant_id is None.
        srv_1 = unit.new_service_ref()
        PROVIDERS.catalog_api.create_service(srv_1['id'], srv_1)
        endpoint_1 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        PROVIDERS.catalog_api.create_endpoint(endpoint_1['id'], endpoint_1)

        srv_2 = unit.new_service_ref()
        PROVIDERS.catalog_api.create_service(srv_2['id'], srv_2)
        endpoint_2 = unit.new_endpoint_ref(service_id=srv_2['id'],
                                           region_id=None)
        PROVIDERS.catalog_api.create_endpoint(endpoint_2['id'], endpoint_2)

        self.config_fixture.config(group='endpoint_filter',
                                   return_all_endpoints_if_no_filter=True)
        catalog_ref = PROVIDERS.catalog_api.get_v3_catalog(
            uuid.uuid4().hex, None
        )
        self.assertThat(catalog_ref, matchers.HasLength(2))
        self.config_fixture.config(group='endpoint_filter',
                                   return_all_endpoints_if_no_filter=False)
        catalog_ref = PROVIDERS.catalog_api.get_v3_catalog(
            uuid.uuid4().hex, None
        )
        self.assertThat(catalog_ref, matchers.HasLength(0))
Пример #3
0
    def test_delete_region_with_endpoint(self):
        # create a region
        region = {"id": uuid.uuid4().hex, "description": uuid.uuid4().hex}
        self.catalog_api.create_region(region)

        # create a child region
        child_region = {"id": uuid.uuid4().hex, "description": uuid.uuid4().hex, "parent_id": region["id"]}
        self.catalog_api.create_region(child_region)
        # create a service
        service = {
            "id": uuid.uuid4().hex,
            "type": uuid.uuid4().hex,
            "name": uuid.uuid4().hex,
            "description": uuid.uuid4().hex,
        }
        self.catalog_api.create_service(service["id"], service)

        # create an endpoint attached to the service and child region
        child_endpoint = unit.new_endpoint_ref(region_id=child_region["id"], service_id=service["id"])

        self.catalog_api.create_endpoint(child_endpoint["id"], child_endpoint)
        self.assertRaises(exception.RegionDeletionError, self.catalog_api.delete_region, child_region["id"])

        # create an endpoint attached to the service and parent region
        endpoint = unit.new_endpoint_ref(region_id=region["id"], service_id=service["id"])

        self.catalog_api.create_endpoint(endpoint["id"], endpoint)
        self.assertRaises(exception.RegionDeletionError, self.catalog_api.delete_region, region["id"])
Пример #4
0
    def test_v3_catalog_domain_scoped_token(self):
        # test the case that tenant_id is None.
        srv_1 = unit.new_service_ref()
        PROVIDERS.catalog_api.create_service(srv_1['id'], srv_1)
        endpoint_1 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        PROVIDERS.catalog_api.create_endpoint(endpoint_1['id'], endpoint_1)

        srv_2 = unit.new_service_ref()
        PROVIDERS.catalog_api.create_service(srv_2['id'], srv_2)
        endpoint_2 = unit.new_endpoint_ref(service_id=srv_2['id'],
                                           region_id=None)
        PROVIDERS.catalog_api.create_endpoint(endpoint_2['id'], endpoint_2)

        self.config_fixture.config(group='endpoint_filter',
                                   return_all_endpoints_if_no_filter=True)
        catalog_ref = PROVIDERS.catalog_api.get_v3_catalog(
            uuid.uuid4().hex, None
        )
        self.assertThat(catalog_ref, matchers.HasLength(2))
        self.config_fixture.config(group='endpoint_filter',
                                   return_all_endpoints_if_no_filter=False)
        catalog_ref = PROVIDERS.catalog_api.get_v3_catalog(
            uuid.uuid4().hex, None
        )
        self.assertThat(catalog_ref, matchers.HasLength(0))
Пример #5
0
    def test_cache_layer_delete_service_with_endpoint(self):
        service = unit.new_service_ref()
        PROVIDERS.catalog_api.create_service(service['id'], service)

        # create an endpoint attached to the service
        endpoint = unit.new_endpoint_ref(service_id=service['id'],
                                         region_id=None)
        PROVIDERS.catalog_api.create_endpoint(endpoint['id'], endpoint)
        # cache the result
        PROVIDERS.catalog_api.get_service(service['id'])
        PROVIDERS.catalog_api.get_endpoint(endpoint['id'])
        # delete the service bypassing catalog api
        PROVIDERS.catalog_api.driver.delete_service(service['id'])
        self.assertDictContainsSubset(endpoint,
                                      PROVIDERS.catalog_api.
                                      get_endpoint(endpoint['id']))
        self.assertDictContainsSubset(service,
                                      PROVIDERS.catalog_api.
                                      get_service(service['id']))
        PROVIDERS.catalog_api.get_endpoint.invalidate(
            PROVIDERS.catalog_api, endpoint['id']
        )
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.get_endpoint,
                          endpoint['id'])
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.delete_endpoint,
                          endpoint['id'])
        # multiple endpoints associated with a service
        second_endpoint = unit.new_endpoint_ref(service_id=service['id'],
                                                region_id=None)
        PROVIDERS.catalog_api.create_service(service['id'], service)
        PROVIDERS.catalog_api.create_endpoint(endpoint['id'], endpoint)
        PROVIDERS.catalog_api.create_endpoint(
            second_endpoint['id'], second_endpoint
        )
        PROVIDERS.catalog_api.delete_service(service['id'])
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.get_endpoint,
                          endpoint['id'])
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.delete_endpoint,
                          endpoint['id'])
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.get_endpoint,
                          second_endpoint['id'])
        self.assertRaises(exception.EndpointNotFound,
                          PROVIDERS.catalog_api.delete_endpoint,
                          second_endpoint['id'])
Пример #6
0
 def new_endpoint(region_id, service_id):
     endpoint = unit.new_endpoint_ref(interface='test',
                                      region_id=region_id,
                                      service_id=service_id,
                                      url='/url')
     self.endpoint.append(
         self.catalog_api.create_endpoint(endpoint['id'], endpoint))
Пример #7
0
    def test_endpoint_create_with_valid_url(self):
        """Create endpoint with valid url should be tested,too."""
        # list one valid url is enough, no need to list too much
        valid_url = "http://127.0.0.1:8774/v1.1/$(tenant_id)s"

        ref = unit.new_endpoint_ref(self.service_id, interface="public", region_id=self.region_id, url=valid_url)
        self.post("/endpoints", body={"endpoint": ref})
Пример #8
0
 def test_update_endpoint(self):
     """Call ``PATCH /endpoints/{endpoint_id}``."""
     ref = unit.new_endpoint_ref(service_id=self.service_id, interface="public", region_id=self.region_id)
     del ref["id"]
     r = self.patch("/endpoints/%(endpoint_id)s" % {"endpoint_id": self.endpoint_id}, body={"endpoint": ref})
     ref["enabled"] = True
     self.assertValidEndpointResponse(r, ref)
Пример #9
0
 def test_create_endpoint_enabled_false(self):
     """Call ``POST /endpoints`` with enabled: false."""
     ref = unit.new_endpoint_ref(
         service_id=self.service_id, interface="public", region_id=self.region_id, enabled=False
     )
     r = self.post("/endpoints", body={"endpoint": ref})
     self.assertValidEndpointResponse(r, ref)
    def test_pure_v3_endpoint_without_publicurl_invisible_from_v2(self):
        """Test pure v3 endpoint without public url can't be fetched via v2 API.

        V2 API will return endpoints created by v3 API, but because public url
        is required for v2 API, so v3 endpoints without public url will be
        ignored.
        """
        region_id = self._region_create()
        service_id = self._service_create()
        # create a v3 endpoint without public interface
        body = {
            'endpoint':
            unit.new_endpoint_ref(service_id, default_region_id=region_id)
        }
        for interface in catalog.controllers.INTERFACES:
            if interface == 'public':
                continue
            body['endpoint']['interface'] = interface
            self.admin_request(method='POST',
                               token=self.get_scoped_token(),
                               path='/v3/endpoints',
                               expected_status=http_client.CREATED,
                               body=body)

        r = self.admin_request(token=self.get_scoped_token(),
                               path='/v2.0/endpoints')
        # v3 endpoints without public url won't be fetched via v2.0 API
        self.assertEqual(0, len(r.result['endpoints']))
Пример #11
0
    def test_create_endpoint(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(service_id=service['id'],
                                         region_id=None)
        self.catalog_api.create_endpoint(endpoint['id'], endpoint.copy())
Пример #12
0
    def test_pure_v3_endpoint_without_publicurl_invisible_from_v2(self):
        """Test pure v3 endpoint without public url can't be fetched via v2 API.

        V2 API will return endpoints created by v3 API, but because public url
        is required for v2 API, so v3 endpoints without public url will be
        ignored.
        """
        region_id = self._region_create()
        service_id = self._service_create()
        # create a v3 endpoint without public interface
        body = {
            'endpoint': unit.new_endpoint_ref(service_id, region_id=region_id)
        }
        for interface in catalog.controllers.INTERFACES:
            if interface == 'public':
                continue
            body['endpoint']['interface'] = interface
            self.admin_request(method='POST',
                               token=self.get_scoped_token(),
                               path='/v3/endpoints',
                               expected_status=http_client.CREATED,
                               body=body)

        r = self.admin_request(token=self.get_scoped_token(),
                               path='/v2.0/endpoints')
        # v3 endpoints without public url won't be fetched via v2.0 API
        self.assertEqual(0, len(r.result['endpoints']))
Пример #13
0
 def test_update_endpoint_nonexistent_region(self):
     dummy_service, enabled_endpoint, dummy_disabled_endpoint = (
         self._create_endpoints())
     new_endpoint = unit.new_endpoint_ref(service_id=uuid.uuid4().hex)
     self.assertRaises(exception.ValidationError,
                       self.catalog_api.update_endpoint,
                       enabled_endpoint['id'], new_endpoint)
Пример #14
0
    def create_endpoint(self, service_id, **kwargs):
        endpoint = unit.new_endpoint_ref(service_id=service_id,
                                         region_id=None,
                                         **kwargs)

        self.catalog_api.create_endpoint(endpoint['id'], endpoint)
        return endpoint
 def new_endpoint(region_id, service_id):
     endpoint = unit.new_endpoint_ref(interface='test',
                                      region_id=region_id,
                                      service_id=service_id,
                                      url='/url')
     self.endpoint.append(PROVIDERS.catalog_api.create_endpoint(
         endpoint['id'], endpoint))
Пример #16
0
 def test_create_endpoint_nonexistent_service(self):
     endpoint = unit.new_endpoint_ref(service_id=uuid.uuid4().hex,
                                      region_id=None)
     self.assertRaises(exception.ValidationError,
                       self.catalog_api.create_endpoint,
                       endpoint['id'],
                       endpoint)
Пример #17
0
 def test_create_endpoint_no_enabled(self):
     """Call ``POST /endpoints``."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id)
     r = self.post('/endpoints', body={'endpoint': ref})
     ref['enabled'] = True
     self.assertValidEndpointResponse(r, ref)
Пример #18
0
    def test_create_endpoint_nonexistent_region(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(service_id=service['id'])
        self.assertRaises(exception.ValidationError,
                          self.catalog_api.create_endpoint, endpoint['id'],
                          endpoint)
Пример #19
0
 def test_create_endpoint_enabled_str_random(self):
     """Call ``POST /endpoints`` with enabled: 'puppies'."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id,
                                 enabled='puppies')
     self.post('/endpoints', body={'endpoint': ref},
               expected_status=http_client.BAD_REQUEST)
Пример #20
0
 def test_create_endpoint_enabled_true(self):
     """Call ``POST /endpoints`` with enabled: true."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id,
                                 enabled=True)
     r = self.post('/endpoints', body={'endpoint': ref})
     self.assertValidEndpointResponse(r, ref)
Пример #21
0
 def test_create_endpoint_no_enabled(self):
     """Call ``POST /endpoints``."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id)
     r = self.post('/endpoints', body={'endpoint': ref})
     ref['enabled'] = True
     self.assertValidEndpointResponse(r, ref)
Пример #22
0
 def test_update_endpoint_nonexistent_region(self):
     dummy_service, enabled_endpoint, dummy_disabled_endpoint = (
         self._create_endpoints())
     new_endpoint = unit.new_endpoint_ref(service_id=uuid.uuid4().hex)
     self.assertRaises(exception.ValidationError,
                       self.catalog_api.update_endpoint,
                       enabled_endpoint['id'],
                       new_endpoint)
Пример #23
0
 def test_create_endpoint_enabled_false(self):
     """Call ``POST /endpoints`` with enabled: false."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id,
                                 enabled=False)
     r = self.post('/endpoints', body={'endpoint': ref})
     self.assertValidEndpointResponse(r, ref)
Пример #24
0
    def _create_random_endpoint(self, interface="public", parent_region_id=None):
        region = self._create_region_with_parent_id(parent_id=parent_region_id)
        service = self._create_random_service()
        ref = unit.new_endpoint_ref(
            service_id=service["id"], interface=interface, region_id=region.result["region"]["id"]
        )

        response = self.post("/endpoints", body={"endpoint": ref})
        return response.json["endpoint"]
Пример #25
0
    def test_endpoint_create_with_valid_url_project_id(self):
        """Create endpoint with valid url should be tested,too."""
        valid_url = 'http://127.0.0.1:8774/v1.1/$(project_id)s'

        ref = unit.new_endpoint_ref(self.service_id,
                                    interface='public',
                                    region_id=self.region_id,
                                    url=valid_url)
        self.post('/endpoints', body={'endpoint': ref})
Пример #26
0
    def test_user_can_get_an_endpoint(self):
        service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                       unit.new_service_ref())
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint)

        with self.test_client() as c:
            c.get('/v3/endpoints/%s' % endpoint['id'], headers=self.headers)
Пример #27
0
    def test_create_endpoint_nonexistent_region(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(service_id=service['id'])
        self.assertRaises(exception.ValidationError,
                          self.catalog_api.create_endpoint,
                          endpoint['id'],
                          endpoint)
Пример #28
0
        def create_endpoint(service_id, region, **kwargs):
            ref = unit.new_endpoint_ref(
                service_id=service_id,
                region_id=region,
                url='http://localhost/%s' % uuid.uuid4().hex,
                **kwargs)

            self.catalog_api.create_endpoint(ref['id'], ref)
            return ref
Пример #29
0
    def test_create_endpoint_region_returns_not_found(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(region_id=uuid.uuid4().hex,
                                         service_id=service['id'])

        self.assertRaises(exception.ValidationError,
                          self.catalog_api.create_endpoint, endpoint['id'],
                          endpoint.copy())
Пример #30
0
    def test_endpoint_create_with_valid_url(self):
        """Create endpoint with valid url should be tested,too."""
        # list one valid url is enough, no need to list too much
        valid_url = 'http://127.0.0.1:8774/v1.1/$(tenant_id)s'

        ref = unit.new_endpoint_ref(self.service_id,
                                    interface='public',
                                    region_id=self.region_id,
                                    url=valid_url)
        self.post('/endpoints', body={'endpoint': ref})
Пример #31
0
    def load_sample_data(self):
        self._populate_default_domain()
        self.domain = unit.new_domain_ref()
        self.domain_id = self.domain['id']
        self.resource_api.create_domain(self.domain_id, self.domain)

        self.project = unit.new_project_ref(domain_id=self.domain_id)
        self.project_id = self.project['id']
        self.resource_api.create_project(self.project_id, self.project)

        self.user = unit.create_user(self.identity_api,
                                     domain_id=self.domain_id)
        self.user_id = self.user['id']

        self.default_domain_project_id = uuid.uuid4().hex
        self.default_domain_project = unit.new_project_ref(
            domain_id=DEFAULT_DOMAIN_ID)
        self.default_domain_project['id'] = self.default_domain_project_id
        self.resource_api.create_project(self.default_domain_project_id,
                                         self.default_domain_project)

        self.default_domain_user = unit.create_user(
            self.identity_api,
            domain_id=DEFAULT_DOMAIN_ID)
        self.default_domain_user_id = self.default_domain_user['id']

        # create & grant policy.json's default role for admin_required
        self.role = unit.new_role_ref(name='admin')
        self.role_id = self.role['id']
        self.role_api.create_role(self.role_id, self.role)
        self.assignment_api.add_role_to_user_and_project(
            self.user_id, self.project_id, self.role_id)
        self.assignment_api.add_role_to_user_and_project(
            self.default_domain_user_id, self.default_domain_project_id,
            self.role_id)
        self.assignment_api.add_role_to_user_and_project(
            self.default_domain_user_id, self.project_id,
            self.role_id)

        self.region = unit.new_region_ref()
        self.region_id = self.region['id']
        self.catalog_api.create_region(self.region)

        self.service = unit.new_service_ref()
        self.service_id = self.service['id']
        self.catalog_api.create_service(self.service_id, self.service.copy())

        self.endpoint = unit.new_endpoint_ref(service_id=self.service_id,
                                              interface='public',
                                              region_id=self.region_id)
        self.endpoint_id = self.endpoint['id']
        self.catalog_api.create_endpoint(self.endpoint_id,
                                         self.endpoint.copy())
        # The server adds 'enabled' and defaults to True.
        self.endpoint['enabled'] = True
Пример #32
0
    def test_create_endpoint_region_returns_not_found(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(region_id=uuid.uuid4().hex,
                                         service_id=service['id'])

        self.assertRaises(exception.ValidationError,
                          self.catalog_api.create_endpoint,
                          endpoint['id'],
                          endpoint.copy())
Пример #33
0
    def test_user_cannot_delete_endpoints(self):
        service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                       unit.new_service_ref())
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint)

        with self.test_client() as c:
            c.delete('/v3/endpoints/%s' % endpoint['id'],
                     headers=self.headers,
                     expected_status_code=http_client.FORBIDDEN)
Пример #34
0
    def test_user_can_get_an_endpoint(self):
        service = PROVIDERS.catalog_api.create_service(
            uuid.uuid4().hex, unit.new_service_ref()
        )
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint
        )

        with self.test_client() as c:
            c.get('/v3/endpoints/%s' % endpoint['id'], headers=self.headers)
Пример #35
0
    def test_v3_catalog_endpoint_filter_enabled(self):
        srv_1 = unit.new_service_ref()
        self.catalog_api.create_service(srv_1['id'], srv_1)
        endpoint_1 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        self.catalog_api.create_endpoint(endpoint_1['id'], endpoint_1)
        endpoint_2 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        self.catalog_api.create_endpoint(endpoint_2['id'], endpoint_2)
        # create endpoint-project association.
        self.catalog_api.add_endpoint_to_project(endpoint_1['id'],
                                                 self.tenant_bar['id'])

        catalog_ref = self.catalog_api.get_v3_catalog(uuid.uuid4().hex,
                                                      self.tenant_bar['id'])
        self.assertThat(catalog_ref, matchers.HasLength(1))
        self.assertThat(catalog_ref[0]['endpoints'], matchers.HasLength(1))
        # the endpoint is that defined in the endpoint-project association.
        self.assertEqual(endpoint_1['id'],
                         catalog_ref[0]['endpoints'][0]['id'])
Пример #36
0
    def _create_random_endpoint(self,
                                interface='public',
                                parent_region_id=None):
        region = self._create_region_with_parent_id(parent_id=parent_region_id)
        service = self._create_random_service()
        ref = unit.new_endpoint_ref(service_id=service['id'],
                                    interface=interface,
                                    region_id=region.result['region']['id'])

        response = self.post('/endpoints', body={'endpoint': ref})
        return response.json['endpoint']
Пример #37
0
 def test_update_endpoint(self):
     """Call ``PATCH /endpoints/{endpoint_id}``."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id)
     del ref['id']
     r = self.patch('/endpoints/%(endpoint_id)s' %
                    {'endpoint_id': self.endpoint_id},
                    body={'endpoint': ref})
     ref['enabled'] = True
     self.assertValidEndpointResponse(r, ref)
 def setUp(self):
     super(EndpointPolicyTestCase, self).setUp()
     self.policy = unit.new_policy_ref()
     self.policy_api.create_policy(self.policy['id'], self.policy)
     self.service = unit.new_service_ref()
     self.catalog_api.create_service(self.service['id'], self.service)
     self.endpoint = unit.new_endpoint_ref(self.service['id'], enabled=True,
                                           interface='public',
                                           region_id=self.region_id)
     self.catalog_api.create_endpoint(self.endpoint['id'], self.endpoint)
     self.region = unit.new_region_ref()
     self.catalog_api.create_region(self.region)
 def setUp(self):
     super(EndpointPolicyTestCase, self).setUp()
     self.policy = unit.new_policy_ref()
     self.policy_api.create_policy(self.policy['id'], self.policy)
     self.service = unit.new_service_ref()
     self.catalog_api.create_service(self.service['id'], self.service)
     self.endpoint = unit.new_endpoint_ref(self.service['id'], enabled=True,
                                           interface='public',
                                           region_id=self.region_id)
     self.catalog_api.create_endpoint(self.endpoint['id'], self.endpoint)
     self.region = unit.new_region_ref()
     self.catalog_api.create_region(self.region)
Пример #40
0
    def test_v3_catalog_endpoint_filter_enabled(self):
        srv_1 = unit.new_service_ref()
        self.catalog_api.create_service(srv_1['id'], srv_1)
        endpoint_1 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        self.catalog_api.create_endpoint(endpoint_1['id'], endpoint_1)
        endpoint_2 = unit.new_endpoint_ref(service_id=srv_1['id'],
                                           region_id=None)
        self.catalog_api.create_endpoint(endpoint_2['id'], endpoint_2)
        # create endpoint-project association.
        self.catalog_api.add_endpoint_to_project(
            endpoint_1['id'],
            self.tenant_bar['id'])

        catalog_ref = self.catalog_api.get_v3_catalog(uuid.uuid4().hex,
                                                      self.tenant_bar['id'])
        self.assertThat(catalog_ref, matchers.HasLength(1))
        self.assertThat(catalog_ref[0]['endpoints'], matchers.HasLength(1))
        # the endpoint is that defined in the endpoint-project association.
        self.assertEqual(endpoint_1['id'],
                         catalog_ref[0]['endpoints'][0]['id'])
Пример #41
0
 def test_update_endpoint(self):
     """Call ``PATCH /endpoints/{endpoint_id}``."""
     ref = unit.new_endpoint_ref(service_id=self.service_id,
                                 interface='public',
                                 region_id=self.region_id)
     del ref['id']
     r = self.patch(
         '/endpoints/%(endpoint_id)s' % {
             'endpoint_id': self.endpoint_id},
         body={'endpoint': ref})
     ref['enabled'] = True
     self.assertValidEndpointResponse(r, ref)
Пример #42
0
    def test_create_endpoint_region_returns_not_found(self):
        service = {
            "id": uuid.uuid4().hex,
            "type": uuid.uuid4().hex,
            "name": uuid.uuid4().hex,
            "description": uuid.uuid4().hex,
        }
        self.catalog_api.create_service(service["id"], service.copy())

        endpoint = unit.new_endpoint_ref(region_id=uuid.uuid4().hex, service_id=service["id"])

        self.assertRaises(exception.ValidationError, self.catalog_api.create_endpoint, endpoint["id"], endpoint.copy())
Пример #43
0
    def test_list_endpoints(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        expected_ids = set([uuid.uuid4().hex for _ in range(3)])
        for endpoint_id in expected_ids:
            endpoint = unit.new_endpoint_ref(service_id=service['id'],
                                             id=endpoint_id,
                                             region_id=None)
            self.catalog_api.create_endpoint(endpoint['id'], endpoint)

        endpoints = self.catalog_api.list_endpoints()
        self.assertEqual(expected_ids, set(e['id'] for e in endpoints))
Пример #44
0
    def test_catalog_ignored_malformed_urls(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        malformed_url = "http://192.168.1.104:8774/v2/$(tenant)s"
        endpoint = unit.new_endpoint_ref(service_id=service['id'],
                                         url=malformed_url,
                                         region_id=None)
        self.catalog_api.create_endpoint(endpoint['id'], endpoint.copy())

        # NOTE(dstanek): there are no valid URLs, so nothing is in the catalog
        catalog = self.catalog_api.get_catalog('fake-user', 'fake-tenant')
        self.assertEqual({}, catalog)
Пример #45
0
    def test_user_can_update_endpoints(self):
        service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                       unit.new_service_ref())
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint)

        update = {'endpoint': {'interface': 'internal'}}

        with self.test_client() as c:
            c.patch('/v3/endpoints/%s' % endpoint['id'],
                    json=update,
                    headers=self.headers)
Пример #46
0
    def test_user_cannot_delete_endpoints(self):
        service = PROVIDERS.catalog_api.create_service(
            uuid.uuid4().hex, unit.new_service_ref()
        )
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint
        )

        with self.test_client() as c:
            c.delete(
                '/v3/endpoints/%s' % endpoint['id'], headers=self.headers,
                expected_status_code=http_client.FORBIDDEN
            )
Пример #47
0
    def test_user_can_delete_policy_association_for_endpoint(self):
        policy = unit.new_policy_ref()
        policy = PROVIDERS.policy_api.create_policy(policy['id'], policy)
        service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                       unit.new_service_ref())
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint)

        with self.test_client() as c:
            c.delete('/v3/policies/%s/OS-ENDPOINT-POLICY/endpoints/%s' %
                     (policy['id'], endpoint['id']),
                     headers=self.headers,
                     expected_status_code=http_client.NO_CONTENT)
Пример #48
0
 def test_user_can_get_policy_for_endpoint(self):
     policy = unit.new_policy_ref()
     policy = PROVIDERS.policy_api.create_policy(policy['id'], policy)
     service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                    unit.new_service_ref())
     endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
     endpoint = PROVIDERS.catalog_api.create_endpoint(
         endpoint['id'], endpoint)
     PROVIDERS.endpoint_policy_api.create_policy_association(
         policy['id'], endpoint['id'])
     with self.test_client() as c:
         c.get('/v3/endpoints/%s/OS-ENDPOINT-POLICY/policy' %
               (endpoint['id']),
               headers=self.headers)
Пример #49
0
    def _create_random_endpoint(self, interface='public',
                                parent_region_id=None):
        region = self._create_region_with_parent_id(
            parent_id=parent_region_id)
        service = self._create_random_service()
        ref = unit.new_endpoint_ref(
            service_id=service['id'],
            interface=interface,
            region_id=region.result['region']['id'])

        response = self.post(
            '/endpoints',
            body={'endpoint': ref})
        return response.json['endpoint']
Пример #50
0
    def test_user_cannot_list_endpoints(self):
        # Domain and project users should access this information through the
        # token response they get when they authenticate for or validate a
        # token.
        service = PROVIDERS.catalog_api.create_service(uuid.uuid4().hex,
                                                       unit.new_service_ref())
        endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
        endpoint = PROVIDERS.catalog_api.create_endpoint(
            endpoint['id'], endpoint)

        with self.test_client() as c:
            c.get('/v3/endpoints',
                  headers=self.headers,
                  expected_status_code=http.client.FORBIDDEN)
Пример #51
0
    def test_get_catalog_with_empty_public_url(self):
        service = unit.new_service_ref()
        self.catalog_api.create_service(service['id'], service)

        endpoint = unit.new_endpoint_ref(url='', service_id=service['id'],
                                         region_id=None)
        self.catalog_api.create_endpoint(endpoint['id'], endpoint.copy())

        catalog = self.catalog_api.get_catalog('user', 'tenant')
        catalog_endpoint = catalog[endpoint['region_id']][service['type']]
        self.assertEqual(service['name'], catalog_endpoint['name'])
        self.assertEqual(endpoint['id'], catalog_endpoint['id'])
        self.assertEqual('', catalog_endpoint['publicURL'])
        self.assertIsNone(catalog_endpoint.get('adminURL'))
        self.assertIsNone(catalog_endpoint.get('internalURL'))