@Test void passwordResolution() throws Exception { assertEquals("pass1", Utils.getPasswordFromInputs("pass1", null, null), "getPasswordFromInputs did not retrieve the password from a string"); assertEquals("pass2", Utils.getPasswordFromInputs(null, Paths.get("./src/test/resources/utilsTest/testPasswordFile.txt"), null), "getPasswordFromInputs did not retrieve the password from a file"); assertEquals("pass3", Utils.getPasswordFromInputs(null, null, "TEST_ENV_PASSWORD"), "getPasswordFromInputs did not retrieve the password from the environment"); assertEquals("pass2", Utils.getPasswordFromInputs(null, Paths.get("./src/test/resources/utilsTest/testPasswordFile.txt"), "TEST_ENV_PASSWORD"), "getPasswordFromInputs did not give preference to the file over the environment"); }
public static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv) throws IOException { if (!isEmptyString(passwordStr)) { return passwordStr; } else if (validFile(passwordFile)) { try ( BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile.toFile())) ) { return bufferedReader.readLine(); } } else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) { return System.getenv(passwordEnv); } return null; }
Utils { public static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv) throws IOException { if (!isEmptyString(passwordStr)) { return passwordStr; } else if (validFile(passwordFile)) { try ( BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile.toFile())) ) { return bufferedReader.readLine(); } } else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) { return System.getenv(passwordEnv); } return null; } }
Utils { public static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv) throws IOException { if (!isEmptyString(passwordStr)) { return passwordStr; } else if (validFile(passwordFile)) { try ( BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile.toFile())) ) { return bufferedReader.readLine(); } } else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) { return System.getenv(passwordEnv); } return null; } private  Utils(); }
Utils { public static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv) throws IOException { if (!isEmptyString(passwordStr)) { return passwordStr; } else if (validFile(passwordFile)) { try ( BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile.toFile())) ) { return bufferedReader.readLine(); } } else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) { return System.getenv(passwordEnv); } return null; } private  Utils(); static void copyResourceAsFile(String resourcePath, String destPath, boolean markExec); static void copyLocalFile(Path sourcePath, Path destPath, boolean markExec); static void copyLocalDirectory(Path sourcePath, Path destPath, boolean markExec); static void setProxyIfRequired(String httpProxyUrl, String httpsProxyUrl, String nonProxyHosts); static String writeDockerfile(String destPath, String template, DockerfileOptions options, boolean dryRun); static void writeResolvedFiles(List<Path> paths, List<Object> options); static void deleteFilesRecursively(String pathDir); static int compareVersions(String thisVersion, String otherVersion); static boolean isEmptyString(String s); static Properties getBaseImageProperties(String dockerImage, String tmpDir); static String findProxyUrl(String proxyUrl, String protocol); static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv); static String getEnvironmentProperty(String name); static String getBuildWorkingDir(); static String getOpatchVersionFromZip(String fileName); static boolean validatePatchIds(List<String> patches, boolean rigid); static void setOracleHome(List<Path> responseFiles, DockerfileOptions options); static void setInventoryLocation(String inventoryLocFile, DockerfileOptions options); static String getMessage(@PropertyKey(resourceBundle = "ImageTool") String key, Object... params); static void removeIntermediateDockerImages(String buildId); static String getPsuVersion(String lsInventory); @SafeVarargs static List<T> list(Collection<? extends T> start, T... elements); }
Utils { public static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv) throws IOException { if (!isEmptyString(passwordStr)) { return passwordStr; } else if (validFile(passwordFile)) { try ( BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile.toFile())) ) { return bufferedReader.readLine(); } } else if (!isEmptyString(passwordEnv) && !isEmptyString(System.getenv(passwordEnv))) { return System.getenv(passwordEnv); } return null; } private  Utils(); static void copyResourceAsFile(String resourcePath, String destPath, boolean markExec); static void copyLocalFile(Path sourcePath, Path destPath, boolean markExec); static void copyLocalDirectory(Path sourcePath, Path destPath, boolean markExec); static void setProxyIfRequired(String httpProxyUrl, String httpsProxyUrl, String nonProxyHosts); static String writeDockerfile(String destPath, String template, DockerfileOptions options, boolean dryRun); static void writeResolvedFiles(List<Path> paths, List<Object> options); static void deleteFilesRecursively(String pathDir); static int compareVersions(String thisVersion, String otherVersion); static boolean isEmptyString(String s); static Properties getBaseImageProperties(String dockerImage, String tmpDir); static String findProxyUrl(String proxyUrl, String protocol); static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv); static String getEnvironmentProperty(String name); static String getBuildWorkingDir(); static String getOpatchVersionFromZip(String fileName); static boolean validatePatchIds(List<String> patches, boolean rigid); static void setOracleHome(List<Path> responseFiles, DockerfileOptions options); static void setInventoryLocation(String inventoryLocFile, DockerfileOptions options); static String getMessage(@PropertyKey(resourceBundle = "ImageTool") String key, Object... params); static void removeIntermediateDockerImages(String buildId); static String getPsuVersion(String lsInventory); @SafeVarargs static List<T> list(Collection<? extends T> start, T... elements);  }