-
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
1 parent
672e164
commit 684e7e8
Showing
2 changed files
with
51 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -116,7 +116,7 @@ def test_reused_magic_link_redirects_for_active_session( | |
assert second_response.status_code == 302 | ||
|
||
def test_reused_magic_link_with_active_session_shows_landing( | ||
self, authenticator_test_client, create_magic_link, mock_get_applications_for_account | ||
self, authenticator_test_client, create_magic_link, mock_get_applications_for_auth_frontend | ||
): | ||
""" | ||
GIVEN a running Flask client, redis instance and | ||
|
@@ -133,6 +133,9 @@ def test_reused_magic_link_with_active_session_shows_landing( | |
with ( | ||
mock.patch("authenticator.models.fund.FundMethods.get_fund") as mock_get_fund, | ||
mock.patch("authenticator.frontend.magic_links.routes.get_round_data") as mock_get_round_data, | ||
mock.patch( | ||
"authenticator.frontend.magic_links.routes.MagicLinkMethods.redis_mlinks", create=True | ||
) as mock_redis_mlinks, | ||
): | ||
# Mock get_fund() called in get_magic_link() | ||
mock_fund = mock.MagicMock() | ||
|
@@ -148,8 +151,13 @@ def test_reused_magic_link_with_active_session_shows_landing( | |
mock_round.configure_mock(contact_email="[email protected]") | ||
mock_round.configure_mock(reference_contact_page_over_email=False) | ||
mock_round.configure_mock(is_expression_of_interest=False) | ||
mock_round.configure_mock(has_eligibility=True) | ||
mock_get_round_data.return_value = mock_round | ||
|
||
mock_redis_mlinks.get.return_value = json.dumps( | ||
{"accountId": "usera", "iat": 1736312454, "exp": 1736316114} | ||
).encode("utf-8") | ||
|
||
# use magic link landing but unauthorised | ||
landing_response = authenticator_test_client.get(landing_endpoint) | ||
|
||
|
@@ -177,10 +185,16 @@ def test_reused_magic_link_with_active_session_shows_landing( | |
== 1 | ||
) | ||
|
||
mock_redis_mlinks.get.return_value = None | ||
|
||
# use link | ||
use_link_response = authenticator_test_client.get(use_endpoint) | ||
assert use_link_response.status_code == 302 | ||
|
||
mock_redis_mlinks.get.return_value = json.dumps( | ||
{"accountId": "usera", "iat": 1736312454, "exp": 1736316114} | ||
).encode("utf-8") | ||
|
||
# re-use magic link landing but now authorised (cookie present) | ||
second_landing_response = authenticator_test_client.get(landing_endpoint) | ||
assert second_landing_response.status_code == 200 | ||
|