From 20dcea566c60bdf19183aec25c36faa27af254e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 6 Sep 2022 18:14:21 +0200 Subject: [PATCH] applications: skip unknown (lateral) services (#68783) --- hobo/applications/views.py | 2 ++ tests/test_application.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hobo/applications/views.py b/hobo/applications/views.py index c4b8746..db684be 100644 --- a/hobo/applications/views.py +++ b/hobo/applications/views.py @@ -65,6 +65,8 @@ def get_object_types(): continue service_objects = {x.get_base_url_path(): x for x in get_installed_services(types=[service_id])} for service in services.values(): + if service['url'] not in service_objects: + continue if service_objects[service['url']].secondary: continue url = urllib.parse.urljoin(service['url'], 'api/export-import/') diff --git a/tests/test_application.py b/tests/test_application.py index 6f0f7b1..4aa0977 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -145,12 +145,19 @@ def test_create_application(app, admin_user, settings): settings.KNOWN_SERVICES = { 'wcs': { + 'blah': { + # simulate an instance from another collectivity + 'title': 'Unknown', + 'url': 'https://unknown.example.invalid/', + 'orig': 'example.org', + 'secret': 'xxx', + }, 'foobar': { 'title': 'Foobar', 'url': 'https://wcs.example.invalid/', 'orig': 'example.org', 'secret': 'xxx', - } + }, } }