### Question:
ConfigSecretReader { public static Optional<char[]> readSecretFromFile() { final EnvironmentVariableProvider envProvider = new EnvironmentVariableProvider(); if (envProvider.hasEnv(EnvironmentVariables.CONFIG_SECRET_PATH)) { final Path secretPath = Paths.get(envProvider.getEnv(EnvironmentVariables.CONFIG_SECRET_PATH)); if (Files.exists(secretPath)) { try { return Optional.of(new String(Files.readAllBytes(secretPath)).trim().toCharArray()); } catch (IOException ex) { LOGGER.error("Error while reading secret from file"); } } } LOGGER.warn("Not able to find or read any secret for decrypting sensitive values in config."); return Optional.empty(); } private  ConfigSecretReader(); static Optional<char[]> readSecretFromFile(); static char[] readSecretFromConsole();  }### Answer:
@Test public void testReadSecret() { envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, filePath); Optional<char[]> secret = ConfigSecretReader.readSecretFromFile(); assertThat(secret).isPresent(); assertThat(secret.get()).isEqualTo("quorum".toCharArray()); }
@Test public void testNotAbleToReadSecret() { envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, "not-existed"); assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty(); }
@Test public void envNotSet() { envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH); assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty(); }
@Test public void testReadException() throws IOException { envVariables.clear(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH); final File tempFile = tempDir.newFile("key.secret"); tempFile.setReadable(false); envVariables.set(com.quorum.tessera.config.util.EnvironmentVariables.CONFIG_SECRET_PATH, tempFile.getAbsolutePath()); assertThat(ConfigSecretReader.readSecretFromFile()).isEmpty(); }