KeycloakContainer
import io.skipcheck.tm1.testcontainers.KeycloakContainer; Keycloak in Docker, as the OpenID Connect provider for a CognosContainer's OIDC
namespace (CognosContainer.withKeycloak). Cognos builds a realm in it from its
test users when it starts.
Its issuer is its address on the shared Docker network, http://keycloak:8080,
whichever way it's reached, so Cognos accepts tokens that tests get through the
host-side port (idToken). The interactive (browser) logon would need a browser
that reaches that network address, so it isn't wrapped here.
Members
DEFAULT_IMAGE static | The Keycloak image. |
IMAGE static | Overrides the Keycloak image, e.g. |
HTTP_PORT static | Keycloak's HTTP port inside the container. |
NETWORK_ALIAS static | The container's name on its Docker network. |
REALM static | The realm cognos-server builds from its test users. |
APP_CLIENT static | The realm's client for applications. |
KeycloakContainer constructor | Keycloak on the default image (or KEYCLOAK_IMAGE), in development mode. |
KeycloakContainer constructor | Keycloak on image. |
getNetworkUrl | Keycloak as other containers on its network reach it. |
getUrl | Keycloak as seen from the host, e.g. |
idToken | A user's ID token from the realm's tm1-app client, by the password grant. |
DEFAULT_IMAGE
staticDockerImageName DEFAULT_IMAGEThe Keycloak image.
IMAGE
staticString IMAGEOverrides the Keycloak image, e.g. another version. Read as a system property, then an environment variable.
HTTP_PORT
staticint HTTP_PORTKeycloak's HTTP port inside the container.
NETWORK_ALIAS
staticString NETWORK_ALIASThe container's name on its Docker network.
REALM
staticString REALMThe realm cognos-server builds from its test users.
APP_CLIENT
staticString APP_CLIENTThe realm's client for applications: public, and its tokens include Cognos's client in their audience, which Cognos requires.
KeycloakContainer
constructorKeycloakContainer()Keycloak on the default image (or KEYCLOAK_IMAGE), in development mode.
KeycloakContainer
constructorKeycloakContainer(DockerImageName image) Keycloak on image.
Parameters
image- a Keycloak image, version 25 or later
getNetworkUrl
String getNetworkUrl() Keycloak as other containers on its network reach it: http://keycloak:8080.
Also its issuer's base.
Returns
- the in-network URL, without a trailing slash
getUrl
String getUrl() Keycloak as seen from the host, e.g. http://localhost:54321. Its admin
console logs on as admin / admin.
Returns
- the URL, without a trailing slash
idToken
String idToken(String user, String password) A user's ID token from the realm's tm1-app client, by the password
grant: what an application that has logged a user on would hold. Cognos logs that
user on with it (CognosContainer.passport).
Parameters
user- a test user's name
password- the password
Returns
- the ID token (a JWT)
Throws
IllegalStateException- if Keycloak refuses the logon
Also in the Javadoc.