### Question:
RegistryAuthenticator { public Authorization authenticatePush(@Nullable Credential credential) throws RegistryAuthenticationFailedException, RegistryCredentialsNotSentException { return authenticate(credential, "pull,push"); } private  RegistryAuthenticator(
      String realm,
      String service,
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      @Nullable String userAgent,
      FailoverHttpClient httpClient); Authorization authenticatePull(@Nullable Credential credential); Authorization authenticatePush(@Nullable Credential credential);  }### Answer:
@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()); } }