diff --git a/pom.xml b/pom.xml index 47dc4fa..07a17dd 100644 --- a/pom.xml +++ b/pom.xml @@ -131,5 +131,11 @@ 2.13.0 test + + commons-io + commons-io + 2.6 + test + diff --git a/src/test/java/de/stklcode/jvault/connector/HTTPVaultConnectorTest.java b/src/test/java/de/stklcode/jvault/connector/HTTPVaultConnectorTest.java index 98920a2..5b4f33e 100644 --- a/src/test/java/de/stklcode/jvault/connector/HTTPVaultConnectorTest.java +++ b/src/test/java/de/stklcode/jvault/connector/HTTPVaultConnectorTest.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.apache.commons.io.FileUtils.copyDirectory; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.core.Is.is; @@ -84,7 +85,7 @@ public class HTTPVaultConnectorTest { * Requires "vault" binary to be in current user's executable path. Not using MLock, so no extended rights required. */ @BeforeEach - public void setUp(TestInfo testInfo) throws VaultConnectorException { + public void setUp(TestInfo testInfo) throws VaultConnectorException, IOException { /* Determine, if TLS is required */ boolean isTls = testInfo.getTags().contains("tls"); @@ -960,14 +961,15 @@ public class HTTPVaultConnectorTest { * @return Vault Configuration * @throws IllegalStateException on error */ - private VaultConfiguration initializeVault(boolean tls) throws IllegalStateException { - String dataResource = getClass().getResource("/data_dir").getPath(); + private VaultConfiguration initializeVault(boolean tls) throws IllegalStateException, IOException { + File dataDir = tmpDir.newFolder(); + copyDirectory(new File(getClass().getResource("/data_dir").getPath()), dataDir); /* Generate vault local unencrypted configuration */ VaultConfiguration config = new VaultConfiguration() .withHost("localhost") .withPort(getFreePort()) - .withDataLocation(dataResource) + .withDataLocation(dataDir.toPath()) .disableMlock(); /* Enable TLS with custom certificate and key, if required */