mirror of
https://github.com/valitydev/adapter-common-lib.git
synced 2024-11-06 10:15:23 +00:00
Vault with custom kv-path (#50)
Co-authored-by: Inal Arsanukaev <aiz@empayre.com>
This commit is contained in:
parent
26b607d603
commit
42a2972d9e
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>adapter-common-lib</artifactId>
|
<artifactId>adapter-common-lib</artifactId>
|
||||||
<version>1.2.7</version>
|
<version>1.2.8</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>adapter-common-lib</name>
|
<name>adapter-common-lib</name>
|
||||||
|
@ -10,9 +10,12 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.vault.authentication.TokenAuthentication;
|
import org.springframework.vault.authentication.TokenAuthentication;
|
||||||
import org.springframework.vault.client.VaultEndpoint;
|
import org.springframework.vault.client.VaultEndpoint;
|
||||||
import org.springframework.vault.core.VaultTemplate;
|
import org.springframework.vault.core.VaultTemplate;
|
||||||
|
import org.testcontainers.containers.Container;
|
||||||
import org.testcontainers.utility.DockerImageName;
|
import org.testcontainers.utility.DockerImageName;
|
||||||
import org.testcontainers.vault.VaultContainer;
|
import org.testcontainers.vault.VaultContainer;
|
||||||
|
import org.testcontainers.vault.VaultLogLevel;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
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 SIMPLE_SECRET = "sbdhfvh2y32bub";
|
||||||
public static final String HMAC_KEY = "hmacKey";
|
public static final String HMAC_KEY = "hmacKey";
|
||||||
public static final String HMAC_SECRET = "6d6b6c6172657772";
|
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 VaultSecretService vaultService;
|
||||||
|
|
||||||
private static final String TEST_PATH = "test-terminal-123";
|
private static final String TEST_PATH = "test-terminal-123";
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
public static void setUp() throws IOException, InterruptedException {
|
||||||
VaultContainer<?> container = new VaultContainer<>(DockerImageName.parse("vault:1.1.3"))
|
VaultContainer<?> container = new VaultContainer<>(DockerImageName.parse("vault:1.1.3"))
|
||||||
|
.withLogLevel(VaultLogLevel.Trace)
|
||||||
.withVaultToken("my-root-token");
|
.withVaultToken("my-root-token");
|
||||||
container.start();
|
container.start();
|
||||||
|
container.execInContainer("vault", "secrets", "enable", "-version=2", "-path=" + SERVICE_NAME, " kv");
|
||||||
VaultEndpoint vaultEndpoint = VaultEndpoint.create("localhost", container.getFirstMappedPort());
|
VaultEndpoint vaultEndpoint = VaultEndpoint.create("localhost", container.getFirstMappedPort());
|
||||||
vaultEndpoint.setScheme("http");
|
vaultEndpoint.setScheme("http");
|
||||||
VaultTemplate vaultTemplate = new VaultTemplate(vaultEndpoint, new TokenAuthentication("my-root-token"));
|
VaultTemplate vaultTemplate = new VaultTemplate(vaultEndpoint, new TokenAuthentication("my-root-token"));
|
||||||
|
Loading…
Reference in New Issue
Block a user