-
Notifications
You must be signed in to change notification settings - Fork 168
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
444314d
commit 0bf743b
Showing
1 changed file
with
20 additions
and
25 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 |
---|---|---|
|
@@ -3,19 +3,14 @@ | |
|
||
from cryptography.hazmat.backends import default_backend | ||
from cryptography.hazmat.primitives import hashes, hmac | ||
from josepy.b64 import b64encode | ||
|
||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
from django.core.exceptions import SuspiciousOperation | ||
from django.test import RequestFactory, TestCase, override_settings | ||
from django.utils.encoding import force_bytes, smart_str | ||
from josepy.b64 import b64encode | ||
|
||
from mozilla_django_oidc.auth import ( | ||
default_username_algo, | ||
OIDCAuthenticationBackend, | ||
) | ||
|
||
from mozilla_django_oidc.auth import OIDCAuthenticationBackend, default_username_algo | ||
|
||
User = get_user_model() | ||
|
||
|
@@ -61,7 +56,7 @@ def test_invalid_token(self, request_mock, token_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"accesss_token": "access_token", | ||
|
@@ -239,7 +234,7 @@ def test_successful_authentication_existing_user_namespaced( | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -288,7 +283,7 @@ def test_successful_authentication_existing_user(self, token_mock, request_mock) | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -341,7 +336,7 @@ def test_successful_authentication_existing_user_upper_case( | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -394,7 +389,7 @@ def test_failed_authentication_verify_claims( | |
claims_response = {"nickname": "a_username", "email": "[email protected]"} | ||
get_json_mock.json.return_value = claims_response | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -445,7 +440,7 @@ def test_successful_authentication_new_user( | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -505,7 +500,7 @@ def test_successful_authentication_basic_auth_token(self, token_mock, request_mo | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -576,7 +571,7 @@ def test_jwt_decode_params(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "token", | ||
"access_token": "access_token", | ||
|
@@ -602,7 +597,7 @@ def test_jwt_decode_params_verify_false(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "token", | ||
"access_token": "access_token", | ||
|
@@ -642,7 +637,7 @@ def test_create_user_disabled(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -666,7 +661,7 @@ def test_create_user_enabled(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -695,7 +690,7 @@ def test_custom_username_algo(self, request_mock, jws_mock, algo_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -725,7 +720,7 @@ def test_custom_username_algo_dotted_path(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -753,7 +748,7 @@ def test_duplicate_emails_exact(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -778,7 +773,7 @@ def test_duplicate_emails_case_mismatch(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -812,7 +807,7 @@ def update_user(user, claims): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "id_token", | ||
"access_token": "access_granted", | ||
|
@@ -850,7 +845,7 @@ def test_jwt_verify_sign_key(self, request_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "token", | ||
"access_token": "access_token", | ||
|
@@ -899,7 +894,7 @@ def test_jwt_verify_sign_key_calls(self, request_mock, jwk_mock, jws_mock): | |
"email": "[email protected]", | ||
} | ||
request_mock.get.return_value = get_json_mock | ||
post_json_mock = Mock() | ||
post_json_mock = Mock(status_code=200) | ||
post_json_mock.json.return_value = { | ||
"id_token": "token", | ||
"access_token": "access_token", | ||
|