Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

868 GET Workspace Layer Metadata Comparison #925

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- [#765](https://github.com/LayerManager/layman/issues/765) Remove `authn.txt` files from workspace directories. The same information as in `authn.txt` files is saved in prime DB schema.
- [#868](https://github.com/LayerManager/layman/issues/868) Fill table `map_layer` with relations between maps and [internal layers](doc/models.md#internal-map-layer) (layers published on this Layman instance). Relations to [external layers](doc/models.md#internal-map-layer) (layers of other servers) are not imported into the table.
### Changes
- [#868](https://github.com/LayerManager/layman/issues/868) Endpoints [GET Publications](doc/rest.md#get-publications), [GET Layers](doc/rest.md#get-layers), [GET Workspace Layers](doc/rest.md#get-workspace-layers), [GET Maps](doc/rest.md#get-maps), [GET Workspace Maps](doc/rest.md#get-workspace-maps), [GET Workspace Layer](doc/rest.md#get-workspace-layer), [GET Workspace Map](doc/rest.md#get-workspace-map), [POST Workspace Layers](doc/rest.md#post-workspace-layers), [DELETE Workspace Layer](doc/rest.md#delete-workspace-layer), [DELETE Workspace Layers](doc/rest.md#delete-workspace-layers), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps), [POST Workspace Maps](doc/rest.md#post-workspace-maps), [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer), [PATCH Workspace Map](doc/rest.md#patch-workspace-map) and [WMS/WFS endpoints](doc/endpoints.md) respects [HTTP header `X-Forwarded-Prefix`](doc/client-proxy.md#x-forwarded-prefix-http-header) of the request in the response.
- [#868](https://github.com/LayerManager/layman/issues/868) Endpoints [GET Publications](doc/rest.md#get-publications), [GET Layers](doc/rest.md#get-layers), [GET Workspace Layers](doc/rest.md#get-workspace-layers), [GET Maps](doc/rest.md#get-maps), [GET Workspace Maps](doc/rest.md#get-workspace-maps), [GET Workspace Layer](doc/rest.md#get-workspace-layer), [GET Workspace Map](doc/rest.md#get-workspace-map), [POST Workspace Layers](doc/rest.md#post-workspace-layers), [DELETE Workspace Layer](doc/rest.md#delete-workspace-layer), [DELETE Workspace Layers](doc/rest.md#delete-workspace-layers), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps), [POST Workspace Maps](doc/rest.md#post-workspace-maps), [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer), [PATCH Workspace Map](doc/rest.md#patch-workspace-map) and [WMS/WFS endpoints](doc/endpoints.md) respects [HTTP header `X-Forwarded-Prefix`](doc/client-proxy.md#x-forwarded-prefix-http-header) of the request in the response. Header does not affect response of [GET Workspace Layer Metadata Comparison](doc/rest.md#get-workspace-layer-metadata-comparison).
- [#868](https://github.com/LayerManager/layman/issues/868) Relations between map and [internal layers](doc/models.md#internal-map-layer) are updated in `map_layer` table when calling [POST Workspace Maps](doc/rest.md#post-workspace-maps), [PATCH Workspace Map](doc/rest.md#patch-workspace-map), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), and [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps).
- [#880](https://github.com/LayerManager/layman/issues/880) Use Docker Compose v2 (`docker compose`) in Makefile without `compatibility` flag and remove `Makefile_docker-compose_v1` file. Docker containers are named according to Docker Compose v2 and may have different name after upgrade.
- [#765](https://github.com/LayerManager/layman/issues/765) Stop saving OAuth2 claims in filesystem, use prime DB schema only.
Expand Down
2 changes: 2 additions & 0 deletions doc/client-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ Currently, value of `X-Forwarded-Prefix` affects following URLs:
* all legend URLs
* [WFS endpoints](endpoints.md#web-feature-service)
* all operations URLs

Value of `X-Forwarded-Prefix` does not affects response values of [GET Workspace Layer Metadata Comparison](rest.md#get-workspace-layer-metadata-comparison).
29 changes: 27 additions & 2 deletions tests/asserts/final/publication/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def expected_values_in_micka_metadata(workspace, publ_type, name, expected_value
)


def correct_values_in_metadata(workspace, publ_type, name, http_method, *, exp_values=None, actor_name=None):
def correct_values_in_metadata(workspace, publ_type, name, http_method, *, exp_values=None, actor_name=None, headers=None):
exp_values = exp_values or {}
actor_name = actor_name or settings.ANONYM_USER
md_props = {
Expand All @@ -62,7 +62,8 @@ def correct_values_in_metadata(workspace, publ_type, name, http_method, *, exp_v
}[publ_type]
with app.app_context():
resp_json = process_client.get_workspace_publication_metadata_comparison(publ_type, workspace, name,
actor_name=actor_name)
actor_name=actor_name,
headers=headers)
assert md_props.issubset(set(resp_json['metadata_properties'].keys()))
for key, value in resp_json['metadata_properties'].items():
assert value['equal_or_null'] is True, f'key={key}, value={value}'
Expand All @@ -80,3 +81,27 @@ def correct_values_in_metadata(workspace, publ_type, name, http_method, *, exp_v
for key, value in exp_values.items():
assert exp_metadata[key] == value, f"Template value differ from expected value, key={key}"
expected_values_in_micka_metadata(workspace, publ_type, name, exp_metadata)


def correct_layer_comparison_response_with_x_forwarded_prefix_header(workspace, name, *, actor_name=None, headers=None):
proxy_prefix = '/layman-proxy'
headers = headers or {}
actor_name = actor_name or settings.ANONYM_USER
md_props = LAYER_METADATA_PROPERTIES
headers_with_header = {**headers,
'X-Forwarded-Prefix': proxy_prefix,
}
with app.app_context():
resp_json_with_proxy = process_client.get_workspace_publication_metadata_comparison(process_client.LAYER_TYPE, workspace, name,
actor_name=actor_name,
headers=headers_with_header)
resp_json_without_proxy = process_client.get_workspace_publication_metadata_comparison(process_client.LAYER_TYPE, workspace,
name,
actor_name=actor_name,
headers=headers)
assert md_props.issubset(set(resp_json_with_proxy['metadata_properties'].keys()))
for key, value in resp_json_with_proxy['metadata_properties'].items():
assert value['equal_or_null'] is True, f'key={key}, value={value}'
assert value['equal'] is True, f'key={key}, value={value}'

assert resp_json_with_proxy == resp_json_without_proxy
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ def test_layer(layer, params, rest_args, rest_method, parametrization):
asserts_publ.geoserver_proxy.is_complete_in_workspace_wms(layer.workspace, layer.type, layer.name,
version='1.1.1')
asserts_publ.geoserver_proxy.wms_legend_url_with_x_forwarded_prefix(layer.workspace, layer.type, layer.name, )
asserts_publ.metadata.correct_layer_comparison_response_with_x_forwarded_prefix_header(layer.workspace, layer.name, )
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_publication(self, map, rest_method, rest_args, params):
assert_util.is_publication_valid_and_complete(map)

exp = params['exp_after_rest_method']
http_method = REQUEST_METHOD_PATCH if rest_method == self.patch_publication else REQUEST_METHOD_POST # pylint: disable=W0143
http_method = REQUEST_METHOD_PATCH if rest_method.enum_item == base_test_classes.RestMethodAll.PATCH else REQUEST_METHOD_POST
self.assert_exp_map_layers(map, exp['map_layers'], exp['operates_on'], http_method=http_method,
actor_name=rest_args.get('actor_name'))
self.assert_exp_layer_maps(LAYER_HRANICE, [
Expand Down