-
-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sources/oauth: ensure all UI sources return a valid source (cherry-pick
#9401) (#9406) sources/oauth: ensure all UI sources return a valid source (#9401) * web/admin: prevent selection of inbuilt source in identification stage * fix apple source * also fix plex challenge --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens L <jens@goauthentik.io>
- Loading branch information
1 parent
11ff795
commit 541becf
Showing
6 changed files
with
63 additions
and
24 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,37 @@ | ||
"""Apple Type tests""" | ||
|
||
from django.test import RequestFactory, TestCase | ||
from guardian.shortcuts import get_anonymous_user | ||
|
||
from authentik.lib.generators import generate_id | ||
from authentik.lib.tests.utils import dummy_get_response | ||
from authentik.root.middleware import SessionMiddleware | ||
from authentik.sources.oauth.models import OAuthSource | ||
from authentik.sources.oauth.types.registry import registry | ||
|
||
|
||
class TestTypeApple(TestCase): | ||
"""OAuth Source tests""" | ||
|
||
def setUp(self): | ||
self.source = OAuthSource.objects.create( | ||
name="test", | ||
slug="test", | ||
provider_type="apple", | ||
authorization_url="", | ||
profile_url="", | ||
consumer_key=generate_id(), | ||
) | ||
self.factory = RequestFactory() | ||
|
||
def test_login_challenge(self): | ||
"""Test login_challenge""" | ||
request = self.factory.get("/") | ||
request.user = get_anonymous_user() | ||
|
||
middleware = SessionMiddleware(dummy_get_response) | ||
middleware.process_request(request) | ||
request.session.save() | ||
oauth_type = registry.find_type("apple") | ||
challenge = oauth_type().login_challenge(self.source, request) | ||
self.assertTrue(challenge.is_valid(raise_exception=True)) |
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
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
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
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
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