From c32d5697c3b691a0f2e7ef2a39dfd407ee8302c2 Mon Sep 17 00:00:00 2001 From: Nino Date: Mon, 21 Oct 2024 11:19:10 +0200 Subject: [PATCH 1/2] remove unused endpoint --- app/apps/openzaak/views.py | 16 ---------------- app/apps/users/views.py | 1 - app/config/urls.py | 7 ------- 3 files changed, 24 deletions(-) delete mode 100644 app/apps/openzaak/views.py diff --git a/app/apps/openzaak/views.py b/app/apps/openzaak/views.py deleted file mode 100644 index f6de1d8fd..000000000 --- a/app/apps/openzaak/views.py +++ /dev/null @@ -1,16 +0,0 @@ -import json - -from rest_framework import status -from rest_framework.response import Response -from rest_framework.views import APIView - -from .models import Notification - - -class ReceiveNotificationView(APIView): - permission_classes = () - authentication_classes = () - - def post(self, request): - Notification.objects.create(data=json.dumps(request.data)) - return Response({}, status=status.HTTP_201_CREATED) diff --git a/app/apps/users/views.py b/app/apps/users/views.py index 2739e9dc5..a81c918d7 100644 --- a/app/apps/users/views.py +++ b/app/apps/users/views.py @@ -82,7 +82,6 @@ def post(self, request, *args, **kwargs): except Exception as e: LOGGER.error("Could not authenticate: {}".format(str(e))) return HttpResponseBadRequest("Could not authenticate") - try: refresh = RefreshToken.for_user(user) except Exception as e: diff --git a/app/config/urls.py b/app/config/urls.py index 770a72f55..a34f3a6d2 100644 --- a/app/config/urls.py +++ b/app/config/urls.py @@ -16,7 +16,6 @@ from apps.decisions.views import DecisionTypeViewSet, DecisionViewSet from apps.fines.views import FinesViewSet from apps.health.health_checks import is_healthy -from apps.openzaak.views import ReceiveNotificationView from apps.quick_decisions.views import QuickDecisionTypeViewSet, QuickDecisionViewSet from apps.schedules.views import ( ActionViewSet, @@ -116,12 +115,6 @@ def get(self, request, *args, **kwargs): IsAuthorizedView.as_view(), name="is-authorized", ), - # Endpoint to receive the notification - path( - "api/v1/openzaak/callbacks", - ReceiveNotificationView.as_view(), - name="notification-callback", - ), path("health/", include("health_check.urls")), path("startup/", is_healthy), re_path(r"^$", view=MyView.as_view(), name="index"), From 0077688430ee3819ecd6709de1855666003134fd Mon Sep 17 00:00:00 2001 From: Nino Date: Mon, 21 Oct 2024 11:19:58 +0200 Subject: [PATCH 2/2] remove test --- app/apps/openzaak/tests/tests_views.py | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 app/apps/openzaak/tests/tests_views.py diff --git a/app/apps/openzaak/tests/tests_views.py b/app/apps/openzaak/tests/tests_views.py deleted file mode 100644 index 776f180d6..000000000 --- a/app/apps/openzaak/tests/tests_views.py +++ /dev/null @@ -1,25 +0,0 @@ -from apps.openzaak.models import Notification -from django.urls import reverse -from django_webtest import WebTest - - -class ViewTests(WebTest): - def test_notification_get(self): - url = reverse("notification-callback") - self.app.get(url, status=405) - - def test_notification_post(self): - url = reverse("notification-callback") - response = self.app.post(url) - self.assertEqual(response.status_code, 201) - self.assertEqual(Notification.objects.count(), 1) - notification = Notification.objects.first() - self.assertEqual(notification.data, "{}") - - def test_notification_post_with_data(self): - url = reverse("notification-callback") - response = self.app.post(url, params={"test": "test"}) - self.assertEqual(response.status_code, 201) - self.assertEqual(Notification.objects.count(), 1) - notification = Notification.objects.first() - self.assertEqual(notification.data, '{"test": "test"}')