public <T extends ManifestTemplate> ManifestAndDigest<T> pullManifest(
      String imageQualifier, Class<T> manifestTemplateClass) throws IOException, RegistryException {
    ManifestPuller<T> manifestPuller =
        new ManifestPuller<>(
            registryEndpointRequestProperties, imageQualifier, manifestTemplateClass);
    return callRegistryEndpoint(manifestPuller);
  }
@Test
  public void testPullManifest()
      throws IOException, InterruptedException, GeneralSecurityException, URISyntaxException,
          RegistryException {
    String manifestResponse =
        "HTTP/1.1 200 OK\nContent-Length: 307\n\n{\n"
            + "    \"schemaVersion\": 2,\n"
            + "    \"mediaType\": \"application/vnd.docker.distribution.manifest.v2+json\",\n"
            + "    \"config\": {\n"
            + "        \"mediaType\": \"application/vnd.docker.container.image.v1+json\",\n"
            + "        \"size\": 7023,\n"
            + "        \"digest\": \"sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7\"\n"
            + "    }\n"
            + "}";

    registry = new TestWebServer(false, Arrays.asList(manifestResponse), 1);
    RegistryClient registryClient = createRegistryClient(null);
    ManifestAndDigest<?> manifestAndDigest = registryClient.pullManifest("image-tag");

    Assert.assertEquals(
        "sha256:6b61466eabab6e5ffb68ae2bd9b85c789225540c2ac54ea1f71eb327588e8946",
        manifestAndDigest.getDigest().toString());

    Assert.assertTrue(manifestAndDigest.getManifest() instanceof V22ManifestTemplate);
    V22ManifestTemplate manifest = (V22ManifestTemplate) manifestAndDigest.getManifest();
    Assert.assertEquals(2, manifest.getSchemaVersion());
    Assert.assertEquals(
        "application/vnd.docker.distribution.manifest.v2+json", manifest.getManifestMediaType());
    Assert.assertEquals(
        "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7",
        manifest.getContainerConfiguration().getDigest().toString());
    Assert.assertEquals(7023, manifest.getContainerConfiguration().getSize());

    MatcherAssert.assertThat(
        registry.getInputRead(),
        CoreMatchers.containsString("GET /v2/foo/bar/manifests/image-tag "));
  }