Пример #1
0
    def test_update_endpoint(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        new_service = fixtures.Service(self.client)
        self.useFixture(new_service)

        new_region = fixtures.Region(self.client)
        self.useFixture(new_region)

        endpoint = fixtures.Endpoint(self.client, service.id, 'public')
        self.useFixture(endpoint)

        new_url = 'http://' + uuid.uuid4().hex
        new_interface = 'internal'
        new_enabled = False

        endpoint_ret = self.client.endpoints.update(endpoint.id,
                                                    service=new_service.id,
                                                    url=new_url,
                                                    interface=new_interface,
                                                    enabled=new_enabled,
                                                    region=new_region.id)

        endpoint.ref.update({
            'service': new_service.id,
            'url': new_url,
            'interface': new_interface,
            'enabled': new_enabled,
            'region': new_region.entity
        })
        self.check_endpoint(endpoint_ret, endpoint.ref)
Пример #2
0
    def test_list_services(self):
        service_one = fixtures.Service(self.client)
        self.useFixture(service_one)

        service_two = fixtures.Service(self.client)
        self.useFixture(service_two)

        services = self.client.services.list()

        # All services are valid
        for service in services:
            self.check_service(service)

        self.assertIn(service_one.entity, services)
        self.assertIn(service_two.entity, services)
Пример #3
0
    def test_list_endpoints(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        region = fixtures.Region(self.client)
        self.useFixture(region)

        endpoint_one = fixtures.Endpoint(self.client,
                                         service.id,
                                         'public',
                                         region=region.id)
        self.useFixture(endpoint_one)

        endpoint_two = fixtures.Endpoint(self.client,
                                         service.id,
                                         'admin',
                                         region=region.id)
        self.useFixture(endpoint_two)

        endpoint_three = fixtures.Endpoint(self.client,
                                           service.id,
                                           'internal',
                                           region=region.id)
        self.useFixture(endpoint_three)

        endpoints = self.client.endpoints.list()

        # All endpoints are valid
        for endpoint in endpoints:
            self.check_endpoint(endpoint)

        self.assertIn(endpoint_one.entity, endpoints)
        self.assertIn(endpoint_two.entity, endpoints)
        self.assertIn(endpoint_three.entity, endpoints)
Пример #4
0
    def test_get_endpoint(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        interfaces = ['public', 'admin', 'internal']
        for interface in interfaces:
            endpoint = fixtures.Endpoint(self.client, service.id, interface)
            self.useFixture(endpoint)
            endpoint_ret = self.client.endpoints.get(endpoint.id)
            # All endpoints are valid
            self.check_endpoint(endpoint_ret, endpoint.ref)
Пример #5
0
    def test_delete_endpoint(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)
        endpoint = self.client.endpoints.create(service=service.id,
                                                url='http://' +
                                                uuid.uuid4().hex,
                                                enabled=True,
                                                interface='public')

        self.client.endpoints.delete(endpoint.id)
        self.assertRaises(http.NotFound, self.client.endpoints.get,
                          endpoint.id)
Пример #6
0
    def test_create_endpoint(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        endpoint_ref = {
            'service': service.id,
            'url': 'http://' + uuid.uuid4().hex,
            'enabled': True,
            'interface': 'public'
        }
        endpoint = self.client.endpoints.create(**endpoint_ref)

        self.addCleanup(self.client.endpoints.delete, endpoint)
        self.check_endpoint(endpoint, endpoint_ref)
Пример #7
0
    def test_update_service(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        new_name = fixtures.RESOURCE_NAME_PREFIX + uuid.uuid4().hex
        new_type = uuid.uuid4().hex
        new_enabled = False
        new_description = uuid.uuid4().hex

        service_ret = self.client.services.update(service.id,
                                                  name=new_name,
                                                  type=new_type,
                                                  enabled=new_enabled,
                                                  description=new_description)

        service.ref.update({
            'name': new_name,
            'type': new_type,
            'enabled': new_enabled,
            'description': new_description
        })
        self.check_service(service_ret, service.ref)
Пример #8
0
    def test_get_service(self):
        service = fixtures.Service(self.client)
        self.useFixture(service)

        service_ret = self.client.services.get(service.id)
        self.check_service(service_ret, service.ref)