Skip to content

Commit

Permalink
Remove role and role-user operations on GeoServer
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Dec 14, 2023
1 parent 28b569e commit 5c9775d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 49 deletions.
38 changes: 0 additions & 38 deletions src/geoserver/geoserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/layman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 0 additions & 8 deletions src/layman/layer/geoserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
1 change: 1 addition & 0 deletions src/layman/upgrade/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5c9775d

Please sign in to comment.