public void TestRoleApiWithDomains() { var e = new Enforcer(_testModelFixture.GetNewRbacWithDomainsTestModel()); e.BuildRoleLinks(); TestGetRolesInDomain(e, "alice", "domain1", AsList("admin")); TestGetRolesInDomain(e, "bob", "domain1", AsList()); TestGetRolesInDomain(e, "admin", "domain1", AsList()); TestGetRolesInDomain(e, "non_exist", "domain1", AsList()); TestGetRolesInDomain(e, "alice", "domain2", AsList()); TestGetRolesInDomain(e, "bob", "domain2", AsList("admin")); TestGetRolesInDomain(e, "admin", "domain2", AsList()); TestGetRolesInDomain(e, "non_exist", "domain2", AsList()); e.DeleteRoleForUserInDomain("alice", "admin", "domain1"); e.AddRoleForUserInDomain("bob", "admin", "domain1"); TestGetRolesInDomain(e, "alice", "domain1", AsList()); TestGetRolesInDomain(e, "bob", "domain1", AsList("admin")); TestGetRolesInDomain(e, "admin", "domain1", AsList()); TestGetRolesInDomain(e, "non_exist", "domain1", AsList()); TestGetRolesInDomain(e, "alice", "domain2", AsList()); TestGetRolesInDomain(e, "bob", "domain2", AsList("admin")); TestGetRolesInDomain(e, "admin", "domain2", AsList()); TestGetRolesInDomain(e, "non_exist", "domain2", AsList()); }
public void TestRoleApiWithDomains() { var e = new Enforcer(_testModelFixture.GetNewRbacWithDomainsTestModel()); e.BuildRoleLinks(); TestHasRole(e, "alice", "admin", true, "domain1"); TestHasRole(e, "alice", "admin", false, "domain2"); TestGetRoles(e, "alice", AsList("admin"), "domain1"); TestGetRoles(e, "bob", AsList(), "domain1"); TestGetRoles(e, "admin", AsList(), "domain1"); TestGetRoles(e, "non_exist", AsList(), "domain1"); TestGetRoles(e, "alice", AsList(), "domain2"); TestGetRoles(e, "bob", AsList("admin"), "domain2"); TestGetRoles(e, "admin", AsList(), "domain2"); TestGetRoles(e, "non_exist", AsList(), "domain2"); _ = e.DeleteRoleForUser("alice", "admin", "domain1"); _ = e.AddRoleForUser("bob", "admin", "domain1"); TestGetRoles(e, "alice", AsList(), "domain1"); TestGetRoles(e, "bob", AsList("admin"), "domain1"); TestGetRoles(e, "admin", AsList(), "domain1"); TestGetRoles(e, "non_exist", AsList(), "domain1"); TestGetRoles(e, "alice", AsList(), "domain2"); TestGetRoles(e, "bob", AsList("admin"), "domain2"); TestGetRoles(e, "admin", AsList(), "domain2"); TestGetRoles(e, "non_exist", AsList(), "domain2"); _ = e.AddRoleForUser("alice", "admin", "domain1"); _ = e.DeleteRolesForUser("bob", "domain1"); TestGetRoles(e, "alice", AsList("admin"), "domain1"); TestGetRoles(e, "bob", AsList(), "domain1"); TestGetRoles(e, "admin", AsList(), "domain1"); TestGetRoles(e, "non_exist", AsList(), "domain1"); TestGetRoles(e, "alice", AsList(), "domain2"); TestGetRoles(e, "bob", AsList("admin"), "domain2"); TestGetRoles(e, "admin", AsList(), "domain2"); TestGetRoles(e, "non_exist", AsList(), "domain2"); _ = e.AddRolesForUser("bob", AsList("admin", "admin1", "admin2"), "domain1"); TestGetRoles(e, "bob", AsList("admin", "admin1", "admin2"), "domain1"); TestGetPermissions(e, "admin", AsList( AsList("admin", "domain1", "data1", "read"), AsList("admin", "domain1", "data1", "write")), "domain1"); TestGetPermissions(e, "admin", AsList( AsList("admin", "domain2", "data2", "read"), AsList("admin", "domain2", "data2", "write")), "domain2"); }
public void TestRbacModelWithDomains() { var e = new Enforcer(_testModelFixture.GetNewRbacWithDomainsTestModel()); e.BuildRoleLinks(); TestDomainEnforce(e, "alice", "domain1", "data1", "read", true); TestDomainEnforce(e, "alice", "domain1", "data1", "write", true); TestDomainEnforce(e, "alice", "domain1", "data2", "read", false); TestDomainEnforce(e, "alice", "domain1", "data2", "write", false); TestDomainEnforce(e, "bob", "domain2", "data1", "read", false); TestDomainEnforce(e, "bob", "domain2", "data1", "write", false); TestDomainEnforce(e, "bob", "domain2", "data2", "read", true); TestDomainEnforce(e, "bob", "domain2", "data2", "write", true); }