Package org.testcontainers.vault
Class VaultContainer<SELF extends VaultContainer<SELF>>
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<SELF>
org.testcontainers.vault.VaultContainer<SELF>
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<SELF>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public class VaultContainer<SELF extends VaultContainer<SELF>>
extends org.testcontainers.containers.GenericContainer<SELF>
Testcontainers implementation for Vault.
Supported image: hashicorp/vault, vault
Exposure ports: 8200
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
Fields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.VaultContainer(String dockerImageName) VaultContainer(org.testcontainers.utility.DockerImageName dockerImageName) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcontainerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) withInitCommand(String... commands) Run initialization commands using the vault cli.withLogLevel(VaultLogLevel level) Deprecated.useGenericContainer.withEnv(String, String)insteadwithSecretInVault(String path, String firstSecret, String... remainingSecrets) Deprecated.usewithInitCommand(String...)insteadwithVaultPort(int port) Deprecated.the exposed port will be randomized automatically.withVaultToken(String token) Sets the Vault root token for the container so application tests can source secrets using the tokenMethods inherited from class org.testcontainers.containers.GenericContainer
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, setContainerDef, 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, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods inherited from interface org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Constructor Details
-
VaultContainer
Deprecated.useVaultContainer(DockerImageName)instead -
VaultContainer
-
VaultContainer
public VaultContainer(org.testcontainers.utility.DockerImageName dockerImageName)
-
-
Method Details
-
getHttpHostAddress
-
containerIsStarted
protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) - Overrides:
containerIsStartedin classorg.testcontainers.containers.GenericContainer<SELF extends VaultContainer<SELF>>
-
withVaultToken
Sets the Vault root token for the container so application tests can source secrets using the token- Parameters:
token- the root token value to set for Vault.- Returns:
- this
-
withVaultPort
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.Sets the Vault port in the container as well as the port bindings for the host to reach the container over HTTP.- Parameters:
port- the port number you want to have the Vault container listen on for tests.- Returns:
- this
-
withLogLevel
Deprecated.useGenericContainer.withEnv(String, String)insteadSets the logging level for the Vault server in the container. Logs can be consumed throughGenericContainer.withLogConsumer(Consumer).- Parameters:
level- the logging level to set for Vault.- Returns:
- this
-
withSecretInVault
@Deprecated public SELF withSecretInVault(String path, String firstSecret, String... remainingSecrets) Deprecated.usewithInitCommand(String...)insteadPre-loads secrets into Vault container. User may specify one or more secrets and all will be added to each path that is specified. Thus this can be called more than once for multiple paths to be added to Vault.The secrets are added to vault directly after the container is up via the
addSecrets, called fromcontainerIsStarted- Parameters:
path- specific Vault path to store specified secretsfirstSecret- first secret to add to specified pathremainingSecrets- var args list of secrets to add to specified path- Returns:
- this
-
withInitCommand
Run initialization commands using the vault cli.Useful for enabling more secret engines like:
.withInitCommand("secrets enable pki") .withInitCommand("secrets enable transit")- Parameters:
commands- The commands to send to the vault cli- Returns:
- this
-
VaultContainer(DockerImageName)instead