public void Can_Generate_BCrypt_Password_Hash_Salted_With_Email_Concatenated_With_Password()
        {
            // Setup
            IProcess<GenerateUserPasswordHashParams, GeneratedPasswordHashViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;

            // Act
            var result = process.Execute(new GenerateUserPasswordHashParams { Email = email, PlainTextPassword = password });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(BCrypt.Net.BCrypt.Verify(saltedPassword, result.PasswordHash), "Password has was not correct");
        }
        public void Verify_Fails_For_BCrypt_Password_Hash_Not_Correct_For_Supplied_Credentials()
        {
            // Setup
            IProcess<VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams { Email = email, PlainTextPassword = "******", HashedPassword = hashedPassword });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsFalse(result.PasswordVerified, "Password was incorrectly verified as matching");
        }
        public void Can_Verify_BCrypt_Password_Hash_Salted_With_Email_Concatenated_With_Password()
        {
            // Setup
            IProcess<VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams { Email = email, PlainTextPassword = password, HashedPassword = hashedPassword });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.PasswordVerified, "Password was not verified as matching");
        }
Example #4
0
        public void Password_Generated_Using_Trimmed_And_Lowercased_Email()
        {
            // Setup
            IProcess <GenerateUserPasswordHashParams, GeneratedPasswordHashViewModel> process = new UserPasswordProcesses();
            string email = " EMAIL ", password = "******";
            string saltedPassword = email.ToLower().Trim() + password;

            // Act
            var result = process.Execute(new GenerateUserPasswordHashParams {
                Email = email, PlainTextPassword = password
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(BCrypt.Net.BCrypt.Verify(saltedPassword, result.PasswordHash), "Password has was not correct");
        }
Example #5
0
        public void Verify_Fails_For_BCrypt_Password_Hash_Not_Correct_For_Supplied_Credentials()
        {
            // Setup
            IProcess <VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams {
                Email = email, PlainTextPassword = "******", HashedPassword = hashedPassword
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsFalse(result.PasswordVerified, "Password was incorrectly verified as matching");
        }
Example #6
0
        public void Can_Verify_BCrypt_Password_Hash_Salted_With_Email_Concatenated_With_Password()
        {
            // Setup
            IProcess <VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams {
                Email = email, PlainTextPassword = password, HashedPassword = hashedPassword
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.PasswordVerified, "Password was not verified as matching");
        }
Example #7
0
        public void Can_Generate_BCrypt_Password_Hash_Salted_With_Email_Concatenated_With_Password()
        {
            // Setup
            IProcess <GenerateUserPasswordHashParams, GeneratedPasswordHashViewModel> process = new UserPasswordProcesses();
            string email = "email", password = "******";
            string saltedPassword = email + password;

            // Act
            var result = process.Execute(new GenerateUserPasswordHashParams {
                Email = email, PlainTextPassword = password
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(BCrypt.Net.BCrypt.Verify(saltedPassword, result.PasswordHash), "Password has was not correct");
        }
Example #8
0
        public void Verify_Passes_For_BCrypt_Password_Hash_When_Email_Is_Capitalized_And_Requires_Trimming()
        {
            // Setup
            IProcess <VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = " EMAIL ", password = "******";
            string saltedPassword = email.ToLower().Trim() + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams {
                Email = email, PlainTextPassword = password, HashedPassword = hashedPassword
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.PasswordVerified, "Password was not verified as matching");
        }
        public void Verify_Passes_For_BCrypt_Password_Hash_When_Email_Is_Capitalized_And_Requires_Trimming()
        {
            // Setup
            IProcess<VerifyUserPasswordHashParams, UserPasswordVerificationResultViewModel> process = new UserPasswordProcesses();
            string email = " EMAIL ", password = "******";
            string saltedPassword = email.ToLower().Trim() + password;
            string hashedPassword = BCrypt.Net.BCrypt.HashPassword(saltedPassword);

            // Act
            var result = process.Execute(new VerifyUserPasswordHashParams { Email = email, PlainTextPassword = password, HashedPassword = hashedPassword });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.PasswordVerified, "Password was not verified as matching");
        }
        public void Password_Generated_Using_Trimmed_And_Lowercased_Email()
        {
            // Setup
            IProcess<GenerateUserPasswordHashParams, GeneratedPasswordHashViewModel> process = new UserPasswordProcesses();
            string email = " EMAIL ", password = "******";
            string saltedPassword = email.ToLower().Trim() + password;

            // Act
            var result = process.Execute(new GenerateUserPasswordHashParams { Email = email, PlainTextPassword = password });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(BCrypt.Net.BCrypt.Verify(saltedPassword, result.PasswordHash), "Password has was not correct");
        }