Skip to content

Commit

Permalink
Fix patch saving layer file before access right validation
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Oct 17, 2023
1 parent 7cd197c commit 821c3ce
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
2023-10-12
### Changes
- [#949](https://github.com/LayerManager/layman/issues/949) Fix reading map-layer relations from map composition that includes also other than WMS and Vector layers.
- [#952](https://github.com/LayerManager/layman/issues/952) Fix patch saving publication files before access right validation.

## v1.22.0
2023-10-05
Expand Down
14 changes: 7 additions & 7 deletions src/layman/layer/rest_workspace_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ def patch(workspace, layername):

layer_result = {}

kwargs.update({'actor_name': authn.get_authn_username()})
rest_util.setup_patch_access_rights(request.form, kwargs)
util.pre_publication_action_check(workspace,
layername,
kwargs,
)

if delete_from is not None:
request_method = request.method.lower()
deleted = util.delete_layer(workspace, layername, source=delete_from, http_method=request_method)
Expand Down Expand Up @@ -245,13 +252,6 @@ def patch(workspace, layername):
elif input_files:
shutil.move(temp_dir, input_file.get_layer_input_file_dir(workspace, layername))
publications.set_wfs_wms_status(workspace, LAYER_TYPE, layername, settings.EnumWfsWmsStatus.PREPARING)
kwargs.update({'actor_name': authn.get_authn_username()})

rest_util.setup_patch_access_rights(request.form, kwargs)
util.pre_publication_action_check(workspace,
layername,
kwargs,
)

util.patch_layer(
workspace,
Expand Down
38 changes: 38 additions & 0 deletions tests/dynamic_data/publications/wrong_input/wrong_input_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,44 @@ class Key(Enum):
Key.RUN_ONLY_CASES: frozenset([RestMethod.PATCH, WithChunksDomain.FALSE, CompressDomain.FALSE]),
Key.SPECIFIC_CASES: {},
},
# issue 952
'patch_layer_write_rights_without_owner': {
Key.PUBLICATION_TYPE: process_client.LAYER_TYPE,
Key.WORKSPACE: OWNER,
Key.POST_BEFORE_TEST_ARGS: {
'access_rights': {
'read': 'EVERYONE',
'write': 'EVERYONE',
},
'actor_name': OWNER,
},
Key.REST_ARGS: {
'file_paths': ['sample/layman.layer/small_layer.geojson'],
'access_rights': {
'read': 'EVERYONE',
'write': EDITOR,
},
'actor_name': EDITOR,
},
Key.EXCEPTION: LaymanError,
Key.EXPECTED_EXCEPTION: {
'http_code': 400,
'sync': True,
'code': 43,
'message': 'Wrong access rights.',
'data': {
'access_rights': {'read': ['EVERYONE'], 'write': ['wrong_input_editor']},
'message': 'Owner of the personal workspace have to keep write right.',
'actor_name': 'wrong_input_editor',
'owner': 'wrong_input_owner',
'publication_name': '{publication_name}',
'workspace_name': '{workspace}',
},
},
Key.MANDATORY_CASES: frozenset([RestMethod.PATCH, WithChunksDomain.FALSE, CompressDomain.FALSE]),
Key.RUN_ONLY_CASES: frozenset([RestMethod.PATCH, WithChunksDomain.FALSE, CompressDomain.FALSE]),
Key.SPECIFIC_CASES: {},
},
}


Expand Down

0 comments on commit 821c3ce

Please sign in to comment.