Skip to content

Commit

Permalink
✅ [#390] Test new endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Oct 3, 2024
1 parent 40727b7 commit ce41a54
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions backend/src/openarchiefbeheer/config/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from unittest.mock import patch

from django.test import override_settings, tag

from mozilla_django_oidc_db.models import OpenIDConnectConfig
from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
Expand Down Expand Up @@ -86,3 +89,35 @@ def test_can_send_empty_list(self):
config = ArchiveConfig.get_solo()

self.assertEqual(config.zaaktypes_short_process, [])


class OIDCInfoViewTests(APITestCase):
def test_oidc_info_view_not_enabled(self):
config_url = reverse("api:oidc-info")
with patch(
"openarchiefbeheer.config.api.views.OpenIDConnectConfig.get_solo",
return_value=OpenIDConnectConfig(enabled=False),
):
response = self.client.get(config_url)

self.assertEqual(response.status_code, status.HTTP_200_OK)

data = response.json()

self.assertFalse(data["enabled"])
self.assertEqual(data["loginUrl"], "")

def test_oidc_info_view_enabled(self):
config_url = reverse("api:oidc-info")
with patch(
"openarchiefbeheer.config.api.views.OpenIDConnectConfig.get_solo",
return_value=OpenIDConnectConfig(enabled=True),
):
response = self.client.get(config_url)

self.assertEqual(response.status_code, status.HTTP_200_OK)

data = response.json()

self.assertTrue(data["enabled"])
self.assertEqual(data["loginUrl"], "http://testserver/oidc/authenticate/")

0 comments on commit ce41a54

Please sign in to comment.