@@ -51,7 +51,8 @@ async def test_routes_gated_off_by_default(get_session, UserModel) -> None:
5151 await auth .initialize ()
5252 async with _client (app ) as c :
5353 await _register_login (c )
54- assert (await c .get ("/sessions" )).status_code == 404 # not mounted
54+ resp = await c .get ("/sessions" )
55+ assert resp .status_code == 404 # not mounted
5556 await auth .shutdown ()
5657
5758
@@ -63,7 +64,8 @@ async def test_logout_all_revokes_and_clears(get_session, UserModel) -> None:
6364 r = await c .post ("/logout-all" , headers = {"X-CSRF-Token" : csrf })
6465 assert r .status_code == 200
6566 assert r .json ()["revoked" ] >= 1
66- assert (await c .get ("/me" )).status_code == 401 # cookie cleared, session gone
67+ resp = await c .get ("/me" )
68+ assert resp .status_code == 401 # cookie cleared, session gone
6769 await auth .shutdown ()
6870
6971
@@ -75,8 +77,10 @@ async def test_logout_all_keep_current(get_session, UserModel) -> None:
7577 await _register_login (b ) # second session for the same user
7678 r = await a .post ("/logout-all?keep_current=true" , headers = {"X-CSRF-Token" : csrf_a })
7779 assert r .status_code == 200 and r .json ()["revoked" ] == 1 # revoked B, kept A
78- assert (await a .get ("/me" )).status_code == 200 # caller's session survives
79- assert (await b .get ("/me" )).status_code == 401 # the other session is gone
80+ resp = await a .get ("/me" )
81+ assert resp .status_code == 200 # caller's session survives
82+ resp = await b .get ("/me" )
83+ assert resp .status_code == 401 # the other session is gone
8084 await auth .shutdown ()
8185
8286
@@ -108,23 +112,24 @@ async def test_delete_own_other_unknown_and_cross_user(get_session, UserModel) -
108112 # revoke alice's other session (B)
109113 r = await a .delete (f"/sessions/{ b_id } " , headers = {"X-CSRF-Token" : csrf_a })
110114 assert r .status_code == 200
111- assert (await b .get ("/me" )).status_code == 401
115+ resp = await b .get ("/me" )
116+ assert resp .status_code == 401
112117
113118 # unknown id -> 404
114- assert (
115- await a .delete ("/sessions/nope" , headers = {"X-CSRF-Token" : csrf_a })
116- ).status_code == 404
119+ resp = await a .delete ("/sessions/nope" , headers = {"X-CSRF-Token" : csrf_a })
120+ assert resp .status_code == 404
117121
118122 # another user's session id -> 404 (ownership check, no leak)
119- assert (
120- await other . delete ( f"/sessions/ { a_id } " , headers = { "X-CSRF-Token" : csrf_other })
121- ). status_code == 404
122- assert ( await a . get ( "/me" )) .status_code == 200 # untouched
123+ resp = await other . delete ( f"/sessions/ { a_id } " , headers = { "X-CSRF-Token" : csrf_other })
124+ assert resp . status_code == 404
125+ resp = await a . get ( "/me" )
126+ assert resp .status_code == 200 # untouched
123127
124128 # revoke own current session -> 200 + cookie cleared
125129 r = await a .delete (f"/sessions/{ a_id } " , headers = {"X-CSRF-Token" : csrf_a })
126130 assert r .status_code == 200
127- assert (await a .get ("/me" )).status_code == 401
131+ resp = await a .get ("/me" )
132+ assert resp .status_code == 401
128133 await auth .shutdown ()
129134
130135
@@ -152,7 +157,8 @@ async def test_csrf_refresh_no_session_401(get_session, UserModel) -> None:
152157 app , auth = _build (get_session , UserModel )
153158 await auth .initialize ()
154159 async with _client (app ) as c :
155- assert (await c .post ("/csrf/refresh" )).status_code == 401 # no session cookie
160+ resp = await c .post ("/csrf/refresh" )
161+ assert resp .status_code == 401 # no session cookie
156162 await auth .shutdown ()
157163
158164
@@ -161,5 +167,6 @@ async def test_csrf_refresh_disabled_400(get_session, UserModel) -> None:
161167 await auth .initialize ()
162168 async with _client (app ) as c :
163169 await _register_login (c )
164- assert (await c .post ("/csrf/refresh" )).status_code == 400 # CSRF disabled
170+ resp = await c .post ("/csrf/refresh" )
171+ assert resp .status_code == 400 # CSRF disabled
165172 await auth .shutdown ()
0 commit comments