-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d0c1af
commit 0658e87
Showing
7 changed files
with
81 additions
and
5 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,42 @@ | ||
from django.urls import reverse | ||
from django.utils.translation import gettext as _ | ||
|
||
from django_webtest import WebTest | ||
from mozilla_django_oidc_db.models import OpenIDConnectConfig | ||
|
||
|
||
class OIDCLoginButtonTestCase(WebTest): | ||
def test_oidc_button_disabled(self): | ||
config = OpenIDConnectConfig.get_solo() | ||
config.enabled = False | ||
config.save() | ||
|
||
response = self.app.get(reverse("admin:login")) | ||
|
||
oidc_login_link = response.html.find( | ||
"a", string=_("Login with organization account") | ||
) | ||
|
||
# Verify that the login button is not visible | ||
self.assertIsNone(oidc_login_link) | ||
|
||
def test_oidc_button_enabled(self): | ||
config = OpenIDConnectConfig.get_solo() | ||
config.enabled = True | ||
config.oidc_op_token_endpoint = "https://some.endpoint.nl/" | ||
config.oidc_op_user_endpoint = "https://some.endpoint.nl/" | ||
config.oidc_rp_client_id = "id" | ||
config.oidc_rp_client_secret = "secret" | ||
config.save() | ||
|
||
response = self.app.get(reverse("admin:login")) | ||
|
||
oidc_login_link = response.html.find( | ||
"a", string=_("Login with organization account") | ||
) | ||
|
||
# Verify that the login button is visible | ||
self.assertIsNotNone(oidc_login_link) | ||
self.assertEqual( | ||
oidc_login_link.attrs["href"], reverse("oidc_authentication_init") | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
[ | ||
"auth", | ||
"group" | ||
], | ||
[ | ||
"mozilla_django_oidc_db", | ||
"openidconnectconfig" | ||
] | ||
] | ||
} | ||
|
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