@@ -51,7 +51,9 @@ def client(
5151
5252
5353async def test_reset_password_two_steps_action_confirmation_workflow (
54- client : TestClient , login_options : LoginOptions , capsys : pytest .CaptureFixture
54+ client : TestClient ,
55+ login_options : LoginOptions ,
56+ capsys : pytest .CaptureFixture ,
5557):
5658 assert client .app
5759
@@ -66,38 +68,37 @@ async def test_reset_password_two_steps_action_confirmation_workflow(
6668 assert response .url .path == reset_url .path
6769 await assert_status (response , status .HTTP_200_OK , MSG_EMAIL_SENT .format (** user ))
6870
69- out , err = capsys .readouterr ()
71+ out , _ = capsys .readouterr ()
7072 confirmation_url = parse_link (out )
7173 code = URL (confirmation_url ).parts [- 1 ]
7274
73- # emulates user click on email url
75+ # Emulates USER clicks on email's link
7476 response = await client .get (confirmation_url )
7577 assert response .status == 200
7678 assert (
7779 response .url .path_qs
7880 == URL (login_options .LOGIN_REDIRECT )
7981 .with_fragment (f"reset-password?code={ code } " )
8082 .path_qs
81- )
83+ ), "Should redirect to front-end with special fragment"
8284
83- # api/specs/webserver/v0/components/schemas/auth.yaml#/ResetPasswordForm
84- reset_allowed_url = client .app .router ["complete_reset_password" ].url_for (
85- code = code
86- )
85+ # Emulates FRONT-END:
86+ # SEE api/specs/webserver/v0/components/schemas/auth.yaml#/ResetPasswordForm
87+ complete_reset_password_url = client .app .router [
88+ "complete_reset_password"
89+ ].url_for (code = code )
8790 new_password = generate_password (10 )
8891 response = await client .post (
89- f"{ reset_allowed_url } " ,
92+ f"{ complete_reset_password_url } " ,
9093 json = {
9194 "password" : new_password ,
9295 "confirm" : new_password ,
9396 },
9497 )
95- payload = await response .json ()
96- assert response .status == 200 , payload
97- assert response .url .path == reset_allowed_url .path
9898 await assert_status (response , status .HTTP_200_OK , MSG_PASSWORD_CHANGED )
99+ assert response .url .path == complete_reset_password_url .path
99100
100- # Try new password
101+ # Try NEW password
101102 logout_url = client .app .router ["auth_logout" ].url_for ()
102103 response = await client .post (f"{ logout_url } " )
103104 assert response .url .path == logout_url .path
@@ -111,8 +112,8 @@ async def test_reset_password_two_steps_action_confirmation_workflow(
111112 "password" : new_password ,
112113 },
113114 )
114- assert response .url .path == login_url .path
115115 await assert_status (response , status .HTTP_200_OK , MSG_LOGGED_IN )
116+ assert response .url .path == login_url .path
116117
117118
118119async def test_unknown_email (
0 commit comments