コード例 #1
0
        public async Task Should_not_authenticate_with_wrong_password()
        {
            var email               = "*****@*****.**";
            var password            = "******";
            var registrationRequest = new RegistrationRequest
            {
                Email      = email,
                Password   = password,
                Address    = Address,
                Birthday   = _birthDay,
                Employer   = Employer,
                Occupation = Occupation,
                Name       = Name
            };

            var authenticationRequest = new AuthenticationRequest
            {
                Email    = email,
                Password = "******"
            };

            await Client.PostAsync(
                RegistrationRoute,
                registrationRequest.ToJsonContent());

            var authenticationResult = await Client.PostAsync(
                AuthenticationRoute,
                authenticationRequest.ToJsonContent());

            authenticationResult.StatusCode.Should().Be(HttpStatusCode.Forbidden);
        }
コード例 #2
0
        public async Task Should_not_authenticate_non_existing_user()
        {
            var password = "******";
            var request  = new AuthenticationRequest
            {
                Email    = "*****@*****.**",
                Password = password
            };

            var response = await Client.PostAsync(
                AuthenticationRoute,
                request.ToJsonContent());

            response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
        }
コード例 #3
0
        private async Task <string> RegisterAndAuthenticateAsync(string email, string password)
        {
            await RegisterUserAsync(email, password);

            var authenticationRequest = new AuthenticationRequest
            {
                Email    = email,
                Password = password
            };

            var authenticationResult = await Client.PostAsync(
                AuthenticationRoute,
                authenticationRequest.ToJsonContent());

            return(await authenticationResult.Content.ReadAsStringAsync());
        }
コード例 #4
0
        public async Task Should_authenticate_registered_user()
        {
            var email    = "*****@*****.**";
            var password = "******";

            await RegisterUserAsync(email, password);

            var authenticationRequest = new AuthenticationRequest
            {
                Email    = email,
                Password = password
            };

            var authenticationResult = await Client.PostAsync(
                AuthenticationRoute,
                authenticationRequest.ToJsonContent());

            authenticationResult.StatusCode.Should().Be(HttpStatusCode.OK);
        }
コード例 #5
0
        public async Task Should_create_admin_user_on_startup()
        {
            var configuration = _factory.Services.GetService <IConfiguration>();
            var login         = configuration["Admin:Login"];
            var password      = configuration["Admin:Password"];

            var request = new AuthenticationRequest
            {
                Email    = login,
                Password = password
            };

            var authenticationResult = await Client.PostAsync(
                AuthenticationRoute,
                request.ToJsonContent()
                );

            authenticationResult.StatusCode.Should().Be(200);
        }