public void TestOfAssignPermissions() { this.InitAdmins(); var mainApp = this.CreateDefaultApp(); var mainRole = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch")); base.SetContainerMemberAndPermissions(mainApp, mainRole, new string[] { "EditRelationOfRolesAndPermissions" }); this.SetCurrentPrincipal(this.GetUserByCodeName("wanglch")); var testRole = this.NewObject <SCRole>("测试角色"); Facade.AddRole(testRole, mainApp); var testPermission = this.NewObject <SCPermission>("测试功能"); Facade.AddPermission(testPermission, mainApp); FacadeWithAcl.JoinRoleAndPermission(testRole, testPermission); var pm = PC.Adapters.SchemaRelationObjectAdapter.Instance.Load(testRole.ID, testPermission.ID); Assert.IsNotNull(pm); Assert.AreEqual(pm.Status, SchemaObjectStatus.Normal); FacadeWithAcl.DisjoinRoleAndPermission(testRole, testPermission); pm = PC.Adapters.SchemaRelationObjectAdapter.Instance.Load(testRole.ID, testPermission.ID); Assert.IsNotNull(pm); Assert.AreNotEqual(pm.Status, SchemaObjectStatus.Normal); }
public void TestOfIllegalDisassignPermissions() { this.InitAdmins(); var mainApp = this.CreateDefaultApp(); var mainRole = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch")); this.SetCurrentPrincipal(this.GetUserByCodeName("chenke")); var testRole = this.NewObject <SCRole>("测试角色"); Facade.AddRole(testRole, mainApp); var testPermission = this.NewObject <SCPermission>("测试功能"); Facade.AddPermission(testPermission, mainApp); Facade.JoinRoleAndPermission(testRole, testPermission); //Sleep(200); FacadeWithAcl.DisjoinRoleAndPermission(testRole, testPermission); Assert.Fail("不应该执行到此"); }
public void TestOfAdminAssignPermissions() { this.InitAdmins(); var mainApp = this.CreateDefaultApp(); var mainRole = this.CreateDefaultRole(); var testRole = this.NewObject <SCRole>("测试角色"); Facade.AddRole(testRole, mainApp); var testPermission = this.NewObject <SCPermission>("测试功能"); Facade.AddPermission(testPermission, mainApp); FacadeWithAcl.JoinRoleAndPermission(testRole, testPermission); var pm = PC.Adapters.SchemaRelationObjectAdapter.Instance.Load(testRole.ID, testPermission.ID); Assert.IsNotNull(pm); Assert.AreEqual(pm.Status, SchemaObjectStatus.Normal); FacadeWithAcl.DisjoinRoleAndPermission(testRole, testPermission); pm = PC.Adapters.SchemaRelationObjectAdapter.Instance.Load(testRole.ID, testPermission.ID); Assert.IsNotNull(pm); Assert.AreNotEqual(pm.Status, SchemaObjectStatus.Normal); }
protected PC.SCPermission CreatePermission(PC.SCApplication app, PC.SCPermission fun) { var fun0 = (PC.SCPermission)PC.Adapters.SchemaObjectAdapter.Instance.Load(fun.ID); if (fun0 == null || fun0.Status != SchemaObjectStatus.Normal) { Facade.AddPermission(fun, app); } else { fun = fun0; } return(fun); }