| 263 | |
| 264 | #[test] |
| 265 | fn test_policy_allow_all() { |
| 266 | let policy = PermissionPolicy::new().allow_all(&["Bash(cargo:*)", "Bash(npm:*)", "Grep(*)"]); |
| 267 | |
| 268 | assert_eq!(policy.allow.len(), 3); |
| 269 | assert!(policy.is_allowed("Bash", &json!({"command": "cargo build"}))); |
| 270 | assert!(policy.is_allowed("Bash", &json!({"command": "npm run test"}))); |
| 271 | assert!(policy.is_allowed("Grep", &json!({"pattern": "foo"}))); |
| 272 | } |
| 273 | |
| 274 | // ======================================================================== |
| 275 | // PermissionRule Deserialization Tests |