Vault with custom kv-path (#50)

Co-authored-by: Inal Arsanukaev <aiz@empayre.com>
This commit is contained in:
Inal Arsanukaev 2023-01-19 16:51:59 +03:00 committed by GitHub
parent 26b607d603
commit 42a2972d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -12,7 +12,7 @@
</parent>
<artifactId>adapter-common-lib</artifactId>
<version>1.2.7</version>
<version>1.2.8</version>
<packaging>jar</packaging>
<name>adapter-common-lib</name>

View File

@ -10,9 +10,12 @@ import org.junit.jupiter.api.Test;
import org.springframework.vault.authentication.TokenAuthentication;
import org.springframework.vault.client.VaultEndpoint;
import org.springframework.vault.core.VaultTemplate;
import org.testcontainers.containers.Container;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.vault.VaultContainer;
import org.testcontainers.vault.VaultLogLevel;
import java.io.IOException;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
@ -23,16 +26,18 @@ public class VaultSecretServiceTest {
public static final String SIMPLE_SECRET = "sbdhfvh2y32bub";
public static final String HMAC_KEY = "hmacKey";
public static final String HMAC_SECRET = "6d6b6c6172657772";
public static final String SERVICE_NAME = "secret";
public static final String SERVICE_NAME = "adapter-vtb";
private static VaultSecretService vaultService;
private static final String TEST_PATH = "test-terminal-123";
@BeforeAll
public static void setUp() {
public static void setUp() throws IOException, InterruptedException {
VaultContainer<?> container = new VaultContainer<>(DockerImageName.parse("vault:1.1.3"))
.withLogLevel(VaultLogLevel.Trace)
.withVaultToken("my-root-token");
container.start();
container.execInContainer("vault", "secrets", "enable", "-version=2", "-path=" + SERVICE_NAME, " kv");
VaultEndpoint vaultEndpoint = VaultEndpoint.create("localhost", container.getFirstMappedPort());
vaultEndpoint.setScheme("http");
VaultTemplate vaultTemplate = new VaultTemplate(vaultEndpoint, new TokenAuthentication("my-root-token"));