MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / test_pkill_extensibility

Function test_pkill_extensibility

test_security.py:692–923  ·  view source on GitHub ↗

Test that pkill processes can be extended via config.

()

Source from the content-addressed store, hash-verified

690
691
692def test_pkill_extensibility():
693 """Test that pkill processes can be extended via config."""
694 print("\nTesting pkill process extensibility:\n")
695 passed = 0
696 failed = 0
697
698 # Test 1: Default processes work without config
699 allowed, reason = validate_pkill_command("pkill node")
700 if allowed:
701 print(" PASS: Default process 'node' allowed")
702 passed += 1
703 else:
704 print(f" FAIL: Default process 'node' should be allowed: {reason}")
705 failed += 1
706
707 # Test 2: Non-default process blocked without config
708 allowed, reason = validate_pkill_command("pkill python")
709 if not allowed:
710 print(" PASS: Non-default process 'python' blocked without config")
711 passed += 1
712 else:
713 print(" FAIL: Non-default process 'python' should be blocked without config")
714 failed += 1
715
716 # Test 3: Extra processes allowed when passed
717 allowed, reason = validate_pkill_command("pkill python", extra_processes={"python"})
718 if allowed:
719 print(" PASS: Extra process 'python' allowed when configured")
720 passed += 1
721 else:
722 print(f" FAIL: Extra process 'python' should be allowed when configured: {reason}")
723 failed += 1
724
725 # Test 4: Default processes still work with extra processes
726 allowed, reason = validate_pkill_command("pkill npm", extra_processes={"python"})
727 if allowed:
728 print(" PASS: Default process 'npm' still works with extra processes")
729 passed += 1
730 else:
731 print(f" FAIL: Default process should still work: {reason}")
732 failed += 1
733
734 # Test 5: Test get_effective_pkill_processes with org config
735 with tempfile.TemporaryDirectory() as tmphome:
736 with tempfile.TemporaryDirectory() as tmpproject:
737 with temporary_home(tmphome):
738 org_dir = Path(tmphome) / ".autoforge"
739 org_dir.mkdir()
740 org_config_path = org_dir / "config.yaml"
741
742 # Create org config with extra pkill processes
743 org_config_path.write_text("""version: 1
744pkill_processes:
745 - python
746 - uvicorn
747""")
748
749 project_dir = Path(tmpproject)

Callers 1

mainFunction · 0.85

Calls 5

validate_pkill_commandFunction · 0.90
bash_security_hookFunction · 0.90
load_org_configFunction · 0.90
temporary_homeFunction · 0.70

Tested by

no test coverage detected