skipcheck

TM1 Testcontainers · Docs · Containers

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 staticThe Keycloak image.
IMAGE staticOverrides the Keycloak image, e.g.
HTTP_PORT staticKeycloak's HTTP port inside the container.
NETWORK_ALIAS staticThe container's name on its Docker network.
REALM staticThe realm cognos-server builds from its test users.
APP_CLIENT staticThe realm's client for applications.
KeycloakContainer constructorKeycloak on the default image (or KEYCLOAK_IMAGE), in development mode.
KeycloakContainer constructorKeycloak on image.
getNetworkUrlKeycloak as other containers on its network reach it.
getUrlKeycloak as seen from the host, e.g.
idTokenA user's ID token from the realm's tm1-app client, by the password grant.

DEFAULT_IMAGE

static
DockerImageName DEFAULT_IMAGE

The Keycloak image.

IMAGE

static
String IMAGE

Overrides the Keycloak image, e.g. another version. Read as a system property, then an environment variable.

HTTP_PORT

static
int HTTP_PORT

Keycloak's HTTP port inside the container.

NETWORK_ALIAS

static
String NETWORK_ALIAS

The container's name on its Docker network.

REALM

static
String REALM

The realm cognos-server builds from its test users.

APP_CLIENT

static
String APP_CLIENT

The realm's client for applications: public, and its tokens include Cognos's client in their audience, which Cognos requires.

KeycloakContainer

constructor
KeycloakContainer()

Keycloak on the default image (or KEYCLOAK_IMAGE), in development mode.

KeycloakContainer

constructor
KeycloakContainer(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.