From 6c2189da40889c55fe28bf1cc541b0ed06e67f93 Mon Sep 17 00:00:00 2001 From: index-git Date: Tue, 19 Dec 2023 12:11:49 +0100 Subject: [PATCH] Negative tests of access rights application on GeoServer --- .../test_access_rights_application.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/dynamic_data/publications/access_rights/test_access_rights_application.py b/tests/dynamic_data/publications/access_rights/test_access_rights_application.py index 2cd670f97..5d5e5fd7d 100644 --- a/tests/dynamic_data/publications/access_rights/test_access_rights_application.py +++ b/tests/dynamic_data/publications/access_rights/test_access_rights_application.py @@ -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: @@ -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) @@ -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) as exc_info: + rest_method(**rest_args)