Esempio n. 1
0
        public void AuthenticateUserTestCase3()
        {
            UserManagement um = new UserManagement();
            var            isAuthenticated_1 = um.Authenticate("ssimmons0", generateString(6));
            var            isAuthenticated_2 = um.Authenticate("ssimmons0", generateString(100));
            var            isAuthenticated_3 = um.Authenticate("ssimmons0", generateString(255));

            Assert.IsFalse(isAuthenticated_1);
            Assert.IsFalse(isAuthenticated_2);
            Assert.IsFalse(isAuthenticated_3);
        }
Esempio n. 2
0
        public void AuthenticateUserInCorrectCredentials()
        {
            UserManagement um = new UserManagement();
            var            isAuthenticated = um.Authenticate("ssimmons", "MtqO");

            Assert.IsFalse(isAuthenticated);
        }
Esempio n. 3
0
        public void AuthenticateUserCorrectCredentials()
        {
            UserManagement um = new UserManagement();
            var            isAuthenticated = um.Authenticate("ssimmons0", "MtqOJc");

            Assert.IsTrue(isAuthenticated);
        }
Esempio n. 4
0
        public void AuthenticateUserTestCase4()
        {
            var            isAuthenticated = false;
            UserManagement um = new UserManagement();

            isAuthenticated = um.Authenticate(string.Empty, string.Empty);
            Assert.IsFalse(isAuthenticated);
        }
Esempio n. 5
0
        public void AuthenticateUserTestCase2()
        {
            var            isAuthenticated = false;
            UserManagement um = new UserManagement();

            isAuthenticated = um.Authenticate(generateString(201), generateString(256));
            Assert.IsFalse(isAuthenticated);
        }
Esempio n. 6
0
        public void AuthenticateUserTestCase1()
        {
            var isAuthenticated = false;

            try
            {
                UserManagement um = new UserManagement();
                isAuthenticated = um.Authenticate(null, null);
            }
            finally
            {
                Assert.IsFalse(isAuthenticated);
            }
        }
Esempio n. 7
0
        public override void Run()
        {
            Console.Clear();


            Console.WriteLine(MenuSystem.Path);

            if (UserManagement.CurrentUser == null)
            {
                Console.Write("Enter User ID: ");
                string userId = Console.ReadLine();
                Console.Write("Enter Password: "******"Please enter valid User ID and Password");
                    Console.Write("ID:"); userId = Console.ReadLine();
                    Console.Write("Enter Password: "******"You are already logged in");
                Console.WriteLine("\n1. Log-out\n2. Want to Continue");
                Int32.TryParse("" + Console.ReadKey(true).KeyChar, out choice);

                switch (choice)
                {
                case 1: UserManagement.CurrentUser = null; return;

                case 2:     //menuSystem.AddScreen(new SignUpMain());
                    break;

                default:
                    break;
                }
                Console.WriteLine();
            }
            if (UserManagement.ProfileType() == ProfileType.Manager)
            {
                menuSystem.AddScreen(new ManagerMain());
            }
            else
            {
                menuSystem.AddScreen(new CustomerScreen());
            }
        }
Esempio n. 8
0
        /// <summary>
        /// AttemptToLogUserIn method
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public LoginModel AttemptToLogUserIn(string userName, string password)
        {
            LoginModel myLoginModel = new LoginModel();

            var myUserManagement = new UserManagement();
            var authenticationResult = myUserManagement.Authenticate(userName, password);

            if ((authenticationResult == UserManagement.AuthenticationResults.InvalidPassword)
                || (authenticationResult == UserManagement.AuthenticationResults.NoMatchingUser))
            {
                myLoginModel.Message = Constants.Areas.Common.LoginModel.AuthenticationResultMessages.BadOrIncorrectUsernameOrPassword;
                myLoginModel.Errors = true;
                return myLoginModel;
            }

            if (authenticationResult == UserManagement.AuthenticationResults.ChangePassword)
            {
                myLoginModel.Message = Constants.Areas.Common.LoginModel.AuthenticationResultMessages.ChangePassword;
                myLoginModel.Errors = true;
                return myLoginModel;
            }

            if (authenticationResult != UserManagement.AuthenticationResults.Success)
            {
                myLoginModel.Message = Constants.Areas.Common.LoginModel.AuthenticationResultMessages.UnknownResult;
                myLoginModel.Errors = true;
                return myLoginModel;
            }

            myLoginModel.User = myUserManagement.GetUserDetails(userName);
            myLoginModel.Groups = myUserManagement.GetUserGroups(userName);

            if(myLoginModel.User == null || myLoginModel.Groups.Count == 0)
            {
                myLoginModel.Message = Constants.Areas.Common.LoginModel.AuthenticationResultMessages.NoUserRoles;
                myLoginModel.Errors = true;
                return myLoginModel;
            }

            return myLoginModel;
        }