Example #1
0
        public void testCreateUser()
        {
            LdapUser testLdapUser = setupTestUser();

            //Init the DLL and connect the admin
            testAdminConnect();

            //Create user
            bool result = LdapManagerObj.CreateUser(testLdapUser);

            //Assert the correct operations
            Assert.IsTrue(result);
            Assert.AreEqual(LdapManagerObj.GetLdapMessage(), "LDAP USER MANIPULATION SUCCESS: " + "Create User Operation Success");

            result = LdapManagerObj.DeleteUser(testLdapUser);

            Assert.IsTrue(result);
        }
Example #2
0
        public bool TestCreateUser()
        {
            if (!TestAdminConnect())
            {
                return(false);
            }

            //Create user
            bool result = _ldapManagerObj.CreateUser(_userRepository.TestUser);

            //Assert the correct operations
            if (!result &&
                !_ldapManagerObj.GetLdapMessage()
                .Contains("LDAP USER MANIPULATION SUCCESS: " + "Create User Operation Success")
                )
            {
                return(false);
            }


            result = _ldapManagerObj.DeleteUser(_userRepository.TestUser);

            return(result);
        }
Example #3
0
 public void TestCompleteInitLibraryNoServer()
 {
     _ldapManagerObj = new LdapManager(AdminUser, AdminMode,
                                       "",
                                       LdapSearchBaseDn,
                                       LdapAuthType,
                                       SecureSocketLayerFlag,
                                       TransportSocketLayerFlag,
                                       ClientCertificationFlag,
                                       ClientCertificatePath,
                                       EnableLdapLibraryLog,
                                       LdapLibraryLogPath,
                                       LdapUserObjectClass,
                                       LdapMatchFieldUsername,
                                       connectionTimeout
                                       );
     Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP LIBRARY INIT ERROR: ");
 }
        public void TestCompleteInitLibrary()
        {
            _ldapManagerObj = new LdapManager(null,AdminMode,
                LdapServer,
                LdapSearchBaseDn,
                LdapAuthType,
                SecureSocketLayerFlag,
                TransportSocketLayerFlag,
                ClientCertificationFlag,
                ClientCertificatePath,
                EnableLdapLibraryLog,
                LdapLibraryLogPath,
                LdapUserObjectClass,
                LdapMatchFieldUsername
                );

            Assert.IsFalse(_ldapManagerObj.Equals(null));
            Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP LIBRARY INIT SUCCESS");
        }
Example #5
0
        public void TestSearchUser()
        {
            TestAdminConnect();

            string[] userIdToSearch =
            {
                ReadOnlyUserCn
            };
            string[] fakeuserIdToSearch =
            {
                WriteUserCn
            };
            var userAttributeToReturnBySearch = new List <string>
            {
                "description"
            };

            IList <ILdapUser> returnUsers;

            bool result = _ldapManagerObj.SearchUsers(userAttributeToReturnBySearch, fakeuserIdToSearch, out returnUsers);

            Assert.IsFalse(result);
            Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP SEARCH USER ERROR: ");

            result = _ldapManagerObj.SearchUsers(null, userIdToSearch, out returnUsers);

            Assert.IsTrue(result);
            Assert.AreEqual(returnUsers.Count, userIdToSearch.Length);
            Assert.AreEqual(returnUsers[0].GetUserCn(), ReadOnlyUserCn);
            Assert.IsTrue(returnUsers[0].GetUserAttributes().Count == 0);

            result = _ldapManagerObj.SearchUsers(userAttributeToReturnBySearch, userIdToSearch, out returnUsers);

            Assert.IsTrue(result);
            Assert.AreEqual(returnUsers.Count, userIdToSearch.Length);
            Assert.AreEqual(returnUsers[0].GetUserCn(), ReadOnlyUserCn);
        }
Example #6
0
        public void TestCreateUser()
        {
            var tempUser     = new LdapUser(WriteUserDn, WriteUserCn, "test", null);
            var existingUser = new LdapUser(ReadOnlyUserDn, ReadOnlyUserCn, "test",
                                            new Dictionary <string, List <string> > {
                { "userPassword", new List <string> {
                      ReadOnlyUserPwd
                  } }
            });

            //Init the DLL and connect the admin
            TestAdminConnect();

            //Create existing user
            var result = _ldapManagerObj.CreateUser(existingUser);

            //Assert the correct operations
            Assert.IsFalse(result);
            Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP CREATE USER ERROR: ");

            //Create user
            result = _ldapManagerObj.CreateUser(tempUser);

            //Assert the correct operations
            Assert.IsTrue(result);
            Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1),
                            "LDAP USER MANIPULATION SUCCESS: ");

            result = _ldapManagerObj.DeleteUser(tempUser);

            Assert.IsTrue(result);
        }
 public void TestStandardInitLibraryNologPath_File()
 {
     _ldapManagerObj = new LdapManager(AdminUser, AdminMode, LdapServer, LdapSearchBaseDn, LdapAuthType,
         EnableLdapLibraryLog, null);
     Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP LIBRARY INIT ERROR: ");
 }
 public void TestCompleteInitLibraryNoUserClass()
 {
     _ldapManagerObj = new LdapManager(AdminUser, AdminMode,
         LdapServer,
         LdapSearchBaseDn,
         LdapAuthType,
         SecureSocketLayerFlag,
         TransportSocketLayerFlag,
         ClientCertificationFlag,
         ClientCertificatePath,
         EnableLdapLibraryLog,
         LdapLibraryLogPath,
         "",
         LdapMatchFieldUsername
         );
     Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP LIBRARY INIT ERROR: ");
 }
Example #9
0
 public void TestStandardInitLibraryNologPath_File()
 {
     _ldapManagerObj = new LdapManager(AdminUser, AdminMode, LdapServer, LdapSearchBaseDn, LdapAuthType,
                                       EnableLdapLibraryLog, null);
     Assert.AreEqual(_ldapManagerObj.GetLdapMessage().Split('-')[1].Substring(1), "LDAP LIBRARY INIT ERROR: ");
 }