示例#1
0
        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);
        }
示例#2
0
        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("不应该执行到此");
        }
示例#3
0
        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);
        }