@@ -143,8 +143,6 @@ def test_authenticate_invalid_jwt(TEST_CONSTANTS, mock_user_management):
143143
144144 response = session .authenticate ()
145145
146- print (response )
147-
148146 assert response .reason == AuthenticateWithSessionCookieFailureReason .INVALID_JWT
149147
150148
@@ -192,19 +190,12 @@ def test_authenticate_success(TEST_CONSTANTS, mock_user_management):
192190 "entitlements" : ["feature_1" ],
193191 }
194192
195- with (
196- # Mock unsealing the session data
197- patch .object (Session , "unseal_data" , return_value = mock_session ),
198- # Mock JWT validation
199- patch .object (session , "is_valid_jwt" , return_value = True ),
200- # Mock JWT decoding
201- patch ("jwt.decode" , return_value = mock_jwt_payload ),
202- # Mock JWT signing key retrieval
203- patch .object (
204- session .jwks ,
205- "get_signing_key_from_jwt" ,
206- return_value = Mock (key = TEST_CONSTANTS ["PUBLIC_KEY" ]),
207- ),
193+ with patch .object (Session , "unseal_data" , return_value = mock_session ), patch .object (
194+ session , "is_valid_jwt" , return_value = True
195+ ), patch ("jwt.decode" , return_value = mock_jwt_payload ), patch .object (
196+ session .jwks ,
197+ "get_signing_key_from_jwt" ,
198+ return_value = Mock (key = TEST_CONSTANTS ["PUBLIC_KEY" ]),
208199 ):
209200 response = session .authenticate ()
210201
@@ -273,9 +264,8 @@ def test_refresh_success(TEST_CONSTANTS, mock_user_management):
273264 cookie_password = TEST_CONSTANTS ["COOKIE_PASSWORD" ],
274265 )
275266
276- with (
277- patch .object (session , "is_valid_jwt" , return_value = True ),
278- patch (
267+ with patch .object (session , "is_valid_jwt" , return_value = True ) as _ :
268+ with patch (
279269 "jwt.decode" ,
280270 return_value = {
281271 "sid" : TEST_CONSTANTS ["SESSION_ID" ],
@@ -284,13 +274,12 @@ def test_refresh_success(TEST_CONSTANTS, mock_user_management):
284274 "permissions" : ["read" ],
285275 "entitlements" : ["feature_1" ],
286276 },
287- ),
288- ):
289- response = session .refresh ()
277+ ):
278+ response = session .refresh ()
290279
291- assert isinstance (response , RefreshWithSessionCookieSuccessResponse )
292- assert response .authenticated is True
293- assert response .user .id == test_user ["id" ]
280+ assert isinstance (response , RefreshWithSessionCookieSuccessResponse )
281+ assert response .authenticated is True
282+ assert response .user .id == test_user ["id" ]
294283
295284 # Verify the refresh token was used correctly
296285 mock_user_management .authenticate_with_refresh_token .assert_called_once_with (
@@ -310,8 +299,6 @@ def test_seal_data(TEST_CONSTANTS):
310299
311300 # Test unsealing
312301 unsealed = Session .unseal_data (sealed , TEST_CONSTANTS ["COOKIE_PASSWORD" ])
313- print (test_data )
314- print (unsealed )
315302
316303 assert unsealed == test_data
317304
0 commit comments