"""Tests for safety path matcher.""" from interns_mcp.safety import check_paths def test_clean_paths_pass(): assert check_paths(["/home/user/project/src/main.py"]) == [] def test_env_file_blocked(): blocked = check_paths(["project/.env"]) assert len(blocked) == 1 assert blocked[0]["pattern"] == "**/.env" def test_env_local_blocked(): blocked = check_paths(["project/.env.local"]) assert len(blocked) == 1 def test_secrets_dir_blocked(): blocked = check_paths(["project/secrets/api_key.txt"]) assert len(blocked) == 1 def test_pem_file_blocked(): blocked = check_paths(["/home/user/.ssh/id_rsa.pem"]) assert len(blocked) == 1 def test_ssh_dir_blocked(): blocked = check_paths(["/home/user/.ssh/config"]) assert len(blocked) == 1 def test_credentials_blocked(): blocked = check_paths(["project/credentials.json"]) assert len(blocked) == 1 def test_key_file_blocked(): blocked = check_paths(["project/server.key"]) assert len(blocked) == 1 def test_mixed_paths(): blocked = check_paths(["src/app.py", "project/.env", "README.md"]) assert len(blocked) == 1 assert blocked[0]["path"] == "project/.env" def test_extra_patterns(): blocked = check_paths(["data/private.csv"], extra_patterns=["data/**"]) assert len(blocked) == 1