@@ -37,27 +37,32 @@ def test_validate_folder_all_valid(temp_policy_dir):
3737 (temp_policy_dir / "valid2.json" ).write_text (VALID_POLICY )
3838
3939 result = validate_policy_folder (str (temp_policy_dir ))
40- assert result == 0 # all valid, should pass
40+ assert result == [] # all valid, no findings
4141
4242def test_validate_folder_some_invalid (temp_policy_dir ):
4343 (temp_policy_dir / "good.json" ).write_text (VALID_POLICY )
4444 (temp_policy_dir / "bad.json" ).write_text (INVALID_POLICY )
4545
4646 result = validate_policy_folder (str (temp_policy_dir ))
47- assert result == 1 # one invalid
47+ assert any (f ["level" ] == "high" for f in result )
48+ assert any ("wildcard" in f ["message" ] for f in result )
4849
4950def test_validate_folder_empty (temp_policy_dir ):
5051 result = validate_policy_folder (str (temp_policy_dir ))
51- assert result == 1 # no policy files
52+ assert len (result ) == 1
53+ assert result [0 ]["level" ] == "warning"
54+ assert "No policy files found" in result [0 ]["message" ]
5255
5356def test_validate_folder_not_exist ():
5457 result = validate_policy_folder ("non_existent_folder_123" )
55- assert result == 1 # should gracefully error out
58+ assert len (result ) == 1
59+ assert result [0 ]["level" ] == "error"
60+ assert "not found" in result [0 ]["message" ]
5661
5762def test_folder_with_malformed_json (tmp_path ):
5863 (tmp_path / "bad.json" ).write_text ('{"Version": "2012-10-17", "Statement": [INVALID_JSON' )
5964 result = validate_policy_folder (str (tmp_path ))
60- assert result == 1 # should catch parse failure
65+ assert any ( "failed" in f [ "message" ] for f in result )
6166
6267def test_folder_with_yaml_file (tmp_path ):
6368 good_yaml = """
@@ -69,7 +74,7 @@ def test_folder_with_yaml_file(tmp_path):
6974"""
7075 (tmp_path / "good.yaml" ).write_text (good_yaml )
7176 result = validate_policy_folder (str (tmp_path ))
72- assert result == 0 # valid YAML should pass
77+ assert result == [] # no findings
7378
7479def test_folder_with_good_and_bad_files (tmp_path ):
7580 good = {
@@ -79,4 +84,4 @@ def test_folder_with_good_and_bad_files(tmp_path):
7984 (tmp_path / "good.json" ).write_text (json .dumps (good ))
8085 (tmp_path / "broken.json" ).write_text ('INVALID' )
8186 result = validate_policy_folder (str (tmp_path ))
82- assert result == 1 # one fails, so exit code should be 1
87+ assert any ( "failed" in f [ "message" ] for f in result )
0 commit comments