-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: prevent school change through email migration
- Loading branch information
Showing
2 changed files
with
25 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,7 +245,7 @@ def test_create_and_activate_user( | |
headers={"Authorization": f"Bearer {token_admin_user}"}, | ||
) | ||
|
||
assert user_detail.json()["school_id"] == expected_school_id.value | ||
assert user_detail.json()["school_id"] == str(expected_school_id.value) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
@@ -362,6 +362,18 @@ def test_update_user(client: TestClient) -> None: | |
assert response.status_code == 204 | ||
|
||
|
||
async def test_migrate_mail_with_school_change(client: TestClient) -> None: | ||
token = create_api_access_token(student_user_with_old_email) | ||
|
||
# Start the migration process | ||
response = client.post( | ||
"/users/migrate-mail", | ||
json={"new_email": "[email protected]"}, | ||
headers={"Authorization": f"Bearer {token}"}, | ||
) | ||
assert response.status_code == 400 | ||
|
||
|
||
async def test_migrate_mail(mocker: MockerFixture, client: TestClient) -> None: | ||
# NOTE: we don't want to mock app.core.security.generate_token but | ||
# app.core.users.endpoints_users.security.generate_token which is the imported version of the function | ||
|