コード例 #1
0
        public async Task WhenInvalidEmailPosted_ThenInvalidEmailError_Should_Return(string email)
        {
            var testServer = await GetTestServer();

            var client = testServer.CreateClient();

            var command = new SendResetPasswordLinkCommand(
                Guid.NewGuid(), email, Guid.NewGuid(), Random.RandomString(4));

            var response = await client.PostAsync($"{ApiPath}/send-reset-password-link", command.ToJsonContent());

            await response.Should().BeBadRequestAsync(ErrorCodes.InvalidEmailAddress);
        }
コード例 #2
0
        public async Task WhenValidEmailPosted_Then_LinkShouldBeSentToUser()
        {
            var testServer = await GetTestServer();

            var client = testServer.CreateClient();
            var model  = await CreateUserAsync(client);

            var command = new SendResetPasswordLinkCommand(
                Guid.NewGuid(), model.Email, Guid.NewGuid(), Random.RandomString(4));

            var response = await client.PostAsync($"{ApiPath}/send-reset-password-link", command.ToJsonContent());

            response.EnsureSuccessStatusCode();

            var events = Consumer.Instance.GetAll <IResetPasswordTokenGenerated>();

            events.Should().Contain(e => e.Email == command.Email &&
                                    e.FirstName == model.UserFirstName &&
                                    e.LastName == model.UserLastName &&
                                    !string.IsNullOrEmpty(e.Link));
        }
コード例 #3
0
        public async Task WhenInvalidEmailPosted_ThenInvalidEmailError_Should_Return(string email)
        {
            using (var testServer = await CreateAsync())
            {
                var client  = testServer.CreateClient();
                var captcha = await GetCaptchaAsync(client, testServer.Host.Services);

                var command = new SendResetPasswordLinkCommand(
                    Guid.NewGuid(), email, captcha.Id, captcha.Code);

                var response = await client.PostAsync($"{ApiPath}/send-reset-password-link", command.ToJsonContent());

                await response.Should().BeBadRequestAsync(ErrorCodes.InvalidEmailAddress);
            }
        }