Test that invalid YAML config is safely ignored.
()
| 327 | |
| 328 | |
| 329 | def test_invalid_yaml_ignored(): |
| 330 | """Test that invalid YAML config is safely ignored.""" |
| 331 | print("\n" + "=" * 70) |
| 332 | print("TEST 8: Invalid YAML safely ignored") |
| 333 | print("=" * 70) |
| 334 | |
| 335 | with tempfile.TemporaryDirectory() as tmpdir: |
| 336 | project_dir = Path(tmpdir) |
| 337 | |
| 338 | # Create invalid YAML |
| 339 | autoforge_dir = project_dir / ".autoforge" |
| 340 | autoforge_dir.mkdir() |
| 341 | (autoforge_dir / "allowed_commands.yaml").write_text("invalid: yaml: content:") |
| 342 | |
| 343 | # Try to run ls (should still work - falls back to defaults) |
| 344 | input_data = {"tool_name": "Bash", "tool_input": {"command": "ls"}} |
| 345 | context = {"project_dir": str(project_dir)} |
| 346 | |
| 347 | result = asyncio.run(bash_security_hook(input_data, context=context)) |
| 348 | |
| 349 | if result.get("decision") != "block": |
| 350 | print("✅ PASS: Invalid YAML ignored, defaults still work") |
| 351 | return True |
| 352 | else: |
| 353 | print("❌ FAIL: Should fall back to defaults when YAML is invalid") |
| 354 | print(f" Reason: {result.get('reason', 'N/A')}") |
| 355 | return False |
| 356 | |
| 357 | |
| 358 | def test_100_command_limit(): |
nothing calls this directly
no test coverage detected