public class VaultContainer<SELF extends VaultContainer<SELF>>
extends org.testcontainers.containers.GenericContainer<SELF>
Other helpful features include the withVaultPort, and withVaultToken methods for convenience.
| Constructor and Description |
|---|
VaultContainer()
Deprecated.
use
VaultContainer(DockerImageName) instead |
VaultContainer(org.testcontainers.utility.DockerImageName dockerImageName) |
VaultContainer(java.lang.String dockerImageName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) |
SELF |
withInitCommand(java.lang.String... commands)
Run initialization commands using the vault cli.
|
SELF |
withLogLevel(VaultLogLevel level)
Sets the logging level for the Vault server in the container.
|
SELF |
withSecretInVault(java.lang.String path,
java.lang.String firstSecret,
java.lang.String... remainingSecrets)
Pre-loads secrets into Vault container.
|
SELF |
withVaultPort(int port)
Deprecated.
the exposed port will be randomized automatically. As calling this method provides no additional value, you are recommended to remove the call. getFirstMappedPort() may be used to obtain the listening vault port.
|
SELF |
withVaultToken(java.lang.String token)
Sets the Vault root token for the container so application tests can source secrets using the token
|
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindcopyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning@Deprecated public VaultContainer()
VaultContainer(DockerImageName) insteadpublic VaultContainer(java.lang.String dockerImageName)
public VaultContainer(org.testcontainers.utility.DockerImageName dockerImageName)
protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
containerIsStarted in class org.testcontainers.containers.GenericContainer<SELF extends VaultContainer<SELF>>public SELF withVaultToken(java.lang.String token)
token - the root token value to set for Vault.@Deprecated public SELF withVaultPort(int port)
port - the port number you want to have the Vault container listen on for tests.public SELF withLogLevel(VaultLogLevel level)
GenericContainer.withLogConsumer(Consumer).level - the logging level to set for Vault.public SELF withSecretInVault(java.lang.String path, java.lang.String firstSecret, java.lang.String... remainingSecrets)
The secrets are added to vault directly after the container is up via the
addSecrets, called from containerIsStarted
path - specific Vault path to store specified secretsfirstSecret - first secret to add to specifed pathremainingSecrets - var args list of secrets to add to specified pathpublic SELF withInitCommand(java.lang.String... commands)
.withInitCommand("secrets enable pki")
.withInitCommand("secrets enable transit")
commands - The commands to send to the vault cli