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

Function test_org_config_loading

test_security.py:476–566  ·  view source on GitHub ↗

Test organization-level config loading.

()

Source from the content-addressed store, hash-verified

474
475
476def test_org_config_loading():
477 """Test organization-level config loading."""
478 print("\nTesting org config loading:\n")
479 passed = 0
480 failed = 0
481
482 with tempfile.TemporaryDirectory() as tmpdir:
483 # Use temporary_home for cross-platform compatibility
484 with temporary_home(tmpdir):
485 org_dir = Path(tmpdir) / ".autoforge"
486 org_dir.mkdir()
487 org_config_path = org_dir / "config.yaml"
488
489 # Test 1: Valid org config
490 org_config_path.write_text("""version: 1
491allowed_commands:
492 - name: jq
493 description: JSON processor
494blocked_commands:
495 - aws
496 - kubectl
497""")
498 config = load_org_config()
499 if config and config["version"] == 1:
500 if len(config["allowed_commands"]) == 1 and len(config["blocked_commands"]) == 2:
501 print(" PASS: Load valid org config")
502 passed += 1
503 else:
504 print(" FAIL: Load valid org config (wrong counts)")
505 failed += 1
506 else:
507 print(" FAIL: Load valid org config")
508 print(f" Got: {config}")
509 failed += 1
510
511 # Test 2: Missing file returns None
512 org_config_path.unlink()
513 config = load_org_config()
514 if config is None:
515 print(" PASS: Missing org config returns None")
516 passed += 1
517 else:
518 print(" FAIL: Missing org config returns None")
519 failed += 1
520
521 # Test 3: Non-string command name is rejected
522 org_config_path.write_text("""version: 1
523allowed_commands:
524 - name: 123
525 description: Invalid numeric name
526""")
527 config = load_org_config()
528 if config is None:
529 print(" PASS: Non-string command name rejected")
530 passed += 1
531 else:
532 print(" FAIL: Non-string command name rejected")
533 print(f" Got: {config}")

Callers 1

mainFunction · 0.85

Calls 2

load_org_configFunction · 0.90
temporary_homeFunction · 0.70

Tested by

no test coverage detected