public void TestEnforceExApi() { var e = new Enforcer(_testModelFixture.GetBasicTestModel()); TestEnforceEx(e, "alice", "data1", "read", new List <string> { "alice", "data1", "read" }); TestEnforceEx(e, "alice", "data1", "write", new List <string>()); TestEnforceEx(e, "alice", "data2", "read", new List <string>()); TestEnforceEx(e, "alice", "data2", "write", new List <string>()); TestEnforceEx(e, "bob", "data1", "read", new List <string>()); TestEnforceEx(e, "bob", "data1", "write", new List <string>()); TestEnforceEx(e, "bob", "data2", "read", new List <string>()); TestEnforceEx(e, "bob", "data2", "write", new List <string> { "bob", "data2", "write" }); e = new Enforcer(_testModelFixture.GetNewRbacTestModel()); TestEnforceEx(e, "alice", "data1", "read", new List <string> { "alice", "data1", "read" }); TestEnforceEx(e, "alice", "data1", "write", new List <string>()); TestEnforceEx(e, "alice", "data2", "read", new List <string> { "data2_admin", "data2", "read" }); TestEnforceEx(e, "alice", "data2", "write", new List <string> { "data2_admin", "data2", "write" }); TestEnforceEx(e, "bob", "data1", "read", new List <string>()); TestEnforceEx(e, "bob", "data1", "write", new List <string>()); TestEnforceEx(e, "bob", "data2", "read", new List <string>()); TestEnforceEx(e, "bob", "data2", "write", new List <string> { "bob", "data2", "write" }); e = new Enforcer(_testModelFixture.GetNewPriorityTestModel()); e.BuildRoleLinks(); TestEnforceEx(e, "alice", "data1", "read", new List <string> { "alice", "data1", "read", "allow" }); TestEnforceEx(e, "alice", "data1", "write", new List <string> { "data1_deny_group", "data1", "write", "deny" }); TestEnforceEx(e, "alice", "data2", "read", new List <string>()); TestEnforceEx(e, "alice", "data2", "write", new List <string>()); TestEnforceEx(e, "bob", "data1", "write", new List <string>()); TestEnforceEx(e, "bob", "data2", "read", new List <string> { "data2_allow_group", "data2", "read", "allow" }); TestEnforceEx(e, "bob", "data2", "write", new List <string> { "bob", "data2", "write", "deny" }); }
public void TestPriorityModel() { var e = new Enforcer(_testModelFixture.GetNewPriorityTestModel()); e.BuildRoleLinks(); TestEnforce(e, "alice", "data1", "read", true); TestEnforce(e, "alice", "data1", "write", false); TestEnforce(e, "alice", "data2", "read", false); TestEnforce(e, "alice", "data2", "write", false); TestEnforce(e, "bob", "data1", "read", false); TestEnforce(e, "bob", "data1", "write", false); TestEnforce(e, "bob", "data2", "read", true); TestEnforce(e, "bob", "data2", "write", false); }