-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
- Loading branch information
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters