@Test public void successfulAuth() throws Exception {

  User user = User.named("username");
  Cookie sessionCookie = new Cookie("session", "valid-session");
  cookies.put(sessionCookie.getName(), sessionCookie);
  when(cookieAuthenticator.authenticate(sessionCookie)).thenReturn(Optional.of(user));
  assertThat(factory.provide(request)).isEqualTo(user);
}