File size: 761 Bytes
0953e56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from iac_secfix_agents.llm import parse_fix_candidate


def test_parse_fix_candidate_from_json():
    candidate, ok = parse_fix_candidate(
        '{"patch":"diff","fixed_file":"resource \\"x\\" \\"y\\" {}","resolved_policy_ids":["CKV_X_1"],"explanation":"ok","verification_commands":[],"risk_notes":[],"requires_human_approval":true}'
    )
    assert ok
    assert candidate is not None
    assert candidate.resolved_policy_ids == ["CKV_X_1"]


def test_parse_fix_candidate_from_wrapped_text():
    candidate, ok = parse_fix_candidate(
        'Here is the JSON: {"patch":"","fixed_file":"kind: Pod\\n","resolved":["CKV_K8S_8"],"summary":"fixed"}'
    )
    assert ok
    assert candidate is not None
    assert candidate.resolved_policy_ids == ["CKV_K8S_8"]