public List<CredentialRetriever> asList() throws FileNotFoundException {
    List<CredentialRetriever> credentialRetrievers = new ArrayList<>();
    if (knownCredentialRetriever != null) {
      credentialRetrievers.add(knownCredentialRetriever);
    }
    if (credentialHelper != null) {
      // If credential helper contains file separator, treat as path; otherwise treat as suffix
      if (credentialHelper.contains(FileSystems.getDefault().getSeparator())) {
        if (!Files.exists(Paths.get(credentialHelper))) {
          String osName = systemProperties.getProperty("os.name").toLowerCase(Locale.ENGLISH);
          if (!osName.contains("windows")
              || (!Files.exists(Paths.get(credentialHelper + ".cmd"))
                  && !Files.exists(Paths.get(credentialHelper + ".exe")))) {
            throw new FileNotFoundException(
                "Specified credential helper was not found: " + credentialHelper);
          }
        }
        credentialRetrievers.add(
            credentialRetrieverFactory.dockerCredentialHelper(credentialHelper));
      } else {
        String suffix = credentialHelper; // not path; treat as suffix
        credentialRetrievers.add(
            credentialRetrieverFactory.dockerCredentialHelper("docker-credential-" + suffix));
      }
    }

    if (inferredCredentialRetriever != null) {
      credentialRetrievers.add(inferredCredentialRetriever);
    }

    Set<Path> dockerConfigFiles = new LinkedHashSet<>();

    String xdgRuntime = environment.get("XDG_RUNTIME_DIR");
    if (xdgRuntime != null) {
      dockerConfigFiles.add(Paths.get(xdgRuntime).resolve(XDG_AUTH_FILE));
    }
    String xdgConfigHome = environment.get("XDG_CONFIG_HOME");
    if (xdgConfigHome != null) {
      dockerConfigFiles.add(Paths.get(xdgConfigHome).resolve(XDG_AUTH_FILE));
    }
    String homeProperty = systemProperties.getProperty("user.home");
    if (homeProperty != null) {
      dockerConfigFiles.add(Paths.get(homeProperty).resolve(".config").resolve(XDG_AUTH_FILE));
    }
    String homeEnvVar = environment.get("HOME");
    if (homeEnvVar != null) {
      dockerConfigFiles.add(Paths.get(homeEnvVar).resolve(".config").resolve(XDG_AUTH_FILE));
    }

    String dockerConfigEnv = environment.get("DOCKER_CONFIG");
    if (dockerConfigEnv != null) {
      dockerConfigFiles.addAll(getDockerFiles(Paths.get(dockerConfigEnv)));
    }
    if (homeProperty != null) {
      dockerConfigFiles.addAll(getDockerFiles(Paths.get(homeProperty).resolve(".docker")));
    }
    if (homeEnvVar != null) {
      dockerConfigFiles.addAll(getDockerFiles(Paths.get(homeEnvVar).resolve(".docker")));
    }

    dockerConfigFiles.stream()
        .map(
            path ->
                path.endsWith(LEGACY_DOCKER_CONFIG_FILE)
                    ? credentialRetrieverFactory.legacyDockerConfig(path)
                    : credentialRetrieverFactory.dockerConfig(path))
        .forEach(credentialRetrievers::add);

    credentialRetrievers.add(credentialRetrieverFactory.wellKnownCredentialHelpers());
    credentialRetrievers.add(credentialRetrieverFactory.googleApplicationDefaultCredentials());
    return credentialRetrievers;
  }
@Test
  public void testDockerConfigRetrievers_undefinedHome() throws FileNotFoundException {
    List<CredentialRetriever> retrievers =
        new DefaultCredentialRetrievers(
                mockCredentialRetrieverFactory, new Properties(), new HashMap<>())
            .asList();
    assertThat(retrievers)
        .containsExactly(
            mockWellKnownCredentialHelpersCredentialRetriever,
            mockApplicationDefaultCredentialRetriever)
        .inOrder();
  }