Package dasniko.testcontainers.keycloak
Class ExtendableKeycloakContainer<SELF extends ExtendableKeycloakContainer<SELF>>
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<SELF>
dasniko.testcontainers.keycloak.ExtendableKeycloakContainer<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
- Direct Known Subclasses:
KeycloakContainer
public abstract class ExtendableKeycloakContainer<SELF extends ExtendableKeycloakContainer<SELF>>
extends org.testcontainers.containers.GenericContainer<SELF>
- Author:
- Niko Köbler, https://www.n-k.de, @dasniko
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionCreate a KeycloakContainer with default image and version tagExtendableKeycloakContainer(String dockerImageName) Create a KeycloakContainer by passing the full docker image name -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidcreateKeycloakExtensionDeployment(String deploymentLocation, String extensionName, String extensionClassFolder) Maps the providedextensionClassFolderas an exploded extension.jar to thedeploymentLocation.voidcreateKeycloakExtensionProvider(String extensionClassFolder) Maps the providedextensionClassFolderas an exploded providers.jar to the Keycloak providers folder.intintorg.keycloak.admin.client.Keycloakprotected StringresolveExtensionClassLocation(String extensionClassFolder) useMutualTls(String tlsTruststoreFilename, String tlsTruststorePassword, HttpsClientAuth httpsClientAuth) useTls()useTlsKeystore(String tlsKeystoreFilename, String tlsKeystorePassword) withAdminPassword(String adminPassword) withAdminUsername(String adminUsername) withCommand(String cmd) withCommand(String... commandParts) withContextPath(String contextPath) withFeaturesDisabled(String... features) withFeaturesEnabled(String... features) withProviderClassesFrom(String classesLocation) Exposes the given classes location as an exploded providers.jar.withProviderLibsFrom(List<File> libs) withRealmImportFile(String importFile) withRealmImportFiles(String... files) withStartupTimeout(Duration startupTimeout) Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, containerIsCreated, containerIsStarted, 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, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, 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, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Field Details
-
MASTER_REALM
- See Also:
-
ADMIN_CLI_CLIENT
- See Also:
-
-
Constructor Details
-
ExtendableKeycloakContainer
public ExtendableKeycloakContainer()Create a KeycloakContainer with default image and version tag -
ExtendableKeycloakContainer
Create a KeycloakContainer by passing the full docker image name- Parameters:
dockerImageName- Full docker image name, e.g. quay.io/keycloak/keycloak:22.0
-
-
Method Details
-
configure
protected void configure()- Overrides:
configurein classorg.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
-
withCommand
- Specified by:
withCommandin interfaceorg.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>- Overrides:
withCommandin classorg.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
-
withCommand
- Specified by:
withCommandin interfaceorg.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>- Overrides:
withCommandin classorg.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
-
createKeycloakExtensionProvider
Maps the providedextensionClassFolderas an exploded providers.jar to the Keycloak providers folder.- Parameters:
extensionClassFolder- a path relative to the current classpath root.
-
createKeycloakExtensionDeployment
protected void createKeycloakExtensionDeployment(String deploymentLocation, String extensionName, String extensionClassFolder) Maps the providedextensionClassFolderas an exploded extension.jar to thedeploymentLocation.- Parameters:
deploymentLocation- the target deployments location of the Keycloak server.extensionName- the name suffix of the created extension.extensionClassFolder- a path relative to the current classpath root.
-
resolveExtensionClassLocation
-
withRealmImportFile
-
withRealmImportFiles
-
withAdminUsername
-
withAdminPassword
-
withContextPath
-
withProviderClassesFrom
Exposes the given classes location as an exploded providers.jar.- Parameters:
classesLocation- a classes location relative to the current classpath root.
-
withProviderLibsFrom
-
withStartupTimeout
- Specified by:
withStartupTimeoutin interfaceorg.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>- Overrides:
withStartupTimeoutin classorg.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
-
useTls
-
useTls
-
useTlsKeystore
-
useMutualTls
public SELF useMutualTls(String tlsTruststoreFilename, String tlsTruststorePassword, HttpsClientAuth httpsClientAuth) -
withFeaturesEnabled
-
withFeaturesDisabled
-
withDisabledCaching
-
withEnabledMetrics
-
getKeycloakAdminClient
public org.keycloak.admin.client.Keycloak getKeycloakAdminClient() -
getAuthServerUrl
-
getAdminUsername
-
getAdminPassword
-
getHttpPort
public int getHttpPort() -
getHttpsPort
public int getHttpsPort() -
getContextPath
-
getStartupTimeout
-
getKeycloakDefaultVersion
-