Ejemplo n.º 1
0
        public void LegalAddUserToGroupTest()
        {
            this.InitAdmins();

            var mainApp = this.CreateDefaultApp();

            var mainRole = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch"));

            var mainOrg = this.GetOrganizationByCodeName("costEngineer");

            var testOrg = this.NewObject <PC.SCOrganization>("测试组织");

            Facade.AddOrganization(testOrg, mainOrg);

            this.SetContainerMemberAndPermissions(testOrg, mainRole, new string[] { "EditMembersOfGroups" });

            PC.SCGroup testGrp = this.NewObject <PC.SCGroup>("测试群组");

            Facade.AddGroup(testGrp, testOrg);

            this.SetCurrentPrincipal(this.GetUserByCodeName("wanglch"));

            var testUser = this.GetSCUserByCodeName("jinge");

            FacadeWithAcl.AddUserToGroup(testUser, testGrp);

            var actual = PC.Adapters.SCMemberRelationAdapter.Instance.Load(testGrp.ID, testUser.ID);

            Assert.IsNotNull(actual);

            Assert.AreEqual(actual.Status, SchemaObjectStatus.Normal);
        }
Ejemplo n.º 2
0
        public void IllegalAddUserToGroupTest()
        {
            this.InitAdmins();

            var mainApp = this.CreateDefaultApp();

            var mainRole = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch"));

            var mainOrg = this.GetOrganizationByCodeName("costEngineer");

            var testOrg = this.NewObject <PC.SCOrganization>("测试组织");

            Facade.AddOrganization(testOrg, mainOrg);

            this.SetContainerMemberAndPermissions(testOrg, mainRole, new string[] { "EditMembersOfGroups" });

            PC.SCGroup testGrp = this.NewObject <PC.SCGroup>("测试群组");

            Facade.AddGroup(testGrp, testOrg);

            this.SetCurrentPrincipal(this.GetUserByCodeName("chenke"));

            var testUser = this.GetSCUserByCodeName("jinge");

            FacadeWithAcl.AddUserToGroup(testUser, testGrp);

            Assert.Fail("不应执行到此");
        }
Ejemplo n.º 3
0
        public void AdminAddUserToGroupTest()
        {
            this.InitAdmins();

            PC.SCGroup testGrp = this.NewObject <PC.SCGroup>("测试群组");

            var mainOrg = this.GetOrganizationByCodeName("costEngineer");

            var testOrg = this.NewObject <PC.SCOrganization>("测试组织");

            Facade.AddOrganization(testOrg, mainOrg);

            Facade.AddGroup(testGrp, testOrg);

            var testUser = this.GetSCUserByCodeName("jinge");

            FacadeWithAcl.AddUserToGroup(testUser, testGrp);

            var actual = PC.Adapters.SCMemberRelationAdapter.Instance.Load(testGrp.ID, testUser.ID);

            Assert.IsNotNull(actual);

            Assert.AreEqual(actual.Status, SchemaObjectStatus.Normal);
        }