コード例 #1
0
        public void SortGroupsByService()
        {
            //Assumptions:
            // user joe:supersecret exists
            //Actions:
            // Create group for local service
            // Create group for xmlauth
            // Sort groups by service
            //Expected result:
            // ok

            Plug p = Utils.BuildPlugForAdmin();

            string       id = null;
            string       groupnameFilter = Utils.GenerateUniqueName();
            DreamMessage msg             = null;

            msg = UserUtils.CreateGroup(p, "Contributor", null, out id, groupnameFilter + Utils.GenerateUniqueName());

            string serviceid = GetServiceIDBySID(p, SID);

            string groupname = groupnameFilter + Utils.GenerateUniqueName();

            AddNewGroupToXml(p, serviceid, groupname);

            XDoc groupDoc = new XDoc("group")
                            .Elem("name", groupname)
                            .Start("service.authentication").Attr("id", serviceid).End()
                            .Start("permissions.group")
                            .Elem("role", "Contributor")
                            .End();

            msg = p.At("groups").With("authusername", "joe").With("authpassword", "supersecret").Post(groupDoc);
            Assert.AreEqual(DreamStatus.Ok, msg.Status);

            Dictionary <string, string> serviceDescriptions = Utils.GetDictionaryFromDoc(p.At("site", "services").With("limit", "all").Get().ToDocument(), "service", "@id", "description");

            Utils.TestSortingOfDocByField(
                p.At("groups").With("sortby", "service").With("groupnamefilter", groupnameFilter).Get().ToDocument(),
                "group", "service.authentication/@id", true, serviceDescriptions);

            Utils.TestSortingOfDocByField(
                p.At("groups").With("sortby", "-service").With("groupnamefilter", groupnameFilter).Get().ToDocument(),
                "group", "service.authentication/@id", false, serviceDescriptions);
        }
コード例 #2
0
ファイル: GroupsTest.cs プロジェクト: Minocula/MindTouch_Core
        public void TestGetGroupsSorting()
        {
            // 1. Create 5 groups
            // (2a) Assert group names are correctly sorted by ascending order
            // (2b) Assert group names are correctly sorted by descending order
            // (3a) Assert group roles are correctly sorted by ascending order
            // (3b) Assert group roles are correctly sorted by descending order

            Plug p = Utils.BuildPlugForAdmin();

            string id = null;
            string groupnameFilter = Utils.GenerateUniqueName();

            string uniqueRoleName = null;

            UserUtils.CreateRandomRole(p, out uniqueRoleName);
            UserUtils.CreateGroup(p, uniqueRoleName, null, out id, Utils.GenerateUniqueName() + groupnameFilter);
            UserUtils.CreateRandomRole(p, out uniqueRoleName);
            UserUtils.CreateGroup(p, uniqueRoleName, null, out id, Utils.GenerateUniqueName() + groupnameFilter);
            UserUtils.CreateRandomRole(p, out uniqueRoleName);
            UserUtils.CreateGroup(p, uniqueRoleName, null, out id, Utils.GenerateUniqueName() + groupnameFilter);
            UserUtils.CreateRandomRole(p, out uniqueRoleName);
            UserUtils.CreateGroup(p, uniqueRoleName, null, out id, Utils.GenerateUniqueName() + groupnameFilter);
            UserUtils.CreateRandomRole(p, out uniqueRoleName);
            UserUtils.CreateGroup(p, uniqueRoleName, null, out id, Utils.GenerateUniqueName() + groupnameFilter);

            Utils.TestSortingOfDocByField(p.At("groups").With("groupnamefilter", groupnameFilter)
                                          .With("sortby", "name").Get().ToDocument(), "group", "groupname", true);
            Utils.TestSortingOfDocByField(p.At("groups").With("groupnamefilter", groupnameFilter)
                                          .With("sortby", "-name").Get().ToDocument(), "group", "groupname", false);

            Utils.TestSortingOfDocByField(p.At("groups").With("groupnamefilter", groupnameFilter)
                                          .With("sortby", "role").Get().ToDocument(), "group", "permissions.group/role", true);
            Utils.TestSortingOfDocByField(p.At("groups").With("groupnamefilter", groupnameFilter)
                                          .With("sortby", "-role").Get().ToDocument(), "group", "permissions.group/role", false);
        }