@@ -55,11 +55,11 @@ def test_register_endpoint(unauth_client: TestClient, session: Session):
5555 "password" : "NewPass123!@#" ,
5656 "confirm_password" : "NewPass123!@#"
5757 },
58- follow_redirects = False
5958 )
60-
59+
6160 # Just check the response status code
6261 assert response .status_code == 303
62+ assert response .headers ["location" ] == str (app .url_path_for ("read_dashboard" ))
6363
6464 # Verify the account was created
6565 account = session .exec (select (Account ).where (Account .email == "new@example.com" )).first ()
@@ -79,9 +79,9 @@ def test_login_endpoint(unauth_client: TestClient, test_account: Account):
7979 "email" : test_account .email ,
8080 "password" : "Test123!@#"
8181 },
82- follow_redirects = False
8382 )
8483 assert response .status_code == 303
84+ assert response .headers ["location" ] == str (app .url_path_for ("read_dashboard" ))
8585
8686 # Check if cookies are set
8787 cookies = response .cookies
@@ -99,9 +99,9 @@ def test_refresh_token_endpoint(auth_client: TestClient, test_account: Account):
9999
100100 response = auth_client .post (
101101 app .url_path_for ("refresh_token" ),
102- follow_redirects = False
103102 )
104103 assert response .status_code == 303
104+ assert response .headers ["location" ] == str (app .url_path_for ("read_dashboard" ))
105105
106106 # Check for new tokens in headers
107107 cookie_headers = response .headers .get_list ("set-cookie" )
@@ -125,9 +125,9 @@ def test_password_reset_flow(unauth_client: TestClient, session: Session, test_a
125125 response = unauth_client .post (
126126 app .url_path_for ("forgot_password" ),
127127 data = {"email" : test_account .email },
128- follow_redirects = False
129128 )
130129 assert response .status_code == 303
130+ assert response .headers ["location" ] == "/forgot_password?show_form=false"
131131
132132 # Verify the email was "sent" with correct parameters
133133 mock_resend_send .assert_called_once ()
@@ -167,9 +167,9 @@ def test_password_reset_flow(unauth_client: TestClient, session: Session, test_a
167167def test_logout_endpoint (auth_client : TestClient ):
168168 response = auth_client .get (
169169 app .url_path_for ("logout" ),
170- follow_redirects = False
171170 )
172171 assert response .status_code == 303
172+ assert response .headers ["location" ] == "/"
173173
174174 # Check for cookie deletion in headers
175175 cookie_headers = response .headers .get_list ("set-cookie" )
@@ -227,9 +227,9 @@ def test_password_reset_email_url(unauth_client: TestClient, session: Session, t
227227 response = unauth_client .post (
228228 app .url_path_for ("forgot_password" ),
229229 data = {"email" : test_account .email },
230- follow_redirects = False
231230 )
232231 assert response .status_code == 303
232+ assert response .headers ["location" ] == "/forgot_password?show_form=false"
233233
234234 # Get the reset token from the database
235235 reset_token = session .exec (select (PasswordResetToken )
@@ -269,16 +269,16 @@ def test_forgot_password_does_not_send_second_email_while_token_is_active(
269269 first_response = unauth_client .post (
270270 app .url_path_for ("forgot_password" ),
271271 data = {"email" : test_account .email },
272- follow_redirects = False ,
273272 )
274273 assert first_response .status_code == 303
274+ assert first_response .headers ["location" ] == "/forgot_password?show_form=false"
275275
276276 second_response = unauth_client .post (
277277 app .url_path_for ("forgot_password" ),
278278 data = {"email" : test_account .email },
279- follow_redirects = False ,
280279 )
281280 assert second_response .status_code == 303
281+ assert second_response .headers ["location" ] == "/forgot_password?show_form=false"
282282
283283 tokens = session .exec (
284284 select (PasswordResetToken ).where (PasswordResetToken .account_id == test_account .id )
@@ -294,9 +294,8 @@ def test_request_email_update_success(auth_client: TestClient, test_account: Acc
294294 response = auth_client .post (
295295 app .url_path_for ("request_email_update" ),
296296 data = {"email" : test_account .email , "new_email" : new_email },
297- follow_redirects = False
298297 )
299-
298+
300299 assert response .status_code == 303
301300 assert f"{ app .url_path_for ('read_profile' )} ?email_update_requested=true" in response .headers ["location" ]
302301
@@ -316,7 +315,6 @@ def test_request_email_update_same_email_returns_error_page(auth_client: TestCli
316315 response = auth_client .post (
317316 app .url_path_for ("request_email_update" ),
318317 data = {"email" : test_account .email , "new_email" : test_account .email },
319- follow_redirects = False ,
320318 )
321319
322320 assert response .status_code == 401
@@ -349,10 +347,10 @@ def test_request_email_update_unauthenticated(unauth_client: TestClient):
349347 response = unauth_client .post (
350348 app .url_path_for ("request_email_update" ),
351349 data = {"email" : "test@example.com" , "new_email" : "new@example.com" },
352- follow_redirects = False
353350 )
354-
351+
355352 assert response .status_code == 303 # Redirect to login
353+ assert response .headers ["location" ] == str (app .url_path_for ("read_login" ))
356354
357355
358356def test_confirm_email_update_success (unauth_client : TestClient , session : Session , test_account : Account ):
@@ -371,7 +369,6 @@ def test_confirm_email_update_success(unauth_client: TestClient, session: Sessio
371369 "token" : update_token .token ,
372370 "new_email" : new_email
373371 },
374- follow_redirects = False
375372 )
376373
377374 assert response .status_code == 303
@@ -486,9 +483,9 @@ def test_login_success_resets_email_limiter(unauth_client: TestClient, test_acco
486483 response = unauth_client .post (
487484 app .url_path_for ("login" ),
488485 data = {"email" : test_account .email , "password" : "Test123!@#" },
489- follow_redirects = False ,
490486 )
491487 assert response .status_code == 303
488+ assert response .headers ["location" ] == str (app .url_path_for ("read_dashboard" ))
492489
493490 # Verify the limiter was reset — full allowance available
494491 assert login_email_limiter .remaining (f"email:{ test_account .email .lower ().strip ()} " ) == login_email_limiter .max_attempts
@@ -505,7 +502,6 @@ def test_register_ip_rate_limit(unauth_client: TestClient, session: Session):
505502 "password" : "Test123!@#" ,
506503 "confirm_password" : "Test123!@#" ,
507504 },
508- follow_redirects = False ,
509505 )
510506
511507 response = unauth_client .post (
@@ -526,13 +522,11 @@ def test_forgot_password_ip_rate_limit(unauth_client: TestClient):
526522 unauth_client .post (
527523 app .url_path_for ("forgot_password" ),
528524 data = {"email" : f"user{ i } @example.com" },
529- follow_redirects = False ,
530525 )
531526
532527 response = unauth_client .post (
533528 app .url_path_for ("forgot_password" ),
534529 data = {"email" : "extra@example.com" },
535- follow_redirects = False ,
536530 )
537531 assert response .status_code == 429
538532
@@ -543,7 +537,6 @@ def test_forgot_password_email_rate_limit(unauth_client: TestClient, test_accoun
543537 unauth_client .post (
544538 app .url_path_for ("forgot_password" ),
545539 data = {"email" : test_account .email },
546- follow_redirects = False ,
547540 )
548541
549542 response = unauth_client .post (
0 commit comments