Class KeycloakContainer
java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<KeycloakContainer>
dasniko.testcontainers.keycloak.ExtendableKeycloakContainer<KeycloakContainer>
org.apache.polaris.test.commons.keycloak.KeycloakContainer
- All Implemented Interfaces:
AutoCloseable,KeycloakAccess,org.junit.rules.TestRule,org.testcontainers.containers.Container<KeycloakContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
public class KeycloakContainer
extends dasniko.testcontainers.keycloak.ExtendableKeycloakContainer<KeycloakContainer>
implements KeycloakAccess
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
Fields inherited from class dasniko.testcontainers.keycloak.ExtendableKeycloakContainer
ADMIN_CLI_CLIENT, LOG_WAIT_STRATEGY, MASTER_REALMFields 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_HEALTHYFields inherited from interface org.apache.polaris.test.commons.keycloak.KeycloakAccess
PRINCIPAL_NAME_CLAIM, USER_PASSWORD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassignRoleToUser(String role, String user) Assigns a role to a user in Keycloak.voidcreateRole(String roleName) Creates a new role in Keycloak with the specified name.voidcreateServiceAccount(String clientId, String clientSecret) Creates a new service account in Keycloak with the specified client ID and client secret.voidcreateUser(String name) Creates a new user in Keycloak.voiddeleteRole(String name) Deletes a role in Keycloak with the specified name.voiddeleteServiceAccount(String clientId) Deletes a service account in Keycloak with the specified client ID.voiddeleteUser(String name) Deletes a user in Keycloak with the specified name.Returns the URL of the Keycloak issuer.Returns the URL of the Keycloak token endpoint.voidstart()voidstop()Methods inherited from class dasniko.testcontainers.keycloak.ExtendableKeycloakContainer
configure, createKeycloakExtensionDeployment, createKeycloakExtensionProvider, disableLightweightAccessTokenForAdminCliClient, getAdminPassword, getAdminUsername, getAuthServerUrl, getContextPath, getDebugPort, getHttpMgmtPort, getHttpPort, getHttpsPort, getKeycloakAdminClient, getKeycloakDefaultVersion, getMgmtServerUrl, getProtocol, getStartupTimeout, resolveExtensionClassLocation, useMutualTls, useTls, useTls, useTlsKeystore, waitingFor, withAdminPassword, withAdminUsername, withBootstrapAdminDisabled, withCommand, withCommand, withContextPath, withCustomCommand, withDebug, withDebugFixedPort, withDefaultProviderClasses, withDisabledCaching, withEnabledMetrics, withFeaturesDisabled, withFeaturesEnabled, withHttpsClientAuth, withNightly, withOptimizedFlag, withProductionMode, withProviderClassesFrom, withProviderLibsFrom, withRamPercentage, withRealmImportFile, withRealmImportFiles, withStartupTimeout, withTrustedCertificates, withVerboseOutputMethods 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, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, starting, succeeded, toString, 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, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.apache.polaris.test.commons.keycloak.KeycloakAccess
getTokenPathMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Constructor Details
-
KeycloakContainer
public KeycloakContainer()
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
startin classorg.testcontainers.containers.GenericContainer<KeycloakContainer>
-
stop
public void stop()- Specified by:
stopin interfaceorg.testcontainers.lifecycle.Startable- Overrides:
stopin classorg.testcontainers.containers.GenericContainer<KeycloakContainer>
-
getIssuerUrl
Description copied from interface:KeycloakAccessReturns the URL of the Keycloak issuer. This is typicallyhttps://<keycloak-server>/realms/<realm-name>.- Specified by:
getIssuerUrlin interfaceKeycloakAccess
-
getTokenEndpoint
Description copied from interface:KeycloakAccessReturns the URL of the Keycloak token endpoint. This is typicallyhttps://<keycloak-server>/realms/<realm-name>/protocol/openid-connect/token.- Specified by:
getTokenEndpointin interfaceKeycloakAccess
-
createRole
Description copied from interface:KeycloakAccessCreates a new role in Keycloak with the specified name. The role should not have thePRINCIPAL_ROLE:prefix.- Specified by:
createRolein interfaceKeycloakAccess
-
createUser
Description copied from interface:KeycloakAccessCreates a new user in Keycloak. The password is always "s3cr3t"- Specified by:
createUserin interfaceKeycloakAccess
-
assignRoleToUser
Description copied from interface:KeycloakAccessAssigns a role to a user in Keycloak. The role should not have thePRINCIPAL_ROLE:prefix. Both the role and the user must exist.- Specified by:
assignRoleToUserin interfaceKeycloakAccess
-
createServiceAccount
Description copied from interface:KeycloakAccessCreates a new service account in Keycloak with the specified client ID and client secret.- Specified by:
createServiceAccountin interfaceKeycloakAccess
-
deleteRole
Description copied from interface:KeycloakAccessDeletes a role in Keycloak with the specified name. The role should not have thePRINCIPAL_ROLE:prefix.- Specified by:
deleteRolein interfaceKeycloakAccess
-
deleteUser
Description copied from interface:KeycloakAccessDeletes a user in Keycloak with the specified name.- Specified by:
deleteUserin interfaceKeycloakAccess
-
deleteServiceAccount
Description copied from interface:KeycloakAccessDeletes a service account in Keycloak with the specified client ID.- Specified by:
deleteServiceAccountin interfaceKeycloakAccess
-