Skip to content

Commit

Permalink
Test metadata comparison with X-Forwarded-Prefix header
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Sep 18, 2023
1 parent adad5a7 commit e337aad
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
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, )

0 comments on commit e337aad

Please sign in to comment.