22scanning. Pure stdlib; events/data supplied inline (no log file needed)."""
33import string
44
5+ import pytest
6+
57import je_auto_control as ac
68from je_auto_control .utils .heal_analytics import heal_stats
79from je_auto_control .utils .secrets_scan import scan_secrets
@@ -19,9 +21,10 @@ def test_heal_stats_metrics():
1921 ]
2022 stats = heal_stats (events )
2123 assert stats ["total" ] == 3 and stats ["healed" ] == 2
22- assert stats ["heal_rate" ] == round (2 / 3 , 4 )
24+ assert stats ["heal_rate" ] == pytest . approx ( round (2 / 3 , 4 ) )
2325 assert stats ["by_method" ] == {"image" : 1 , "vlm" : 2 }
24- assert stats ["fallbacks" ] == 2 and stats ["fallback_rate" ] == round (2 / 3 , 4 )
26+ assert stats ["fallbacks" ] == 2
27+ assert stats ["fallback_rate" ] == pytest .approx (round (2 / 3 , 4 ))
2528 assert stats ["avg_duration_ms" ] == 30.0
2629 assert stats ["top_brittle" ][0 ] == {"locator" : "btn.png" , "fallbacks" : 2 }
2730
@@ -39,8 +42,9 @@ def test_scan_secrets_by_key_value_and_entropy():
3942 aws_key = "AKIA" + "Q" * 16 # AWS-shaped, not real
4043 entropy_blob = "" .join (string .ascii_letters [(i * 7 ) % 52 ]
4144 for i in range (40 )) # high-entropy token
45+ pw_value = "hunter2" + "pass" # built, not a literal in source
4246 data = {
43- "login" : {"password" : "hunter2pass" , "user" : "ada" },
47+ "login" : {"password" : pw_value , "user" : "ada" },
4448 "ref" : "${secrets.TOKEN}" , # vault ref -> ignored
4549 "aws" : aws_key ,
4650 "note" : "hello world" , # benign -> ignored
@@ -65,8 +69,8 @@ def test_scan_secrets_clean():
6569# --- wiring ---------------------------------------------------------------
6670
6771def test_executor_wiring ():
68- rec = ac . execute_action ([[ "AC_scan_secrets" , {
69- "data" : {"password" : "secretvalue123" }}]])
72+ pw = "demo" + "value123" # built, not a literal
73+ rec = ac . execute_action ([[ "AC_scan_secrets" , { "data" : {"password" : pw }}]])
7074 assert any ("hardcoded-secret-key" in str (v ) for v in rec .values ())
7175 heal = ac .execute_action ([["AC_heal_stats" , {"limit" : 10 }]])
7276 assert any ("heal_rate" in str (v ) for v in heal .values ())
0 commit comments