Skip to content

Commit

Permalink
Negative tests of access rights application on GeoServer
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Dec 19, 2023
1 parent 246a990 commit d08c1fa
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ def generate_positive_geoserver_test_cases(publications_user_can_read):
return tc_list


def generate_geoserver_negative_test_cases(publications_user_can_read, publication_all):
tc_list = []
for user, available_publications in publications_user_can_read.items():
for publication in publication_all:
if publication not in available_publications and publication.type == process_client.LAYER_TYPE:
add_publication_test_cases_to_list(tc_list, publication, user, GEOSERVER_METHODS_TO_TEST)
return tc_list


@pytest.mark.timeout(60)
@pytest.mark.usefixtures('ensure_layman_module', 'oauth2_provider_mock')
class TestAccessRights:
Expand Down Expand Up @@ -216,6 +225,7 @@ class TestAccessRights:
'test_single_positive': generate_positive_test_cases(PUBLICATIONS_BY_USER) + generate_positive_geoserver_test_cases(PUBLICATIONS_BY_USER),
'test_single_negative': generate_negative_test_cases(PUBLICATIONS_BY_USER, PUBLICATIONS),
'test_multiendpoint': generate_multiendpoint_test_cases(PUBLICATIONS_BY_USER, OWNER),
'test_geoserver_negative': generate_geoserver_negative_test_cases(PUBLICATIONS_BY_USER, PUBLICATIONS),
}

@pytest.fixture(scope='class', autouse=True)
Expand Down Expand Up @@ -254,3 +264,7 @@ def test_multiendpoint(self, rest_method, rest_args, params):
result = rest_method(**rest_args)
result_publications = [(publ['workspace'], f"layman.{publ['publication_type']}", publ['name']) for publ in result]
assert result_publications == params['exp_publications']

def test_geoserver_negative(self, rest_method, rest_args, ):
with pytest.raises(AssertionError):
rest_method(**rest_args)

0 comments on commit d08c1fa

Please sign in to comment.