예제 #1
0
        public async Task ChangeUserPasswordCommand_UserPasswordAndSaltChanged()
        {
            // Arrange
            const string        userName           = "******";
            Guid                userId             = Guid.NewGuid();
            const string        userPassword       = "******";
            const string        passwordSalt       = "SaltySalt";
            User                user               = new User(userId, userName, "Dirk", "Gently", "*****@*****.**", userPassword, passwordSalt, "555-1234");
            IAccountsRepository accountsRepository = _container.Resolve <IAccountsRepository>();
            await accountsRepository.Add(user);

            // Act
            ICommandBus  commandBus  = _container.Resolve <ICommandBus>();
            const string newPassword = "******";
            await commandBus.Send(new ChangeUserPasswordCommand
            {
                UserId   = userId,
                Password = newPassword
            });

            IAccountsPerspective        accountsPerspective = _container.Resolve <IAccountsPerspective>();
            AccountWithCredentialsModel userWithCredentials = await accountsPerspective.GetUserWithCredentials(userName);

            // Assert
            userWithCredentials.PasswordHash
            .Should().NotBeNullOrWhiteSpace("Password should be hashed and contained")
            .And.NotBe(userPassword)
            .And.NotBe(newPassword);

            userWithCredentials.PasswordSalt
            .Should().NotBeEmpty()
            .And.NotBe(passwordSalt);
        }
예제 #2
0
        public async Task <AccountWithCredentialsModel> Handle(AccountByUserNameQuery query)
        {
            AccountWithCredentialsModel accountWithCredentialsModel = await _perspective.GetUserWithCredentials(query.UserName);

            if (accountWithCredentialsModel != null)
            {
                return(accountWithCredentialsModel);
            }
            throw new UserNotFoundFgException(query.UserName);
        }