1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// use restrict::*;
// #[cfg(test)]
// mod tests {
// use super::*;
// use restrict::policy::Policy;
// use syscall::Syscall;
//
// #[test]
// fn test_create_policy_with_default_action_allow() {
// let policy = Policy::allow_all();
// assert!(policy.is_ok(), "Allow all policy creation failed");
// }
//
// #[test]
// fn test_create_policy_with_default_action_deny() {
// let policy = Policy::deny_all();
// assert!(policy.is_ok(), "Deny all policy creation failed");
// }
//
// #[test]
// fn test_redundunt_allow_policy() {
// let mut policy = Policy::allow_all().unwrap();
// let result = policy.allow(Syscall::Read);
//
// match result {
// Err(SeccompError::RedundantAllowRule(Syscall::Read)) => {}
// _ => panic!("Expected RedundantAllowRule for Syscall::Read"),
// }
// }
//
// #[test]
// fn test_redundunt_deny_policy() {
// let mut policy = Policy::deny_all().unwrap();
// let result = policy.deny(Syscall::Read);
//
// match result {
// Err(SeccompError::RedundantDenyRule(Syscall::Read)) => {}
// _ => panic!("Expected RedundantDenyRule for Syscall::Read"),
// }
// }
// #[test]
// fn test_policy_rules() {
// let mut policy = Policy::deny_all().unwrap();
// let result = policy
// .allow(Syscall::Read)
// .unwrap()
// .allow(Syscall::Mknod)
// .unwrap()
// .allow(Syscall::Iopl)
// .unwrap();
//
// assert_eq!(
// result.rules_len(),
// 3,
// "Policy should not have conflicting default rules"
// );
// }
//
// #[test]
// fn test_policy_rules_deny() {
// let mut policy = Policy::allow_all().unwrap();
// let result = policy
// .deny(Syscall::Read)
// .unwrap()
// .deny(Syscall::Mknod)
// .unwrap()
// .deny(Syscall::Iopl)
// .unwrap();
//
// assert_eq!(
// result.rules_len(),
// 3,
// "Policy should not have conflicting default rules"
// );
// }
// }