@Test
public void goodCredentialsSetsCookie() throws Exception {

  User user = User.named("goodUser");
  when(ldapAuthenticator.authenticate(goodCredentials)).thenReturn(Optional.of(user));
  Response response = sessionLoginResource.login(LoginRequest.from("good", "credentials".toCharArray()));
  assertThat(response.getStatus()).isEqualTo(200);
  Map<String, NewCookie> responseCookies = response.getCookies();
  assertThat(responseCookies).hasSize(1).containsOnlyKeys("session");
  User authUser = cookieAuthenticator.authenticate(responseCookies.get("session"))
      .orElseThrow(RuntimeException::new);
  assertThat(authUser).isEqualTo(user);
}