Example #1
0
        public void TestUpdateTrustees_RemoveAndAddBack()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password = TestHelperSecure.MyPassword;
            string dst = DMLogin.Dst;

            // we know the trustees of this existing document
            int docNumber = 123457;
            TrusteeInfo docsUsersInitial = new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.ReadOnly);
            TrusteeInfo docsUsersToSet = new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.NoAccess);
            List<TrusteeInfo> expected = new List<TrusteeInfo>() {
                docsUsersInitial,
                new TrusteeInfo("HR_USERS", TrusteeType.Group, AccessRights.NormalAccess),
                new TrusteeInfo("JDOE", TrusteeType.Person, AccessRights.View),
                new TrusteeInfo("NKHORIN", TrusteeType.Person, AccessRights.FullAccess),
            };

            DMDocument doc = new DMDocument() { Dst = dst, Library = DMLogin.Library };
            var actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Count, actual.Length);
            foreach(var exp in expected)
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);

            // Remove DOCS_USERS. We use NoAccess to remove a truestee.
            // This is the way we implemented DMDocument.UpdateTrustees
            doc.UpdateTrustees(docNumber, new TrusteeInfo[] { docsUsersToSet });

            // check
            expected.Remove(docsUsersInitial);
            actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Count, actual.Length);
            foreach(var exp in expected)
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);

            // Add DOCS_USERS back
            doc.UpdateTrustees(docNumber, new TrusteeInfo[] { docsUsersInitial });

            // check
            expected.Add(docsUsersInitial);
            actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Count, actual.Length);
            foreach(var exp in expected)
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
        }
Example #2
0
        public void TestFetchTrustees()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password = TestHelperSecure.MyPassword;
            string dst = DMLogin.Dst;

            // we know the trustees of this existing document
            int docNumber = 123456;
            TrusteeInfo[] expected = new TrusteeInfo[] {
                new TrusteeInfo("DOCS_USERS", TrusteeType.Group, AccessRights.ReadOnly),
                new TrusteeInfo("HR_USERS", TrusteeType.Group, AccessRights.NormalAccess),
                new TrusteeInfo("JDOE", TrusteeType.Person, AccessRights.View),
                new TrusteeInfo("NKHORIN", TrusteeType.Person, AccessRights.FullAccess),
            };

            DMDocument doc = new DMDocument() { Dst = dst, Library = DMLogin.Library };
            var actual = doc.FetchTrustees(docNumber);
            Assert.AreEqual(expected.Length, actual.Length);
            foreach(var exp in expected)
                Assert.IsTrue(actual.Contains(exp), "Not found " + exp.Trustee);
        }