public void CheckAccess_WithOperation_ReturnFalse_Test() { var role = new RbacRole("testRole", new IRbacOperation[] { new RbacOperation("op1"), new RbacOperation("op2") }); Assert.IsFalse(role.CheckAccess("Fake")); }
public void CheckAccess_WithTasks_ReturnFalse_Test() { var role = new RbacRole("testRole", Enumerable.Empty <IRbacOperation>(), new IRbacTask[] { new RbacTask("t1", new RbacOperation("op2"), new BizRule(_ => !string.IsNullOrEmpty(_["id"]))) }); Assert.IsFalse(role.CheckAccess("t3", new Dictionary <string, string>() { { "id", "test" } })); }
public void CheckAccess_WithRoles3_ReturnTrue_Test() { var role = new RbacRole("testRole", Enumerable.Empty <IRbacOperation>(), Enumerable.Empty <IRbacTask>(), new IRbacRole[] { new RbacRole("r1"), new RbacRole("r2", new IRbacOperation[] { new RbacOperation("op1"), new RbacOperation("op2") }) }); Assert.IsTrue(role.CheckAccess("op1")); }
public void CheckAccess_WithRoles4_ReturnTrue_Test() { var role = new RbacRole("testRole", Enumerable.Empty <IRbacOperation>(), Enumerable.Empty <IRbacTask>(), new IRbacRole[] { new RbacRole("r1"), new RbacRole("r2", Enumerable.Empty <IRbacOperation>(), new IRbacTask[] { new RbacTask("t1", new RbacOperation("op2"), new BizRule(_ => _["id"] == "id1")) }) }); Assert.IsTrue(role.CheckAccess("t1", new Dictionary <string, string>() { { "id", "id1" } })); }
public void CheckAccess_ReturnFalse_Test() { var role = new RbacRole("testRole"); Assert.IsFalse(role.CheckAccess("Fake")); }
public void CheckAccess_ReturnTrue_Test() { var role = new RbacRole("testRole"); Assert.IsTrue(role.CheckAccess("testRole")); }