@Test
public void testCheckWritePublicBucketWithUnauthorizedProxyChain() {

    final RequestAction action = RequestAction.WRITE;
    // first request will be to authorize the proxy
    final AuthorizationRequest expectedProxyAuthorizationRequest = getProxyAuthorizationRequest(action, USER_WITH_PROXY_CHAIN.getChain());
    when(authorizer.authorize(argThat(new AuthorizationRequestMatcher(expectedProxyAuthorizationRequest))))
            .thenReturn(AuthorizationResult.denied());
    // the authorization of the proxy chain should return denied
    final Authorizable bucketAuthorizable = authorizableLookup.getBucketAuthorizable(bucketPublic.getIdentifier());
    final AuthorizationResult result = bucketAuthorizable.checkAuthorization(authorizer, action, USER_WITH_PROXY_CHAIN);
    assertNotNull(result);
    assertEquals(AuthorizationResult.Result.Denied, result.getResult());
    // Should never call authorizer once for /proxy and then return denied
    verify(authorizer, times(1)).authorize(any(AuthorizationRequest.class));
}