@Test
public void testAuthedProvidesIdToken() {

  final RequestContext requestContext = mock(RequestContext.class);
  final Request request = Request.forUri("/", "PUT")
      .withPayload(ByteString.encodeUtf8("hello"))
      .withHeader(HttpHeaders.AUTHORIZATION, "Bearer s3cr3tp455w0rd");
  when(requestContext.request()).thenReturn(request);
  when(authenticator.authenticate(any())).thenReturn(() -> Optional.of(idToken));
  final Response<Boolean> response = Middlewares.<Boolean>authed(authenticator)
      .apply(rc -> ac -> Response.forPayload(ac.user().map(idToken::equals).orElse(false)))
      .invoke(requestContext);
  assertThat(response.payload(), is(Optional.of(true)));
}