Skip to content

Commit

Permalink
add svc perms check (issue #74-2, PR #73)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault-crim committed Jul 6, 2018
1 parent 42bd385 commit 0932ed9
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions tests/test_magpie_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def test_GetUsers(self):
check_val_is_in(self.usr, json_body['user_names']) # current test user in users

@pytest.mark.users
@pytest.mark.defaults
def test_ValidateDefaultUsers(self):
resp = test_request(self.url, 'GET', '/users', headers=self.json_headers, cookies=self.cookies)
json_body = check_response_basic_info(resp, 200)
Expand Down Expand Up @@ -294,6 +295,7 @@ def test_GetUserInheritedResources(self):
check_val_type(svc_dict['resources'], dict)

@pytest.mark.users
@pytest.mark.defaults
def test_ValidateDefaultGroups(self):
resp = test_request(self.url, 'GET', '/groups', headers=self.json_headers, cookies=self.cookies)
json_body = check_response_basic_info(resp, 200)
Expand Down Expand Up @@ -356,6 +358,18 @@ def setup_DeleteTestServiceResource(cls):
check_val_equal(resp.status_code, 200)
cls.setup_CheckNonExistingTestResource()

@classmethod
def setup_GetRegisteredServicesList(cls):
resp = test_request(cls.url, 'GET', '/services', headers=cls.json_headers, cookies=cls.cookies)
json_body = check_response_basic_info(resp, 200)

# prepare a flat list of registered services
services_list = list()
for svc_type in json_body['services']:
services_of_type = json_body['services'][svc_type]
services_list.extend(services_of_type.values())
return services_list

@pytest.mark.services
def test_GetServiceResources(self):
route = '/services/{svc}/resources'.format(svc=self.test_service_name)
Expand All @@ -379,6 +393,20 @@ def test_GetServiceResources(self):
check_val_type(svc_dict['permission_names'], list)
check_resource_children(svc_dict['resources'], svc_dict['resource_id'], svc_dict['resource_id'])

@pytest.mark.services
def test_GetServicePermissions(self):
services_list = self.setup_GetRegisteredServicesList()

for svc in services_list:
svc_name = svc['service_name']
service_perms = service_type_dict[svc['service_type']].permission_names
route = '/services/{svc}/permissions'.format(svc=svc_name)
resp = test_request(self.url, 'GET', route, headers=self.json_headers, cookies=self.cookies)
json_body = check_response_basic_info(resp, 200)
check_val_is_in('permission_names', json_body)
check_val_type(json_body['permission_names'], list)
check_all_equal(json_body['permission_names'], service_perms)

@pytest.mark.services
def test_PostServiceResources_DirectResource_NoParentID(self):
resources_prior = self.setup_GetExistingTestServiceDirectResources()
Expand Down Expand Up @@ -457,15 +485,9 @@ def test_PostServiceResources_DirectResource_Conflict(self):
paramValue=self.test_resource_name, paramName=u'resource_name')

@pytest.mark.services
@pytest.mark.defaults
def test_ValidateDefaultServiceProviders(self):
resp = test_request(self.url, 'GET', '/services', headers=self.json_headers, cookies=self.cookies)
json_body = check_response_basic_info(resp, 200)

# prepare a flat list of registered services
services_list = list()
for svc_type in json_body['services']:
services_of_type = json_body['services'][svc_type]
services_list.extend(services_of_type.values())
services_list = self.setup_GetRegisteredServicesList()

# ensure that registered services information are all matching the providers in config file
# ignore registered services not from providers as their are not explicitly required from the config
Expand Down

0 comments on commit 0932ed9

Please sign in to comment.