From 9a25aa1c4f23696f712b26955ae1c827d8742025 Mon Sep 17 00:00:00 2001 From: Jiri Kozel Date: Tue, 12 Sep 2023 20:02:54 +0200 Subject: [PATCH] Enable to use actor_name in process_client.py --- test_tools/process_client.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test_tools/process_client.py b/test_tools/process_client.py index b38bc3ea1..d03b887d4 100644 --- a/test_tools/process_client.py +++ b/test_tools/process_client.py @@ -172,6 +172,7 @@ def patch_workspace_publication(publication_type, file_paths=None, external_table_uri=None, headers=None, + actor_name=None, access_rights=None, title=None, style_file=None, @@ -189,6 +190,8 @@ def patch_workspace_publication(publication_type, skip_asserts=False, ): headers = headers or {} + if actor_name: + assert TOKEN_HEADER not in headers publication_type_def = PUBLICATION_TYPES_DEF[publication_type] if not skip_asserts: @@ -210,6 +213,9 @@ def patch_workspace_publication(publication_type, # Compress settings can be used only with compress option assert not compress_settings or compress + if actor_name and actor_name != settings.ANONYM_USER: + headers.update(get_authz_headers(actor_name)) + file_paths = [] if file_paths is None and not map_layers else file_paths with app.app_context(): @@ -325,6 +331,7 @@ def publish_workspace_publication(publication_type, file_paths=None, external_table_uri=None, headers=None, + actor_name=None, access_rights=None, title=None, style_file=None, @@ -344,6 +351,8 @@ def publish_workspace_publication(publication_type, ): title = title or name headers = headers or {} + if actor_name: + assert TOKEN_HEADER not in headers publication_type_def = PUBLICATION_TYPES_DEF[publication_type] assert not map_layers or not file_paths @@ -364,6 +373,9 @@ def publish_workspace_publication(publication_type, assert not (time_regex and publication_type == MAP_TYPE) + if actor_name and actor_name != settings.ANONYM_USER: + headers.update(get_authz_headers(actor_name)) + with app.app_context(): r_url = url_for(publication_type_def.post_workspace_publication_url, workspace=workspace) @@ -557,7 +569,14 @@ def assert_workspace_publications(publication_type, workspace, expected_publicat assert_workspace_maps = partial(assert_workspace_publications, MAP_TYPE) -def get_workspace_publication_metadata_comparison(publication_type, workspace, name, headers=None): +def get_workspace_publication_metadata_comparison(publication_type, workspace, name, headers=None, actor_name=None): + headers = headers or {} + if actor_name: + assert TOKEN_HEADER not in headers + + if actor_name and actor_name != settings.ANONYM_USER: + headers.update(get_authz_headers(actor_name)) + publication_type_def = PUBLICATION_TYPES_DEF[publication_type] with app.app_context(): r_url = url_for(publication_type_def.get_workspace_metadata_comparison_url, **{publication_type_def.url_param_name: name}, workspace=workspace)