@@ -68,7 +68,7 @@ def test_reset(thread_cache: ThreadCache):
6868 thread_cache .config .bypassed_ips .add ("192.168.1.1" )
6969 thread_cache .config .blocked_uids .add ("user123" )
7070 thread_cache .stats .increment_total_hits ()
71- thread_cache .stats .on_detected_attack (blocked = True )
71+ thread_cache .stats .on_detected_attack (blocked = True , operation = "test" )
7272
7373 thread_cache .reset ()
7474
@@ -236,9 +236,11 @@ def test_renew_called_with_correct_args(mock_get_comms, thread_cache: ThreadCach
236236 # Setup initial state
237237 thread_cache .stats .increment_total_hits ()
238238 thread_cache .stats .increment_total_hits ()
239- thread_cache .stats .on_detected_attack (blocked = True )
240- thread_cache .stats .on_detected_attack (blocked = False )
241- thread_cache .stats .on_detected_attack (blocked = False )
239+ thread_cache .stats .operations .register_call ("op1" , "sql_op" )
240+ thread_cache .stats .operations .register_call ("op2" , "sql_op" )
241+ thread_cache .stats .on_detected_attack (blocked = True , operation = "op1" )
242+ thread_cache .stats .on_detected_attack (blocked = False , operation = "op1" )
243+ thread_cache .stats .on_detected_attack (blocked = False , operation = "op2" )
242244 thread_cache .routes .initialize_route ({"method" : "GET" , "route" : "/test" })
243245 thread_cache .routes .increment_route ({"method" : "GET" , "route" : "/test" })
244246
@@ -269,6 +271,18 @@ def test_renew_called_with_correct_args(mock_get_comms, thread_cache: ThreadCach
269271 "aborted" : 0 ,
270272 "attacksDetected" : {"blocked" : 1 , "total" : 3 },
271273 },
274+ "operations" : {
275+ "op1" : {
276+ "attacksDetected" : {"blocked" : 1 , "total" : 2 },
277+ "kind" : "sql_op" ,
278+ "total" : 1 ,
279+ },
280+ "op2" : {
281+ "attacksDetected" : {"blocked" : 0 , "total" : 1 },
282+ "kind" : "sql_op" ,
283+ "total" : 1 ,
284+ },
285+ },
272286 },
273287 "middleware_installed" : False ,
274288 "hostnames" : [],
@@ -313,6 +327,7 @@ def test_sync_data_for_users(mock_get_comms, thread_cache: ThreadCache):
313327 "aborted" : 0 ,
314328 "attacksDetected" : {"total" : 0 , "blocked" : 0 },
315329 },
330+ "operations" : {},
316331 },
317332 "middleware_installed" : False ,
318333 "hostnames" : [],
@@ -362,6 +377,7 @@ def test_renew_called_with_empty_routes(mock_get_comms, thread_cache: ThreadCach
362377 "aborted" : 0 ,
363378 "attacksDetected" : {"total" : 0 , "blocked" : 0 },
364379 },
380+ "operations" : {},
365381 },
366382 "middleware_installed" : False ,
367383 "hostnames" : [],
@@ -399,6 +415,7 @@ def test_renew_called_with_no_requests(mock_get_comms, thread_cache: ThreadCache
399415 "aborted" : 0 ,
400416 "attacksDetected" : {"total" : 0 , "blocked" : 0 },
401417 },
418+ "operations" : {},
402419 },
403420 "middleware_installed" : False ,
404421 "hostnames" : [],
0 commit comments