Copy Vault data directory to temp location before each test
To avoid the annoying clean before each test run (because Vault data has been modified by previous run), the data is now copied from resource directory to temporary location.
This commit is contained in:
parent
38a7d4952d
commit
b2082925d5
6
pom.xml
6
pom.xml
@ -131,5 +131,11 @@
|
|||||||
<version>2.13.0</version>
|
<version>2.13.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -36,6 +36,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.apache.commons.io.FileUtils.copyDirectory;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.hamcrest.core.Is.is;
|
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.
|
* Requires "vault" binary to be in current user's executable path. Not using MLock, so no extended rights required.
|
||||||
*/
|
*/
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp(TestInfo testInfo) throws VaultConnectorException {
|
public void setUp(TestInfo testInfo) throws VaultConnectorException, IOException {
|
||||||
/* Determine, if TLS is required */
|
/* Determine, if TLS is required */
|
||||||
boolean isTls = testInfo.getTags().contains("tls");
|
boolean isTls = testInfo.getTags().contains("tls");
|
||||||
|
|
||||||
@ -960,14 +961,15 @@ public class HTTPVaultConnectorTest {
|
|||||||
* @return Vault Configuration
|
* @return Vault Configuration
|
||||||
* @throws IllegalStateException on error
|
* @throws IllegalStateException on error
|
||||||
*/
|
*/
|
||||||
private VaultConfiguration initializeVault(boolean tls) throws IllegalStateException {
|
private VaultConfiguration initializeVault(boolean tls) throws IllegalStateException, IOException {
|
||||||
String dataResource = getClass().getResource("/data_dir").getPath();
|
File dataDir = tmpDir.newFolder();
|
||||||
|
copyDirectory(new File(getClass().getResource("/data_dir").getPath()), dataDir);
|
||||||
|
|
||||||
/* Generate vault local unencrypted configuration */
|
/* Generate vault local unencrypted configuration */
|
||||||
VaultConfiguration config = new VaultConfiguration()
|
VaultConfiguration config = new VaultConfiguration()
|
||||||
.withHost("localhost")
|
.withHost("localhost")
|
||||||
.withPort(getFreePort())
|
.withPort(getFreePort())
|
||||||
.withDataLocation(dataResource)
|
.withDataLocation(dataDir.toPath())
|
||||||
.disableMlock();
|
.disableMlock();
|
||||||
|
|
||||||
/* Enable TLS with custom certificate and key, if required */
|
/* Enable TLS with custom certificate and key, if required */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user