Package org.apache.polaris.test.keycloak
Class KeycloakContainer
java.lang.Object
org.testcontainers.containers.GenericContainer<KeycloakContainer>
org.apache.polaris.test.keycloak.KeycloakContainer
- All Implemented Interfaces:
AutoCloseable,KeycloakAccess,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 org.testcontainers.containers.GenericContainer<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 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.keycloak.KeycloakAccess
PRINCIPAL_NAME_CLAIM -
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, String password) 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.Obtains an access token from the Keycloak server.Returns the URL of the Keycloak token endpoint.voidstart()voidstop()Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, 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, 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.apache.polaris.test.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.- Specified by:
createRolein interfaceKeycloakAccess
-
createUser
Description copied from interface:KeycloakAccessCreates a new user in Keycloak.- Specified by:
createUserin interfaceKeycloakAccess
-
assignRoleToUser
Description copied from interface:KeycloakAccessAssigns a role to a user in Keycloak. 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.- 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
-
getToken
Description copied from interface:KeycloakAccessObtains an access token from the Keycloak server. The passed map becomes the POST request body and should contain the grant type and all required parameters.- Specified by:
getTokenin interfaceKeycloakAccess
-