Esempio n. 1
0
        public void ChangePasswordQuestionAndAnswer()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            Assert.AreEqual(true, provider.ChangePasswordQuestionAndAnswer(
                                DataAccess.UserDataDao.OldPassword,
                                DataAccess.UserDataDao.UserToChangeAnswer,
                                DataAccess.UserDataDao.NewQuestion,
                                DataAccess.UserDataDao.NewAnswer));


            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT PasswordAnswer FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE UserName = '******'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, DataAccess.UserDataDao.NewAnswer);


            result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                   "SELECT PasswordQuestion FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                   " WHERE UserName = '******'",
                                                   true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, DataAccess.UserDataDao.NewQuestion);
        }
Esempio n. 2
0
        public void ValidateUser()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            Assert.AreEqual(true, provider.ValidateUser(
                                DataAccess.UserDataDao.ExistingUser, DataAccess.UserDataDao.OldPassword));
        }
Esempio n. 3
0
        public void CreateUser()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            MembershipCreateStatus status = MembershipCreateStatus.ProviderError;

            MembershipUser user = provider.CreateUser(
                DataAccess.UserDataDao.NewUserName,
                DataAccess.UserDataDao.OldPassword,
                "*****@*****.**",
                DataAccess.UserDataDao.OldQuestion,
                DataAccess.UserDataDao.OldAnswer,
                true,
                null,
                out status);


            Assert.AreEqual(status, MembershipCreateStatus.Success);

            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT UserName FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE UserName = '******'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, DataAccess.UserDataDao.NewUserName);
        }
Esempio n. 4
0
        public void GetPassword()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            string password = provider.GetPassword(
                DataAccess.UserDataDao.UserToGetPassword,
                DataAccess.UserDataDao.OldAnswer);


            Assert.AreEqual(password, DataAccess.UserDataDao.OldPassword);
        }
Esempio n. 5
0
        public void UnlockUser()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            Assert.AreEqual(true, provider.UnlockUser(DataAccess.UserDataDao.UserToUnLock));



            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT IsLockedOut FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE UserName = '******'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, false);
        }
Esempio n. 6
0
        public void GetUser()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();


            MembershipUser userData = provider.GetUser(DataAccess.UserManagerDao.UserNameToMatch, false);

            Assert.IsNotNull(userData, "Couldn't load the user by name");

            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT userName FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE UserName = '******'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, userData.UserName);
        }
Esempio n. 7
0
        public void GetUserNameByEmail()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            string userName = null;

            userName = provider.GetUserNameByEmail(DataAccess.UserManagerDao.EmailToMatch);

            Assert.IsNotNull(userName, "Couldn't find the user name specified.");


            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT userName FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE Email = '" + DataAccess.UserManagerDao.EmailToMatch + "'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, userName);
        }
Esempio n. 8
0
        public void GetNumberOfUsersOnline()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();


            int totalUsers = -1;

            totalUsers = provider.GetNumberOfUsersOnline();

            Assert.AreNotEqual(totalUsers, -1);

            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT Count(*) FROM " + Framework.Dao.Constants.DefaultTableUsers +
                                                          " WHERE LastactivityDate > DATEADD(minute,  -(" + 10 + "), GETDATE())",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, totalUsers);
        }
Esempio n. 9
0
        public void UpdateUser()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();



            //Framework.Security.Business.CustomMembershipUser user = new Framework.Security.Business.CustomMembershipUser (


            //Framework.Security.Model.UserData userData =
            //                new Framework.Security.Model.UserData(ExistingUser);


            //Framework.Security.DataAccess.UserDataDao userDataDao =
            //    new Framework.Security.DataAccess.UserDataDao(
            //        Constants.Application, _connectionStringSettings,
            //        Framework.Tests.DataServices.CommonDatabase.CurrentUser
            //        );

            //Assert.AreEqual(true, userDataDao.UpdateUser(userData, false));
        }
Esempio n. 10
0
        public void GetAllUsers()
        {
            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            int totalRecords = -1;

            MembershipUserCollection list = provider.GetAllUsers(
                DataAccess.UserManagerDao.PageIndex, DataAccess.UserManagerDao.PageSize, out totalRecords);

            Assert.IsNotNull(list);

            Assert.AreNotEqual(totalRecords, -1);

            Assert.AreEqual(totalRecords, list.Count);


            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT Count(*) FROM " + Framework.Dao.Constants.DefaultTableUsers,
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //TODO: Fix this test
            //Assert.AreEqual(result, totalRecords);
        }
Esempio n. 11
0
        public void FindUsersByName()
        {
            int totalRecords = -1;

            MembershipProvider provider = new Framework.Security.Business.UserManagerService();

            MembershipUserCollection list = provider.FindUsersByName(DataAccess.UserManagerDao.UserNameToMatch,
                                                                     DataAccess.UserManagerDao.PageIndex, DataAccess.UserManagerDao.PageSize, out totalRecords);

            Assert.IsNotNull(list);

            Assert.AreNotEqual(totalRecords, -1);

            Assert.AreEqual(totalRecords, list.Count);


            object result = _commonDatabase.ExecuteScalar(CommandType.Text,
                                                          "SELECT Count(*) FROM " + Framework.Dao.Constants.DefaultTableUsers
                                                          + " WHERE UserName = '******'",
                                                          true, Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            Assert.AreEqual(result, totalRecords);
        }