-
Notifications
You must be signed in to change notification settings - Fork 1
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
9 changed files
with
97 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,11 @@ def create_remote_user(mocker): | |
return mocker.patch("nens_auth_client.backends.create_remote_user") | ||
|
||
|
||
@pytest.fixture | ||
def create_user(mocker): | ||
return mocker.patch("nens_auth_client.backends.create_user") | ||
|
||
|
||
def test_remote_user_exists(user_getter): | ||
user_getter.return_value = User(username="testuser") | ||
|
||
|
@@ -398,3 +403,21 @@ def test_trusted_backend_proper_prerequisites(claims): | |
request=None, claims=claims | ||
) | ||
assert user is None | ||
|
||
|
||
def test_trusted_backend_create_new_user(user_getter, create_user, settings): | ||
# User does not exist and TRUSTED_PROVIDERS_NEW_USERS set? Create new user. | ||
settings.NENS_AUTH_TRUSTED_PROVIDERS = ["vanrees"] | ||
settings.NENS_AUTH_TRUSTED_PROVIDERS_NEW_USERS = ["vanrees"] | ||
claims = { | ||
"sub": "remote-uid", | ||
"cognito:username": "goede.klant", | ||
"email": "[email protected]", | ||
"identities": [{"providerName": "vanrees"}], | ||
} | ||
user_getter.side_effect = ObjectDoesNotExist | ||
user = backends.TrustedProviderMigrationBackend().authenticate( | ||
request=None, claims=claims | ||
) | ||
assert user == create_user.return_value | ||
create_user.assert_called_once_with(claims) |
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