@@ -232,13 +232,9 @@ class TestAuthenticationEdgeCases:
232232 """Test edge cases in authentication."""
233233
234234 @staticmethod
235- def _protected_exec_request (client , headers ):
236- """Hit a real authenticated endpoint with a minimal valid payload."""
237- return client .post (
238- "/exec" ,
239- headers = headers ,
240- json = {"code" : "print('auth edge')" , "lang" : "py" },
241- )
235+ def _protected_authenticated_request (client , headers ):
236+ """Hit a protected endpoint that exercises auth without exec mocks."""
237+ return client .get ("/health/detailed" , headers = headers )
242238
243239 def test_auth_with_special_characters_in_key (self , client , mock_services ):
244240 """Test authentication with special characters in API key."""
@@ -248,11 +244,12 @@ def test_auth_with_special_characters_in_key(self, client, mock_services):
248244 mock_settings .api_key = special_key
249245 headers = {"x-api-key" : special_key }
250246
251- response = self ._protected_exec_request (client , headers )
247+ response = self ._protected_authenticated_request (client , headers )
252248
253249 # Should handle special characters correctly
254- # If 401, auth rejected the key. If 200, auth accepted it.
255- assert response .status_code in [200 , 401 ]
250+ # If 401, auth rejected the key.
251+ # If 200/503, auth accepted it and the health endpoint responded.
252+ assert response .status_code in [200 , 401 , 503 ]
256253
257254 def test_auth_with_very_long_key (self , client , mock_services ):
258255 """Test authentication with very long API key."""
@@ -262,10 +259,10 @@ def test_auth_with_very_long_key(self, client, mock_services):
262259 mock_settings .api_key = long_key
263260 headers = {"x-api-key" : long_key }
264261
265- response = self ._protected_exec_request (client , headers )
262+ response = self ._protected_authenticated_request (client , headers )
266263
267264 # Should handle long keys (within reason)
268- assert response .status_code in [200 , 401 ]
265+ assert response .status_code in [200 , 401 , 503 ]
269266
270267 def test_auth_with_whitespace_in_key (self , client , mock_services ):
271268 """Test authentication with whitespace in API key."""
0 commit comments