"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/protection/v3/test_endpoint_group.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

test_endpoint_group.py  (keystone-16.0.1):test_endpoint_group.py  (keystone-17.0.0)
skipping to change at line 15 skipping to change at line 15
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import uuid import uuid
from six.moves import http_client import http.client
from keystone.common import provider_api from keystone.common import provider_api
import keystone.conf import keystone.conf
from keystone.tests.common import auth as common_auth from keystone.tests.common import auth as common_auth
from keystone.tests import unit from keystone.tests import unit
from keystone.tests.unit import base_classes from keystone.tests.unit import base_classes
from keystone.tests.unit import ksfixtures from keystone.tests.unit import ksfixtures
CONF = keystone.conf.CONF CONF = keystone.conf.CONF
PROVIDERS = provider_api.ProviderAPIs PROVIDERS = provider_api.ProviderAPIs
class _SystemUserEndpointGroupsTests(object): class _SystemUserEndpointGroupsTests(object):
"""Common default functionality for all system users.""" """Common default functionality for all system users."""
def test_user_can_list_endpoint_groups(self): def test_user_can_list_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
r = c.get('/v3/OS-EP-FILTER/endpoint_groups', headers=self.headers) r = c.get('/v3/OS-EP-FILTER/endpoint_groups', headers=self.headers)
endpoint_groups = [] endpoint_groups = []
for endpoint_group in r.json['endpoint_groups']: for endpoint_group in r.json['endpoint_groups']:
endpoint_groups.append(endpoint_group['id']) endpoint_groups.append(endpoint_group['id'])
self.assertIn(endpoint_group['id'], endpoint_groups) self.assertIn(endpoint_group['id'], endpoint_groups)
def test_user_can_get_an_endpoint_group(self): def test_user_can_get_an_endpoint_group(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], c.get('/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
headers=self.headers) headers=self.headers)
def test_user_can_list_projects_associated_with_endpoint_groups(self): def test_user_can_list_projects_associated_with_endpoint_groups(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
r = c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects' r = c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects'
% endpoint_group['id'], headers=self.headers) % endpoint_group['id'], headers=self.headers)
projects = [] projects = []
for project in r.json['projects']: for project in r.json['projects']:
skipping to change at line 81 skipping to change at line 84
self.assertIn(project['id'], projects) self.assertIn(project['id'], projects)
def test_user_can_list_endpoints_associated_with_endpoint_groups(self): def test_user_can_list_endpoints_associated_with_endpoint_groups(self):
service = PROVIDERS.catalog_api.create_service( service = PROVIDERS.catalog_api.create_service(
uuid.uuid4().hex, unit.new_service_ref() uuid.uuid4().hex, unit.new_service_ref()
) )
endpoint = unit.new_endpoint_ref(service['id'], region_id=None) endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
endpoint = PROVIDERS.catalog_api.create_endpoint( endpoint = PROVIDERS.catalog_api.create_endpoint(
endpoint['id'], endpoint endpoint['id'], endpoint
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
r = c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/endpoints' r = c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/endpoints'
% endpoint_group['id'], % endpoint_group['id'],
headers=self.headers) headers=self.headers)
endpoints = [] endpoints = []
for endpoint in r.json['endpoints']: for endpoint in r.json['endpoints']:
endpoints.append(endpoint['id']) endpoints.append(endpoint['id'])
self.assertIn(endpoint['id'], endpoints) self.assertIn(endpoint['id'], endpoints)
def test_user_can_get_endpoints_associated_with_endpoint_groups(self): def test_user_can_get_endpoints_associated_with_endpoint_groups(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers) headers=self.headers)
def test_user_can_list_endpoint_groups_with_their_projects(self): def test_user_can_list_endpoint_groups_with_their_projects(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
r = c.get('/v3/OS-EP-FILTER/projects/%s/endpoint_groups' r = c.get('/v3/OS-EP-FILTER/projects/%s/endpoint_groups'
% project['id'], % project['id'],
headers=self.headers) headers=self.headers)
endpoint_groups = [] endpoint_groups = []
skipping to change at line 146 skipping to change at line 152
'endpoint_group': { 'endpoint_group': {
'id': uuid.uuid4().hex, 'id': uuid.uuid4().hex,
'description': uuid.uuid4().hex, 'description': uuid.uuid4().hex,
'filters': {'interface': 'public'}, 'filters': {'interface': 'public'},
'name': uuid.uuid4().hex 'name': uuid.uuid4().hex
} }
} }
with self.test_client() as c: with self.test_client() as c:
c.post( c.post(
'/v3/OS-EP-FILTER/endpoint_groups', json=create, headers=self.he '/v3/OS-EP-FILTER/endpoint_groups', json=create,
aders, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_endpoint_groups(self): def test_user_cannot_update_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
update = {'endpoint_group': {'filters': {'interface': 'internal'}}} update = {'endpoint_group': {'filters': {'interface': 'internal'}}}
with self.test_client() as c: with self.test_client() as c:
c.patch( c.patch(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], js '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
on=update, json=update,
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_endpoint_groups(self): def test_user_cannot_delete_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], he '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
aders=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_add_endpoint_group_to_project(self): def test_user_cannot_add_endpoint_group_to_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_cannot_remove_endpoint_group_from_project(self): def test_cannot_remove_endpoint_group_from_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class _DomainAndProjectUserEndpointGroupTests(object): class _DomainAndProjectUserEndpointGroupTests(object):
def test_user_cannot_list_endpoint_groups(self): def test_user_cannot_list_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
PROVIDERS.catalog_api.create_endpoint_group( PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups', headers=self.headers, c.get('/v3/OS-EP-FILTER/endpoint_groups', headers=self.headers,
expected_status_code=http_client.FORBIDDEN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_get_an_endpoint_group(self): def test_user_cannot_get_an_endpoint_group(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], c.get('/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
headers=self.headers, expected_status_code=http_client.FORBIDD headers=self.headers,
EN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_list_projects_associated_with_endpoint_groups(self): def test_user_cannot_list_projects_associated_with_endpoint_groups(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects' % endpoint_grou c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects'
p['id'], % endpoint_group['id'],
headers=self.headers, expected_status_code=http_client.FORBIDD headers=self.headers,
EN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_list_endpoints_associated_with_endpoint_groups(self): def test_user_cannot_list_endpoints_associated_with_endpoint_groups(self):
service = PROVIDERS.catalog_api.create_service( service = PROVIDERS.catalog_api.create_service(
uuid.uuid4().hex, unit.new_service_ref() uuid.uuid4().hex, unit.new_service_ref()
) )
endpoint = unit.new_endpoint_ref(service['id'], region_id=None) endpoint = unit.new_endpoint_ref(service['id'], region_id=None)
endpoint = PROVIDERS.catalog_api.create_endpoint( endpoint = PROVIDERS.catalog_api.create_endpoint(
endpoint['id'], endpoint endpoint['id'], endpoint
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/endpoints' % endpoint_gro c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/endpoints'
up['id'], % endpoint_group['id'],
headers=self.headers, expected_status_code=http_client.FORBIDD headers=self.headers,
EN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_get_endpoints_associated_with_endpoint_groups(self): def test_user_cannot_get_endpoints_associated_with_endpoint_groups(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.get('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers, expected_status_code=http_client.FORBIDD headers=self.headers,
EN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_list_endpoint_groups_with_their_projects(self): def test_user_cannot_list_endpoint_groups_with_their_projects(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
c.get('/v3/OS-EP-FILTER/projects/%s/endpoint_groups' % project['id'] c.get('/v3/OS-EP-FILTER/projects/%s/endpoint_groups'
, % project['id'],
headers=self.headers, expected_status_code=http_client.FORBIDD headers=self.headers,
EN) expected_status_code=http.client.FORBIDDEN)
def test_user_cannot_create_endpoint_groups(self): def test_user_cannot_create_endpoint_groups(self):
create = { create = {
'endpoint_group': { 'endpoint_group': {
'id': uuid.uuid4().hex, 'id': uuid.uuid4().hex,
'description': uuid.uuid4().hex, 'description': uuid.uuid4().hex,
'filters': {'interface': 'public'}, 'filters': {'interface': 'public'},
'name': uuid.uuid4().hex 'name': uuid.uuid4().hex
} }
} }
with self.test_client() as c: with self.test_client() as c:
c.post( c.post(
'/v3/OS-EP-FILTER/endpoint_groups', json=create, headers=self.he '/v3/OS-EP-FILTER/endpoint_groups', json=create,
aders, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_endpoint_groups(self): def test_user_cannot_update_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
update = {'endpoint_group': {'filters': {'interface': 'internal'}}} update = {'endpoint_group': {'filters': {'interface': 'internal'}}}
with self.test_client() as c: with self.test_client() as c:
c.patch( c.patch(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], js '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
on=update, json=update,
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_endpoint_groups(self): def test_user_cannot_delete_endpoint_groups(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], he '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
aders=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_add_endpoint_group_to_project(self): def test_user_cannot_add_endpoint_group_to_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_cannot_remove_endpoint_group_from_project(self): def test_cannot_remove_endpoint_group_from_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class SystemReaderTests(base_classes.TestCaseWithBootstrap, class SystemReaderTests(base_classes.TestCaseWithBootstrap,
common_auth.AuthTestMixin, common_auth.AuthTestMixin,
_SystemUserEndpointGroupsTests, _SystemUserEndpointGroupsTests,
_SystemReaderAndMemberUserEndpointGroupsTests): _SystemReaderAndMemberUserEndpointGroupsTests):
def setUp(self): def setUp(self):
super(SystemReaderTests, self).setUp() super(SystemReaderTests, self).setUp()
self.loadapp() self.loadapp()
skipping to change at line 478 skipping to change at line 512
'endpoint_group': { 'endpoint_group': {
'id': uuid.uuid4().hex, 'id': uuid.uuid4().hex,
'description': uuid.uuid4().hex, 'description': uuid.uuid4().hex,
'filters': {'interface': 'public'}, 'filters': {'interface': 'public'},
'name': uuid.uuid4().hex 'name': uuid.uuid4().hex
} }
} }
with self.test_client() as c: with self.test_client() as c:
c.post( c.post(
'/v3/OS-EP-FILTER/endpoint_groups', json=create, headers=self.he '/v3/OS-EP-FILTER/endpoint_groups', json=create,
aders) headers=self.headers)
def test_user_can_update_endpoint_group(self): def test_user_can_update_endpoint_group(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
update = {'endpoint_group': {'filters': {'interface': 'internal'}}} update = {'endpoint_group': {'filters': {'interface': 'internal'}}}
with self.test_client() as c: with self.test_client() as c:
c.patch( c.patch(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], js '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
on=update, json=update,
headers=self.headers) headers=self.headers)
def test_user_can_delete_endpoint_group(self): def test_user_can_delete_endpoint_group(self):
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'], he '/v3/OS-EP-FILTER/endpoint_groups/%s' % endpoint_group['id'],
aders=self.headers headers=self.headers
) )
def test_user_add_endpoint_group_to_project(self): def test_user_add_endpoint_group_to_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
with self.test_client() as c: with self.test_client() as c:
c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.put('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers headers=self.headers
) )
def test_remove_endpoint_group_from_project(self): def test_remove_endpoint_group_from_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref( uuid.uuid4().hex, unit.new_project_ref(
domain_id=CONF.identity.default_domain_id domain_id=CONF.identity.default_domain_id
) )
) )
endpoint_group = unit.new_endpoint_group_ref(filters={'interface': 'publ endpoint_group = unit.new_endpoint_group_ref(
ic'}) filters={'interface': 'public'})
endpoint_group = PROVIDERS.catalog_api.create_endpoint_group( endpoint_group = PROVIDERS.catalog_api.create_endpoint_group(
endpoint_group['id'], endpoint_group endpoint_group['id'], endpoint_group
) )
PROVIDERS.catalog_api.add_endpoint_group_to_project( PROVIDERS.catalog_api.add_endpoint_group_to_project(
endpoint_group['id'], project['id']) endpoint_group['id'], project['id'])
with self.test_client() as c: with self.test_client() as c:
c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s' c.delete('/v3/OS-EP-FILTER/endpoint_groups/%s/projects/%s'
% (endpoint_group['id'], project['id']), % (endpoint_group['id'], project['id']),
headers=self.headers headers=self.headers
) )
 End of changes. 46 change blocks. 
94 lines changed or deleted 94 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)