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

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a KeycloakContainer with default image and version tag
    Create a KeycloakContainer by passing the full docker image name
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
    createKeycloakExtensionDeployment(String deploymentLocation, String extensionName, String extensionClassFolder)
    Maps the provided extensionClassFolder as an exploded extension.jar to the deploymentLocation.
    void
    Maps the provided extensionClassFolder as an exploded providers.jar to the Keycloak providers folder.
     
     
     
     
    int
     
    int
     
    org.keycloak.admin.client.Keycloak
     
     
     
    protected String
    resolveExtensionClassLocation(String extensionClassFolder)
     
    useMutualTls(String tlsTruststoreFilename, String tlsTruststorePassword, HttpsClientAuth httpsClientAuth)
     
     
    useTls(String tlsCertificateFilename, String tlsCertificateKeyFilename)
     
    useTlsKeystore(String tlsKeystoreFilename, String tlsKeystorePassword)
     
    withAdminPassword(String adminPassword)
     
    withAdminUsername(String adminUsername)
     
     
    withCommand(String... commandParts)
     
    withContextPath(String contextPath)
     
     
     
     
     
    Exposes the given classes location as an exploded providers.jar.
     
     
     
    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, withWorkingDirectory

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Field Details

  • Constructor Details

    • ExtendableKeycloakContainer

      public ExtendableKeycloakContainer()
      Create a KeycloakContainer with default image and version tag
    • ExtendableKeycloakContainer

      public ExtendableKeycloakContainer(String dockerImageName)
      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:
      configure in class org.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
    • withCommand

      public SELF withCommand(String cmd)
      Specified by:
      withCommand in interface org.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>
      Overrides:
      withCommand in class org.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
    • withCommand

      public SELF withCommand(String... commandParts)
      Specified by:
      withCommand in interface org.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>
      Overrides:
      withCommand in class org.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
    • createKeycloakExtensionProvider

      public void createKeycloakExtensionProvider(String extensionClassFolder)
      Maps the provided extensionClassFolder as 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 provided extensionClassFolder as an exploded extension.jar to the deploymentLocation.
      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

      protected String resolveExtensionClassLocation(String extensionClassFolder)
    • withRealmImportFile

      public SELF withRealmImportFile(String importFile)
    • withRealmImportFiles

      public SELF withRealmImportFiles(String... files)
    • withAdminUsername

      public SELF withAdminUsername(String adminUsername)
    • withAdminPassword

      public SELF withAdminPassword(String adminPassword)
    • withContextPath

      public SELF withContextPath(String contextPath)
    • withProviderClassesFrom

      public SELF withProviderClassesFrom(String classesLocation)
      Exposes the given classes location as an exploded providers.jar.
      Parameters:
      classesLocation - a classes location relative to the current classpath root.
    • withProviderLibsFrom

      public SELF withProviderLibsFrom(List<File> libs)
    • withStartupTimeout

      public SELF withStartupTimeout(Duration startupTimeout)
      Specified by:
      withStartupTimeout in interface org.testcontainers.containers.Container<SELF extends ExtendableKeycloakContainer<SELF>>
      Overrides:
      withStartupTimeout in class org.testcontainers.containers.GenericContainer<SELF extends ExtendableKeycloakContainer<SELF>>
    • useTls

      public SELF useTls()
    • useTls

      public SELF useTls(String tlsCertificateFilename, String tlsCertificateKeyFilename)
    • useTlsKeystore

      public SELF useTlsKeystore(String tlsKeystoreFilename, String tlsKeystorePassword)
    • useMutualTls

      public SELF useMutualTls(String tlsTruststoreFilename, String tlsTruststorePassword, HttpsClientAuth httpsClientAuth)
    • withFeaturesEnabled

      public SELF withFeaturesEnabled(String... features)
    • withFeaturesDisabled

      public SELF withFeaturesDisabled(String... features)
    • withDisabledCaching

      public SELF withDisabledCaching()
    • withEnabledMetrics

      public SELF withEnabledMetrics()
    • getKeycloakAdminClient

      public org.keycloak.admin.client.Keycloak getKeycloakAdminClient()
    • getAuthServerUrl

      public String getAuthServerUrl()
    • getAdminUsername

      public String getAdminUsername()
    • getAdminPassword

      public String getAdminPassword()
    • getHttpPort

      public int getHttpPort()
    • getHttpsPort

      public int getHttpsPort()
    • getContextPath

      public String getContextPath()
    • getStartupTimeout

      public Duration getStartupTimeout()
    • getKeycloakDefaultVersion

      public String getKeycloakDefaultVersion()