Example #1
0
        public string CheckLogin(string enteredUserName, string enteredPassword)
        {
            if (string.IsNullOrEmpty(enteredUserName) || string.IsNullOrEmpty(enteredPassword))
            {
                return(NullCred);
            }
            else
            {
                User existingUser = _usersAccessor.FindUser(enteredUserName);

                string hashedPassword = _usersAccessor.ComputeSha256Hash(enteredPassword);

                if (existingUser == null)
                {
                    return(UserDNE);
                }
                else if (hashedPassword != existingUser.Password)
                {
                    return(PasswordsDoNotMatch);
                }
                else
                {
                    return(SuccessfulLogin);
                }
            }
        }
Example #2
0
        public void FindUser_WithUserExisting_ShouldReturnExistingUser()
        {
            //Arrange
            User   foundUser    = new User();
            string testUserName = "******";

            //Act
            foundUser = _usersAccessor.FindUser(testUserName);

            //Assert
            Assert.That(foundUser.UserName, Is.EqualTo("test_userName"));
            Assert.That(foundUser.Password, Is.EqualTo("10a6e6cc8311a3e2bcc09bf6c199adecd5dd59408c343e926b129c4914f3cb01"));
        }