-
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
Showing
19 changed files
with
139 additions
and
35 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,17 @@ def test_with_justice_email(self, client, users): | |
assert response.status_code == 302 | ||
assert response.url == reverse("list-tools") | ||
|
||
def test_not_tool_user(self, client, users): | ||
user = users["non_tool_user"] | ||
user.justice_email = "[email protected]" | ||
user.save() | ||
client.force_login(user) | ||
|
||
response = client.get("/") | ||
|
||
assert response.status_code == 302 | ||
assert response.url == reverse("help") | ||
|
||
|
||
class TestPost: | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# Standard library | ||
from unittest.mock import Mock | ||
from unittest.mock import Mock, patch | ||
|
||
# Third-party | ||
import pytest | ||
from django.conf import settings | ||
|
||
# First-party/Local | ||
from controlpanel.oidc import StateMismatchHandler | ||
from controlpanel.oidc import OIDCSubAuthenticationBackend, StateMismatchHandler | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
@@ -24,3 +25,27 @@ def test_success_url(users, email, success_url): | |
view.request = request | ||
view.user = user | ||
assert view.success_url == success_url | ||
|
||
|
||
@pytest.mark.django_db | ||
@pytest.mark.parametrize( | ||
"email, name, expected_name, expected_justice_email", | ||
[ | ||
("[email protected]", "User, Test", "Test User", None), | ||
("[email protected]", "Test User", "Test User", None), | ||
("[email protected]", "User, Test", "Test User", "[email protected]"), | ||
("[email protected]", "Test User", "Test User", "[email protected]"), | ||
], | ||
) | ||
def test_create_user(email, name, expected_name, expected_justice_email): | ||
with patch("controlpanel.api.cluster.User.create"): | ||
user = OIDCSubAuthenticationBackend().create_user( | ||
{ | ||
"sub": "123", | ||
settings.OIDC_FIELD_USERNAME: "testuser", | ||
settings.OIDC_FIELD_EMAIL: email, | ||
settings.OIDC_FIELD_NAME: name, | ||
} | ||
) | ||
assert user.name == expected_name | ||
assert user.justice_email == expected_justice_email |