def test_list_endpoint_groups(self):
        endpoint_group_one = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group_one)

        endpoint_group_two = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group_two)

        endpoint_groups = self.client.endpoint_groups.list()

        # All endpoints are valid
        for endpoint_group in endpoint_groups:
            self.check_endpoint_group(endpoint_group)

        self.assertIn(endpoint_group_one.entity, endpoint_groups)
        self.assertIn(endpoint_group_two.entity, endpoint_groups)
    def test_check_endpoint_group(self):
        endpoint_group = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group)

        self.client.endpoint_groups.check(endpoint_group.id)
        self.assertRaises(http.NotFound, self.client.endpoint_groups.check,
                          uuid.uuid4().hex)
    def test_get_endpoint_group(self):
        endpoint_group = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group)

        endpoint_ret = self.client.endpoint_groups.get(endpoint_group.id)
        self.check_endpoint_group(endpoint_ret, endpoint_group.ref)

        self.assertRaises(http.NotFound, self.client.endpoint_groups.get,
                          uuid.uuid4().hex)
    def test_add_endpoint_group_to_project(self):
        project = fixtures.Project(self.client)
        endpoint_group = fixtures.EndpointGroup(self.client)
        self.useFixture(project)
        self.useFixture(endpoint_group)

        self.client.endpoint_filter.add_endpoint_group_to_project(
            endpoint_group, project)
        self.client.endpoint_filter.check_endpoint_group_in_project(
            endpoint_group, project)
    def setUp(self):
        super(EndpointFiltersTestCase, self).setUp()

        self.project = fixtures.Project(self.client)
        self.endpoint_group = fixtures.EndpointGroup(self.client)
        self.useFixture(self.project)
        self.useFixture(self.endpoint_group)

        self.client.endpoint_filter.add_endpoint_group_to_project(
            self.endpoint_group, self.project)
    def test_list_endpoint_groups_for_project(self):
        endpoint_group_two = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group_two)
        self.client.endpoint_filter.add_endpoint_group_to_project(
            endpoint_group_two, self.project)

        endpoint_groups = (
            self.client.endpoint_filter.list_endpoint_groups_for_project(
                self.project))

        for endpoint_group in endpoint_groups:
            self.check_endpoint_group(endpoint_group)

        self.assertIn(self.endpoint_group.entity, endpoint_groups)
        self.assertIn(endpoint_group_two.entity, endpoint_groups)
    def test_update_endpoint_group(self):
        endpoint_group = fixtures.EndpointGroup(self.client)
        self.useFixture(endpoint_group)

        new_name = fixtures.RESOURCE_NAME_PREFIX + uuid.uuid4().hex
        new_filters = {'interface': 'public'}
        new_description = uuid.uuid4().hex

        endpoint_group_ret = self.client.endpoint_groups.update(
            endpoint_group,
            name=new_name,
            filters=new_filters,
            description=new_description)

        endpoint_group.ref.update({'name': new_name, 'filters': new_filters,
                                   'description': new_description})
        self.check_endpoint_group(endpoint_group_ret, endpoint_group.ref)