Exemplo n.º 1
0
        public void CanLoadWaiterIfPasswordsMatch()
        {
            const string salt     = "salt";
            const string password = "******";

            A.CallTo(() => passwordEncryptor.GenerateSalt()).Returns(salt);
            A.CallTo(() => passwordEncryptor.GenerateHash(password, salt)).Returns("cba");

            var waiter = new Staff
            {
                UserAccount = new UserAccount
                {
                    Password = password.ComputePBKDF2Hash(salt, passwordEncryptor),
                    Salt     = salt
                }
            };

            A.CallTo(() => repository.FindBy <Staff>(a => a.UserAccount.Username == "a"))
            .WithAnyArguments()
            .Returns(new List <Staff> {
                waiter
            });

            var result = staffDomainService.LoadStaff("a", password);

            Assert.IsTrue(result.IsNotNull());
        }
Exemplo n.º 2
0
 public static string ComputePBKDF2Hash(this string value, string salt, IPasswordEncryptor passwordEncryptor)
 {
     return(passwordEncryptor.GenerateHash(value, salt));
 }