diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0689117..3b53faaec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) 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. - [#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), [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. diff --git a/doc/client-proxy.md b/doc/client-proxy.md index f26bde5fb..efc217ce6 100644 --- a/doc/client-proxy.md +++ b/doc/client-proxy.md @@ -82,6 +82,11 @@ Currently, value of `X-Forwarded-Prefix` affects following URLs: * `style`.`url` key * `thumbnail`.`url` key * `metadata`.`comparison_url` key +* [PATCH Workspace Map](rest.md#patch-workspace-map) + * `url` key + * `file`.`url` key + * `thumbnail`.`url` key + * `metadata`.`comparison_url` key * [OGC endpoints](endpoints.md) * Headers `X-Forwarded-Proto`, `X-Forwarded-Host`, `X-Forwarded-For`, `X-Forwarded-Path`, `Forwarded` and `Host` are ignored * [WMS endpoints](endpoints.md#web-map-service) diff --git a/src/layman/map/rest_workspace_map.py b/src/layman/map/rest_workspace_map.py index 1049d324e..c9d751ed9 100644 --- a/src/layman/map/rest_workspace_map.py +++ b/src/layman/map/rest_workspace_map.py @@ -46,6 +46,7 @@ def get(workspace, mapname): def patch(workspace, mapname): app.logger.info(f"PATCH Map, actor={g.user}") + x_forwarded_prefix = layman_util.get_x_forwarded_prefix(request.headers) info = util.get_complete_map_info(workspace, mapname) # FILE @@ -106,7 +107,7 @@ def patch(workspace, mapname): 'layman.map.filesystem.input_file' if file_changed else None ) - info = util.get_complete_map_info(workspace, mapname) + info = util.get_complete_map_info(workspace, mapname, x_forwarded_prefix=x_forwarded_prefix) return jsonify(info), 200 diff --git a/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py b/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py index f73c236ba..c8cbae1a0 100644 --- a/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py +++ b/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py @@ -2,7 +2,7 @@ from tests import EnumTestTypes, Publication from tests.dynamic_data import base_test, base_test_classes from tests.dynamic_data.publications import common_publications -from test_tools import assert_util +from test_tools import assert_util, process_client pytest_generate_tests = base_test.pytest_generate_tests @@ -26,9 +26,6 @@ class TestPublication(base_test.TestSingleRestPublication): publ_def.type, None), type=EnumTestTypes.MANDATORY, - specific_types={ - (base_test_classes.RestMethodAll.PATCH, PublicationTypes.MAP): EnumTestTypes.IGNORE, - } )] def test_publication(self, publication, rest_method): @@ -36,30 +33,45 @@ def test_publication(self, publication, rest_method): response = rest_method(publication, args={'headers': {'X-Forwarded-Prefix': proxy_prefix}}) publication_response = response[0] if isinstance(response, list) and len(response) == 1 else response if rest_method == self.patch_publication: # pylint: disable=W0143 - exp_resp = { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}', - 'thumbnail': { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/thumbnail' - }, - 'metadata': { - 'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/metadata-comparison', - }, - 'wms': { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}_wms/ows', - }, - 'sld': { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style', - }, - 'style': { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style', - }, - } + if publication.type == process_client.LAYER_TYPE: + exp_resp = { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}', + 'thumbnail': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/thumbnail' + }, + 'metadata': { + 'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/metadata-comparison', + }, + 'wms': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}_wms/ows', + }, + 'sld': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style', + }, + 'style': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style', + }, + } - geodata_type = response['geodata_type'] - if geodata_type == settings.GEODATA_TYPE_VECTOR: - exp_resp['wfs'] = { - 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}/wfs' + geodata_type = response['geodata_type'] + if geodata_type == settings.GEODATA_TYPE_VECTOR: + exp_resp['wfs'] = { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}/wfs' + } + else: + exp_resp = { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}', + 'thumbnail': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}/thumbnail' + }, + 'file': { + 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}/file' + }, + 'metadata': { + 'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}/metadata-comparison', + }, } + else: exp_resp = {'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}'}