@Test
  public void testDoBearerAuth()
      throws IOException, InterruptedException, GeneralSecurityException, URISyntaxException,
          RegistryException {
    setUpAuthServerAndRegistry(1, "HTTP/1.1 200 OK\nContent-Length: 1234\n\n");

    RegistryClient registryClient = createRegistryClient(null);
    Assert.assertTrue(registryClient.doPushBearerAuth());

    Optional<BlobDescriptor> digestAndSize = registryClient.checkBlob(digest);
    Assert.assertEquals(1234, digestAndSize.get().getSize());

    Mockito.verify(eventHandlers).dispatch(logContains("attempting bearer auth"));
    Mockito.verify(eventHandlers).dispatch(logContains("bearer auth succeeded"));
  }
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