From 5c9775d643ce041eb822c0e643e539459b0b85e2 Mon Sep 17 00:00:00 2001 From: index-git Date: Thu, 14 Dec 2023 16:55:16 +0100 Subject: [PATCH] Remove role and role-user operations on GeoServer --- src/geoserver/geoserver_test.py | 38 -------------------------- src/layman/__init__.py | 3 -- src/layman/layer/geoserver/__init__.py | 8 ------ src/layman/upgrade/__init__.py | 1 + 4 files changed, 1 insertion(+), 49 deletions(-) diff --git a/src/geoserver/geoserver_test.py b/src/geoserver/geoserver_test.py index a803a0e57..2716a0e52 100644 --- a/src/geoserver/geoserver_test.py +++ b/src/geoserver/geoserver_test.py @@ -24,29 +24,6 @@ def gs_user(): assert gs_util.delete_user(TEST_USER, GS_AUTH) -@pytest.fixture() -def gs_role(): - roles = gs_util.get_roles(GS_AUTH) - assert TEST_ROLE not in roles - assert gs_util.ensure_role(TEST_ROLE, GS_AUTH) - yield TEST_ROLE - assert gs_util.delete_role(TEST_ROLE, GS_AUTH) - - -def test_role_management(): - init_roles = gs_util.get_roles(GS_AUTH) - new_role = TEST_ROLE - assert new_role not in init_roles - assert gs_util.ensure_role(new_role, GS_AUTH) - roles = gs_util.get_roles(GS_AUTH) - assert new_role in roles - assert len(init_roles) + 1 == len(roles) - assert gs_util.delete_role(new_role, GS_AUTH) - roles = gs_util.get_roles(GS_AUTH) - assert new_role not in roles - assert len(init_roles) == len(roles) - - def test_user_management(): init_usernames = gs_util.get_usernames(GS_AUTH) new_user = TEST_USER @@ -62,21 +39,6 @@ def test_user_management(): assert len(init_usernames) == len(usernames) -def test_user_role_management(gs_user, gs_role): - user = gs_user[0] - init_user_roles = gs_util.get_user_roles(user, GS_AUTH) - role = gs_role - assert role not in init_user_roles - assert gs_util.ensure_user_role(user, role, GS_AUTH) - user_roles = gs_util.get_user_roles(user, GS_AUTH) - assert role in user_roles - assert len(init_user_roles) + 1 == len(user_roles) - assert gs_util.delete_user_role(user, role, GS_AUTH) - user_roles = gs_util.get_user_roles(user, GS_AUTH) - assert role not in user_roles - assert len(init_user_roles) == len(user_roles) - - @pytest.mark.parametrize('service', gs_util.SERVICE_TYPES) def test_service_srs_list_management(service): init_service_epsg_codes = gs_util.get_service_srs_list(service, GS_AUTH) diff --git a/src/layman/__init__.py b/src/layman/__init__.py index a76a05daa..e5c578b7f 100644 --- a/src/layman/__init__.py +++ b/src/layman/__init__.py @@ -86,10 +86,7 @@ logger.info(f'Adjusting GeoServer roles') if settings.GEOSERVER_ADMIN_AUTH: - gs_util.ensure_role(settings.LAYMAN_GS_ROLE, settings.GEOSERVER_ADMIN_AUTH) gs_util.ensure_user(settings.LAYMAN_GS_USER, settings.LAYMAN_GS_PASSWORD, settings.GEOSERVER_ADMIN_AUTH) - gs_util.ensure_user_role(settings.LAYMAN_GS_USER, 'ADMIN', settings.GEOSERVER_ADMIN_AUTH) - gs_util.ensure_user_role(settings.LAYMAN_GS_USER, settings.LAYMAN_GS_ROLE, settings.GEOSERVER_ADMIN_AUTH) gs_util.ensure_proxy_base_url(settings.LAYMAN_GS_PROXY_BASE_URL_WITH_PLACEHOLDERS, settings.LAYMAN_GS_AUTH) diff --git a/src/layman/layer/geoserver/__init__.py b/src/layman/layer/geoserver/__init__.py index 225be114a..312112419 100644 --- a/src/layman/layer/geoserver/__init__.py +++ b/src/layman/layer/geoserver/__init__.py @@ -16,19 +16,11 @@ def ensure_whole_user(username, auth=settings.LAYMAN_GS_AUTH): gs_util.ensure_user(username, None, auth) - role = gs_util.username_to_rolename(username) - gs_util.ensure_role(role, auth) - gs_util.ensure_user_role(username, role, auth) - gs_util.ensure_user_role(username, settings.LAYMAN_GS_ROLE, auth) ensure_workspace(username, auth) def delete_whole_user(username, auth=settings.LAYMAN_GS_AUTH): - role = gs_util.username_to_rolename(username) delete_workspace(username, auth) - gs_util.delete_user_role(username, role, auth) - gs_util.delete_user_role(username, settings.LAYMAN_GS_ROLE, auth) - gs_util.delete_role(role, auth) gs_util.delete_user(username, auth) diff --git a/src/layman/upgrade/__init__.py b/src/layman/upgrade/__init__.py index aa2253819..6411f12b8 100644 --- a/src/layman/upgrade/__init__.py +++ b/src/layman/upgrade/__init__.py @@ -1,6 +1,7 @@ import logging from db import util as db_util +from geoserver import util as gs_util from layman.upgrade import upgrade_v1_8, upgrade_v1_9, upgrade_v1_10, upgrade_v1_12, upgrade_v1_16, upgrade_v1_17, upgrade_v1_18, \ upgrade_v1_20, upgrade_v1_21, upgrade_v1_22, upgrade_v1_23 from layman import settings