public void TestPermissionApi() { var e = new Enforcer(_testModelFixture.GetBasicWithoutResourceTestModel()); e.BuildRoleLinks(); TestEnforceWithoutUsers(e, "alice", "read", true); TestEnforceWithoutUsers(e, "alice", "write", false); TestEnforceWithoutUsers(e, "bob", "read", false); TestEnforceWithoutUsers(e, "bob", "write", true); TestGetPermissions(e, "alice", AsList(AsList("alice", "read"))); TestGetPermissions(e, "bob", AsList(AsList("bob", "write"))); TestHasPermission(e, "alice", AsList("read"), true); TestHasPermission(e, "alice", AsList("write"), false); TestHasPermission(e, "bob", AsList("read"), false); TestHasPermission(e, "bob", AsList("write"), true); _ = e.DeletePermission("read"); TestEnforceWithoutUsers(e, "alice", "read", false); TestEnforceWithoutUsers(e, "alice", "write", false); TestEnforceWithoutUsers(e, "bob", "read", false); TestEnforceWithoutUsers(e, "bob", "write", true); _ = e.AddPermissionForUser("bob", "read"); TestEnforceWithoutUsers(e, "alice", "read", false); TestEnforceWithoutUsers(e, "alice", "write", false); TestEnforceWithoutUsers(e, "bob", "read", true); TestEnforceWithoutUsers(e, "bob", "write", true); _ = e.DeletePermissionForUser("bob", "read"); TestEnforceWithoutUsers(e, "alice", "read", false); TestEnforceWithoutUsers(e, "alice", "write", false); TestEnforceWithoutUsers(e, "bob", "read", false); TestEnforceWithoutUsers(e, "bob", "write", true); _ = e.DeletePermissionsForUser("bob"); TestEnforceWithoutUsers(e, "alice", "read", false); TestEnforceWithoutUsers(e, "alice", "write", false); TestEnforceWithoutUsers(e, "bob", "read", false); TestEnforceWithoutUsers(e, "bob", "write", false); }