public Authorization authenticatePush(@Nullable Credential credential)
      throws RegistryAuthenticationFailedException, RegistryCredentialsNotSentException {
    return authenticate(credential, "pull,push");
  }
@Test
  public void testAuthorizationCleared() throws RegistryAuthenticationFailedException, IOException {
    ResponseException responseException = Mockito.mock(ResponseException.class);
    Mockito.when(responseException.getStatusCode()).thenReturn(401);
    Mockito.when(responseException.requestAuthorizationCleared()).thenReturn(true);
    Mockito.when(httpClient.call(Mockito.any(), Mockito.any(), Mockito.any()))
        .thenThrow(responseException);

    try {
      registryAuthenticator.authenticatePush(null);
      Assert.fail();
    } catch (RegistryCredentialsNotSentException ex) {
      Assert.assertEquals(
          "Required credentials for someserver/someimage were not sent because the connection was "
              + "over HTTP",
          ex.getMessage());
    }
  }