From 8c1b065501dc103e1aab140b3f52b9653ace7677 Mon Sep 17 00:00:00 2001 From: Anna Shamray Date: Wed, 6 Dec 2023 12:37:47 +0100 Subject: [PATCH 1/2] :bug: add COMMONGROUND_API_COMMON_GET_DOMAIN to the exported vars --- vng_api_common/conf/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vng_api_common/conf/api.py b/vng_api_common/conf/api.py index 2d85012b..4948bd5b 100644 --- a/vng_api_common/conf/api.py +++ b/vng_api_common/conf/api.py @@ -13,6 +13,7 @@ "NOTIFICATIONS_KANAAL", "NOTIFICATIONS_DISABLED", "JWT_LEEWAY", + "COMMONGROUND_API_COMMON_GET_DOMAIN", ] API_VERSION = "1.0.0-rc1" # semantic version From 448a36ec777b069b50f62d180ff6f766ff144222 Mon Sep 17 00:00:00 2001 From: Anna Shamray Date: Wed, 6 Dec 2023 14:16:05 +0100 Subject: [PATCH 2/2] :white_check_mark: add regression test --- testapp/settings.py | 2 ++ testapp/urls.py | 3 +++ testapp/utils.py | 8 ++++++++ tests/test_views.py | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 tests/test_views.py diff --git a/testapp/settings.py b/testapp/settings.py index a693d426..81bee495 100644 --- a/testapp/settings.py +++ b/testapp/settings.py @@ -93,3 +93,5 @@ "SECURITY_DEFINITIONS": {SECURITY_DEFINITION_NAME: {}}, } ) + +IS_HTTPS = False diff --git a/testapp/urls.py b/testapp/urls.py index ce0edc5b..b60ad771 100644 --- a/testapp/urls.py +++ b/testapp/urls.py @@ -4,6 +4,8 @@ from rest_framework import routers +from vng_api_common.views import ViewConfigView + from .schema import SchemaView from .views import NotificationView from .viewsets import GroupViewSet, HobbyViewSet, PersonViewSet @@ -37,6 +39,7 @@ path("api/", include(router.urls)), path("api/", include("vng_api_common.api.urls")), path("ref/", include("vng_api_common.urls")), + path("view-config/", ViewConfigView.as_view(), name="view-config"), # this is a hack to get the parameter to show up in the API spec # this effectively makes this a wildcard URL, so it should be LAST path("", NotificationView.as_view()), diff --git a/testapp/utils.py b/testapp/utils.py index ece22ae0..367fe93e 100644 --- a/testapp/utils.py +++ b/testapp/utils.py @@ -1,3 +1,11 @@ # Custom function to get client for ClientConfig models def get_client(url): return "testclient" + + +# Custom function to get client with auth for ClientConfig models +def get_client_with_auth(url): + class TestClient: + auth = None + + return TestClient diff --git a/tests/test_views.py b/tests/test_views.py new file mode 100644 index 00000000..1e6ad29b --- /dev/null +++ b/tests/test_views.py @@ -0,0 +1,18 @@ +from django.test import override_settings +from django.urls import reverse + +import pytest +from rest_framework import status + + +@pytest.mark.django_db +@override_settings(CUSTOM_CLIENT_FETCHER="testapp.utils.get_client_with_auth") +def test_config_view(api_client): + """ + regression test for https://github.com/open-zaak/open-notificaties/issues/119 + """ + path = reverse("view-config") + + response = api_client.get(path) + + assert response.status_code == status.HTTP_200_OK