@Test
  public void testAuthPullByWwwAuthenticate_invalidAuthMethod() {
    RegistryClient registryClient =
        RegistryClient.factory(eventHandlers, "server", "foo/bar", null).newRegistryClient();
    try {
      registryClient.authPullByWwwAuthenticate("invalid WWW-Authenticate");
      Assert.fail();
    } catch (RegistryException ex) {
      Assert.assertEquals(
          "Failed to authenticate with registry server/foo/bar because: 'Bearer' was not found in "
              + "the 'WWW-Authenticate' header, tried to parse: invalid WWW-Authenticate",
          ex.getMessage());
    }
  }
Tests for {@link RegistryClient}. More comprehensive tests can be found in the integration tests.
jib-core/src/test/java/com/google/cloud/tools/jib/registry/RegistryClientTest.java