-
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.
IDPF-275 Enable creation of inactive users via sso (#94)
- Loading branch information
Showing
16 changed files
with
172 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,22 +28,24 @@ def test_create_identity(mocker): | |
) | ||
# User is created | ||
profile = services.create_identity( | ||
id="john[email protected]", | ||
id="billy[email protected]", | ||
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=[ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
], | ||
is_active=False, | ||
primary_email="[email protected]", | ||
contact_email="[email protected]", | ||
) | ||
mock_user_create.assert_called_once_with( | ||
sso_email_id="[email protected]", | ||
sso_email_id="[email protected]", | ||
is_active=False, | ||
) | ||
mock_profiles_create.assert_called_once_with( | ||
sso_email_id="john[email protected]", | ||
sso_email_id="billy[email protected]", | ||
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=[ | ||
|
@@ -64,6 +66,7 @@ def test_existing_user(basic_user) -> None: | |
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
|
||
|
||
|
@@ -73,6 +76,7 @@ def test_new_user() -> None: | |
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
assert isinstance(profile, Profile) | ||
assert profile.pk | ||
|
@@ -86,6 +90,7 @@ def test_update_identity() -> None: | |
"Billy", | ||
"Bob", | ||
["[email protected]"], | ||
is_active=True, | ||
) | ||
assert User.objects.get(sso_email_id="[email protected]").is_active | ||
|
||
|
@@ -109,14 +114,16 @@ def test_delete_identity() -> None: | |
"Billy", | ||
"Bob", | ||
["[email protected]"], | ||
is_active=True, | ||
) | ||
|
||
services.delete_identity( | ||
profile, | ||
) | ||
with pytest.raises(Profile.DoesNotExist) as pex: | ||
services.get_by_id( | ||
services.get_identity_by_id( | ||
id=profile.sso_email_id, | ||
include_inactive=True, | ||
) | ||
|
||
assert str(pex.value.args[0]) == "Profile matching query does not exist." | ||
|
@@ -135,12 +142,14 @@ def test_bulk_delete_identity_users_from_sso(mocker) -> None: | |
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
services.create_identity( | ||
id="[email protected]", | ||
first_name="Gilly", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
|
||
mock_delete_identity = mocker.patch( | ||
|
@@ -152,14 +161,16 @@ def test_bulk_delete_identity_users_from_sso(mocker) -> None: | |
SSO_USER_EMAIL_ID: "[email protected]", | ||
SSO_FIRST_NAME: "Gilly", | ||
SSO_LAST_NAME: "Bob", | ||
SSO_USER_STATUS: "active", | ||
SSO_USER_STATUS: "inactive", | ||
SSO_EMAIL_ADDRESSES: ["[email protected]"], | ||
SSO_CONTACT_EMAIL_ADDRESS: "[email protected]", | ||
}, | ||
] | ||
|
||
profile1_to_delete = services.get_by_id("[email protected]") | ||
profile2_to_delete = services.get_by_id(id) | ||
profile1_to_delete = services.get_identity_by_id( | ||
"[email protected]", include_inactive=True | ||
) | ||
profile2_to_delete = services.get_identity_by_id(id, include_inactive=True) | ||
calls = [call(profile=profile1_to_delete), call(profile=profile2_to_delete)] | ||
|
||
services.bulk_delete_identity_users_from_sso(sso_users=sso_users) | ||
|
@@ -173,6 +184,7 @@ def test_bulk_create_and_update_identity_users_from_sso(mocker) -> None: | |
first_name="Gilly", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
mock_create_identity = mocker.patch( | ||
"core.services.create_identity", return_value="__profile__" | ||
|
@@ -194,7 +206,7 @@ def test_bulk_create_and_update_identity_users_from_sso(mocker) -> None: | |
SSO_USER_EMAIL_ID: "[email protected]", | ||
SSO_FIRST_NAME: "Alice", | ||
SSO_LAST_NAME: "Smith", | ||
SSO_USER_STATUS: "active", | ||
SSO_USER_STATUS: "inactive", | ||
SSO_EMAIL_ADDRESSES: ["[email protected]"], | ||
SSO_CONTACT_EMAIL_ADDRESS: "[email protected]", | ||
}, | ||
|
@@ -205,11 +217,14 @@ def test_bulk_create_and_update_identity_users_from_sso(mocker) -> None: | |
first_name="Alice", | ||
last_name="Smith", | ||
all_emails=["[email protected]", "[email protected]"], | ||
is_active=False, | ||
primary_email="[email protected]", | ||
contact_email="[email protected]", | ||
) | ||
mock_update_identity.assert_called_once_with( | ||
profile=services.get_by_id("[email protected]"), | ||
profile=services.get_identity_by_id( | ||
id="[email protected]", include_inactive=True | ||
), | ||
first_name="Jane", | ||
last_name="Doe", | ||
all_emails=["[email protected]", "[email protected]"], | ||
|
@@ -225,12 +240,14 @@ def test_sync_bulk_sso_users(mocker) -> None: | |
first_name="Billy", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
services.create_identity( | ||
id="[email protected]", | ||
first_name="Gilly", | ||
last_name="Bob", | ||
all_emails=["[email protected]"], | ||
is_active=True, | ||
) | ||
|
||
mock_get_bulk_user_records = mocker.patch( | ||
|
Oops, something went wrong.