### Question:
EnclaveFactory { static String readSecretFromFile(final Path path) throws IOException { final String password = Files.asCharSource(path.toFile(), StandardCharsets.UTF_8).readFirstLine(); if (password == null || password.isEmpty()) { throw new InvalidConfigurationException("Keystore password file is empty: " + path); } return password; } EnclaveFactory(final Vertx vertx); Enclave createVertxEnclave(final URI enclaveUri); Enclave createVertxEnclave(
      final URI enclaveUri,
      final Path privacyKeyStoreFile,
      final Path privacyKeyStorePasswordFile,
      final Path privacyAllowlistFile);  }### Answer:
@Test public void passwordCanBeReadFromFile() throws IOException { final File passwordFile = temporaryFolder.newFile(); Files.writeString(passwordFile.toPath(), "test" + System.lineSeparator() + "test2"); assertThat(EnclaveFactory.readSecretFromFile(passwordFile.toPath())).isEqualTo("test"); }
@Test public void emptyFileThrowsException() throws IOException { final File passwordFile = temporaryFolder.newFile(); assertThatExceptionOfType(InvalidConfigurationException.class) .isThrownBy(() -> EnclaveFactory.readSecretFromFile(passwordFile.toPath())) .withMessage(EMPTY_FILE_ERROR_MSG, passwordFile); }
@Test public void fileWithOnlyEoLThrowsException() throws IOException { final File passwordFile = temporaryFolder.newFile(); Files.writeString(passwordFile.toPath(), System.lineSeparator()); assertThatExceptionOfType(InvalidConfigurationException.class) .isThrownBy(() -> EnclaveFactory.readSecretFromFile(passwordFile.toPath())) .withMessage(EMPTY_FILE_ERROR_MSG, passwordFile); }