@Test
  public void testCall_credentialsForcedOverHttp() throws IOException, RegistryException {
    ResponseException unauthorizedException =
        mockResponseException(HttpStatusCodes.STATUS_CODE_UNAUTHORIZED);
    setUpRegistryResponse(unauthorizedException);
    System.setProperty(JibSystemProperties.SEND_CREDENTIALS_OVER_HTTP, "true");

    try {
      endpointCaller.call();
      Assert.fail("Call should have failed");

    } catch (RegistryCredentialsNotSentException ex) {
      throw new AssertionError("should have sent credentials", ex);
    } catch (RegistryUnauthorizedException ex) {
      Assert.assertEquals("Unauthorized for serverUrl/imageName", ex.getMessage());
    }
  }
Implementation of {@link RegistryEndpointProvider} for testing.
jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryEndpointCallerTest.java