From 180c5d74abd183a43bf90be2728dc2d7d8a269b0 Mon Sep 17 00:00:00 2001 From: Jiri Kozel Date: Fri, 22 Dec 2023 16:06:43 +0100 Subject: [PATCH] Fix test_create_role_service_schema in upgrade_v1_23_test.py --- src/layman/upgrade/upgrade_v1_23_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/layman/upgrade/upgrade_v1_23_test.py b/src/layman/upgrade/upgrade_v1_23_test.py index 0c43099e0..7451434b6 100644 --- a/src/layman/upgrade/upgrade_v1_23_test.py +++ b/src/layman/upgrade/upgrade_v1_23_test.py @@ -93,11 +93,29 @@ def test_create_role_service_schema(): (select count(*) from {ROLE_SERVICE_SCHEMA}.admin_user_roles) admin_user_roles, (select count(*) from {ROLE_SERVICE_SCHEMA}.user_roles) user_roles''' + # prepare simple schema in the same way as in setup_geoserver.py + prepare_simple_schema_statement = f""" +CREATE SCHEMA "{ROLE_SERVICE_SCHEMA}" AUTHORIZATION {settings.LAYMAN_PG_USER}; +create view {ROLE_SERVICE_SCHEMA}.roles as select 'ADMIN'::varchar(64) as name, null::varchar(64) as parent +union all select 'GROUP_ADMIN', null +union all select %s, null +; +create view {ROLE_SERVICE_SCHEMA}.role_props as select null::varchar(64) as rolename, null::varchar(64) as propname, null::varchar(2048) as propvalue; +create view {ROLE_SERVICE_SCHEMA}.user_roles as select %s::varchar(64) as username, 'ADMIN'::varchar(64) as rolename +union all select %s, %s +union all select %s, 'ADMIN' +; +create view {ROLE_SERVICE_SCHEMA}.group_roles as select null::varchar(128) as groupname, null::varchar(64) as rolename; + """ + with app.app_context(): ensure_whole_user(username, userinfo) db_util.run_statement(drop_statement) result = db_util.run_query(schema_existence_query)[0][0] assert result == 0 + db_util.run_statement(prepare_simple_schema_statement, data=( + settings.LAYMAN_GS_ROLE, settings.LAYMAN_GS_USER, settings.LAYMAN_GS_USER, settings.LAYMAN_GS_ROLE, + settings.GEOSERVER_ADMIN_USER)) upgrade_v1_23.create_role_service_schema()