@Nullable
  AuthTemplate getAuthFor(String registry) {
    Map.Entry<String, AuthTemplate> authEntry =
        findFirstInMapByKey(dockerConfigTemplate.getAuths(), getRegistryMatchersFor(registry));
    return authEntry != null ? authEntry.getValue() : null;
  }
@Test
  public void testGetAuthFor_orderOfMatchPreference() throws URISyntaxException, IOException {
    Path json =
        Paths.get(Resources.getResource("core/json/dockerconfig_extra_matches.json").toURI());

    DockerConfig dockerConfig =
        new DockerConfig(JsonTemplateMapper.readJsonFromFile(json, DockerConfigTemplate.class));

    Assert.assertEquals(
        "my-registry: exact match", dockerConfig.getAuthFor("my-registry").getAuth());
    Assert.assertEquals(
        "cool-registry: with https", dockerConfig.getAuthFor("cool-registry").getAuth());
    Assert.assertEquals(
        "awesome-registry: starting with name",
        dockerConfig.getAuthFor("awesome-registry").getAuth());
    Assert.assertEquals(
        "dull-registry: starting with name and with https",
        dockerConfig.getAuthFor("dull-registry").getAuth());
  }