public async Task <ActionResult <SignInResponse> > SignIn(SignInRequest request)
        {
            var authAttempt = await _userAuthService.AuthenticateAsync(request.Username, request.Password);

            if (!authAttempt.IsSuccess)
            {
                return(StatusCode((int)HttpStatusCode.Unauthorized, new SignInResponse
                {
                    ResultCode = authAttempt.Code.ToString("G"),
                }));
            }

            Response.Cookies.Append(
                JwtBearerAuthenticationOptions.JwtBearerAuthentication,
                _jwtTokenGenerator.CreateToken(authAttempt.User),
                new CookieOptions
            {
                Expires  = DateTimeOffset.Now.AddDays(7),
                HttpOnly = false,
                Secure   = false,
            }
                );

            return(Ok(new SignInResponse
            {
                ResultCode = authAttempt.Code.ToString("G"),
            }));
        }
        public async Task When_CredentialsAreValid_Should_ReturnAuthenticationResult_With_SuccessCodeAndUser()
        {
            IUserAuthService service = await CreateMockService();

            var authenticationResult = await service.AuthenticateAsync(CorrectUsername, CorrectPassword);

            Assert.AreEqual(AuthenticationResultCode.Success, authenticationResult.Code);
            Assert.IsNotNull(authenticationResult.User);
        }
        public async Task When_PasswordMismatches_Should_ReturnAuthenticationResult_With_InvalidCredentialsCode()
        {
            IUserAuthService service = await CreateMockService();

            var authenticationResult = await service.AuthenticateAsync(CorrectUsername, IncorrectPassword);

            Assert.AreEqual(AuthenticationResultCode.InvalidCredentials, authenticationResult.Code);
            Assert.IsNull(authenticationResult.User);
        }