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

Test map metadata comparison with X-Forwarded-Prefix header #926

Merged
merged 1 commit 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
- [#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. 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) 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 responses of [GET Workspace Layer Metadata Comparison](doc/rest.md#get-workspace-layer-metadata-comparison) and [GET Workspace Map Metadata Comparison](doc/rest.md#get-workspace-map-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: 1 addition & 1 deletion doc/client-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ Currently, value of `X-Forwarded-Prefix` affects following 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).
Value of `X-Forwarded-Prefix` does not affects response values of [GET Workspace Layer Metadata Comparison](rest.md#get-workspace-layer-metadata-comparison) and [GET Workspace Map Metadata Comparison](rest.md#get-workspace-map-metadata-comparison).
12 changes: 7 additions & 5 deletions tests/asserts/final/publication/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ def correct_values_in_metadata(workspace, publ_type, name, http_method, *, exp_v
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):
def correct_comparison_response_with_x_forwarded_prefix_header(workspace, publ_type, 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
md_props = {
process_client.LAYER_TYPE: LAYER_METADATA_PROPERTIES,
process_client.MAP_TYPE: MAP_METADATA_PROPERTIES,
}[publ_type]
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,
resp_json_with_proxy = process_client.get_workspace_publication_metadata_comparison(publ_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,
resp_json_without_proxy = process_client.get_workspace_publication_metadata_comparison(publ_type, workspace, name,
actor_name=actor_name,
headers=headers)
assert md_props.issubset(set(resp_json_with_proxy['metadata_properties'].keys()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +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, )
asserts_publ.metadata.correct_comparison_response_with_x_forwarded_prefix_header(layer.workspace, layer.type, layer.name, )
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def test_publication(self, map, rest_method, rest_args, params):
rest_method.fn(map, args=rest_args)
if rest_method.enum_item in [base_test_classes.RestMethodAll.POST, base_test_classes.RestMethodAll.PATCH]:
assert_util.is_publication_valid_and_complete(map)
asserts_publ.metadata.correct_comparison_response_with_x_forwarded_prefix_header(map.workspace, map.type, map.name, )

exp = params['exp_after_rest_method']
http_method = REQUEST_METHOD_PATCH if rest_method.enum_item == base_test_classes.RestMethodAll.PATCH else REQUEST_METHOD_POST
Expand Down