Skip to content

Commit

Permalink
fix configuration endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Feb 4, 2025
1 parent b6d09c6 commit 3a5d291
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
46 changes: 46 additions & 0 deletions authentik/enterprise/providers/ssf/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import json

from django.urls import reverse
from rest_framework.test import APITestCase

from authentik.core.models import Application
from authentik.core.tests.utils import create_test_cert
from authentik.enterprise.providers.ssf.models import (
SSFProvider,
)
from authentik.lib.generators import generate_id


class TestConfiguration(APITestCase):
def setUp(self):
self.application = Application.objects.create(name=generate_id(), slug=generate_id())
self.provider = SSFProvider.objects.create(
name=generate_id(),
signing_key=create_test_cert(),
backchannel_application=self.application,
)

def test_config_fetch(self):
"""test SSF configuration (unauthenticated)"""
res = self.client.get(
reverse(
"authentik_providers_ssf:configuration",
kwargs={"application_slug": self.application.slug},
),
)
self.assertEqual(res.status_code, 200)
content = json.loads(res.content)
self.assertEqual(content["spec_version"], "1_0-ID2")

def test_config_fetch_authenticated(self):
"""test SSF configuration (authenticated)"""
res = self.client.get(
reverse(
"authentik_providers_ssf:configuration",
kwargs={"application_slug": self.application.slug},
),
HTTP_AUTHORIZATION=f"Bearer {self.provider.token.key}",
)
self.assertEqual(res.status_code, 200)
content = json.loads(res.content)
self.assertEqual(content["spec_version"], "1_0-ID2")
4 changes: 1 addition & 3 deletions authentik/enterprise/providers/ssf/views/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ def get(self, request: HttpRequest, application_slug: str, *args, **kwargs) -> H
"authentik_providers_ssf:configuration",
kwargs={
"application_slug": application.slug,
"provider": provider.pk,
},
)
),
"jwks_uri": self.request.build_absolute_uri(
reverse(
"authentik_providers_ssf:jwks",
kwargs={
"provider": provider.pk,
"application_slug": application.slug,
},
)
),
Expand All @@ -45,7 +44,6 @@ def get(self, request: HttpRequest, application_slug: str, *args, **kwargs) -> H
"authentik_providers_ssf:stream",
kwargs={
"application_slug": application.slug,
"provider": provider.pk,
},
)
),
Expand Down

0 comments on commit 3a5d291

Please # to comment.