示例#1
0
        public void GetLdapUsers_InvalidPageNumber_Failure()
        {
            List <UserLdap> oUsers;
            var             res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 99999, 100, null);

            Assert.IsFalse(res.Success, "GetLdapUsers with invalid page number should fail");
        }
示例#2
0
        public void GetLdapUsers_NullConnectionServer_Failure()
        {
            List <UserLdap> oUsers;
            var             res = UserLdap.GetLdapUsers(null, out oUsers, 0, 20, "");

            Assert.IsFalse(res.Success, "GetLdapUsers with null Connection server should fail");
        }
示例#3
0
        public void GetLdapUsers_InvalidQuery()
        {
            List <UserLdap> oUsers;

            var res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 0, 20, "query=(alias is _bogus_)");

            if (res.ResponseText.Contains("LDAP_DIRECTORY_SYNCH_NOT_ACTIVATED"))
            {
                Console.WriteLine("LDAP not enabled on box -skipping invalid query test");
                return;
            }

            Assert.IsTrue(res.Success, "GetLdapUsers with invalid query server should not fail:" + res);
            Assert.IsNotNull(oUsers, "Bogus query should not return a null list");
            Assert.IsTrue(oUsers.Count == 0, "Bogus query should return empty list");
        }
示例#4
0
        public void GetLdapUsers_ErrorResponse_Failure()
        {
            List <UserLdap> oUsers;

            //error response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "ErrorResponse");

            Assert.IsFalse(res.Success, "Calling GetLdapUsers with ErrorResponse did not fail");
        }
示例#5
0
        public void GetLdapUsers_GarbageResults_Success()
        {
            List <UserLdap> oUsers;

            //garbage response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "garbage result"
            });

            var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "InvalidResultText");

            Assert.IsTrue(res.Success, "Calling GetLdapUsers with InvalidResultText should not fail:" + res);
            Assert.IsTrue(oUsers.Count == 0, "Invalid result text should produce an empty list of templates");
        }
示例#6
0
        public void GetLdapUsers_EmptyResults_Failure()
        {
            List <UserLdap> oUsers;

            //empty results
            _mockTransport.Setup(
                x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                       It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = ""
            });

            var res = UserLdap.GetLdapUsers(_mockServer, out oUsers, 0, 20, "EmptyResultText");

            Assert.IsFalse(res.Success, "Calling GetLdapUsers with EmptyResultText did not fail");
        }
示例#7
0
        public void GetLdapUsers_Success()
        {
            List <UserLdap> oUsers;
            var             res = UserLdap.GetLdapUsers(_connectionServer, out oUsers, 0, 5);

            if (res.ResponseText.Contains("LDAP_DIRECTORY_SYNCH_NOT_ACTIVATED"))
            {
                Console.WriteLine("LDAP not enabled on box -skipping live tests of LDAP import");
                return;
            }

            Assert.IsTrue(res.Success, "Failed fetching LDAP users:" + res);
            Assert.IsNotNull(oUsers, "Fetch of LDAP users returned null list");

            foreach (var oUser in oUsers)
            {
                Console.WriteLine(oUser.ToString());
                Console.WriteLine(oUser.SelectionDisplayString);
                Console.WriteLine(oUser.UniqueIdentifier);
            }
        }