@Override
  public UserSession authenticate(HttpRequest request, HttpResponse response) {
    UserAuthResult userAuthResult = loadUser(request, response);
    if (nonNull(userAuthResult.getUserDto())) {
      if (TOKEN.equals(userAuthResult.getAuthType())) {
        return userSessionFactory.create(userAuthResult.getUserDto(), userAuthResult.getTokenDto());
      }
      boolean isAuthenticatedBrowserSession = JWT.equals(userAuthResult.getAuthType());
      return userSessionFactory.create(userAuthResult.getUserDto(), isAuthenticatedBrowserSession);
    } else if (GITHUB_WEBHOOK.equals(userAuthResult.getAuthType())) {
      return userSessionFactory.createGithubWebhookUserSession();
    }
    return userSessionFactory.createAnonymous();
  }
@Test
  public void authenticate_from_jwt_token() {
    when(httpHeadersAuthentication.authenticate(request, response)).thenReturn(Optional.empty());
    when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.of(A_USER));

    UserSession userSession = underTest.authenticate(request, response);
    assertThat(userSession.getUuid()).isEqualTo(A_USER.getUuid());
    assertThat(userSession.isAuthenticatedBrowserSession()).isTrue();

    verify(response, never()).setStatus(anyInt());
  }