예제 #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());
        }
예제 #2
0
        /// <summary>
        /// Generates a new salt and encrypts the password
        /// </summary>
        public void EncrypPassword(IPasswordEncryptor passwordEncryptor)
        {
            Guard.ArgumentNotNull(passwordEncryptor, "passwordEncryptor");
            Guard.InstanceNotNull(Password, "Password");

            Salt     = passwordEncryptor.GenerateSalt();
            Password = Password.ComputePBKDF2Hash(Salt, passwordEncryptor);
        }