skipcheck

TM1 Testcontainers · Docs · Containers

KeycloakContainer

using Skipcheck.Tm1.Testcontainers;

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 (IdTokenAsync). The interactive (browser) logon would need a browser that reaches that network address, so it isn't wrapped here.

Members

DefaultImage staticThe image Keycloak runs in.
Image staticThe setting that replaces DefaultImage.
HttpPort staticKeycloak's HTTP port.
NetworkAlias staticIts name on the network.
Realm staticThe realm the Cognos users are in.
AppClient staticThe client an app gets ID tokens with.
KeycloakContainer constructorKeycloak in DefaultImage, or KEYCLOAK_IMAGE if set.
KeycloakContainer constructorKeycloak in image.
NetworkUrl propertyKeycloak's address on its network, as Cognos and TM1 reach it.
Url propertyKeycloak's address on the Docker host.
IdTokenAsyncAn ID token for a test user, by the password grant of AppClient.
DockerImageName propertyThe image it runs.
EnvMap propertyIts environment variables, so far.
CommandParts propertyThe command it runs, if not the image's.
ExposedPorts propertyThe ports it exposes on the Docker host.
Network propertyThe network it joins, or null for Docker's default bridge.
NetworkAliases propertyIts names on Network.
Dependencies propertyWhat starts before it.
Container propertyThe started container.
IsRunning property
Host propertyThe host its ports are mapped on.
ContainerId propertyThe Docker container's ID.
GetMappedPortThe host port port is mapped to.
WithEnvSets an environment variable.
WithEnvSets environment variables.
WithCommandRuns commandParts in place of the image's command.
WithExposedPortsExposes ports on the Docker host, each on a free port.
WithNetworkJoins network (created when the first container on it starts).
WithNetworkAliasesAdds names it's reached by on Network.
DependsOnStarts startables before it.
WithExtraHostAdds an /etc/hosts entry.
WithReuseKeeps the container for later runs, when reuse is switched on as Testcontainers for Java has it (testcontainers.reuse.enable=true in ~/.testcontainers.properties, or TESTCONTAINERS_REUSE_ENABLE=true); otherwise it's removed after the run.
WithCopyFileToContainerCopies a host file or folder into the container before it starts.
WithStartupTimeoutHow long to wait for it to be ready.
StartAsync
StopAsync
DisposeAsyncStops it.
GetLogsAsyncIts log, so far.

DefaultImage

static
const string DefaultImage

The image Keycloak runs in.

Image

static
const string Image

The setting that replaces DefaultImage.

HttpPort

static
const int HttpPort

Keycloak's HTTP port.

NetworkAlias

static
const string NetworkAlias

Its name on the network.

Realm

static
const string Realm

The realm the Cognos users are in.

AppClient

static
const string AppClient

The client an app gets ID tokens with.

KeycloakContainer

constructor
KeycloakContainer()

Keycloak in DefaultImage, or KEYCLOAK_IMAGE if set.

KeycloakContainer

constructor
KeycloakContainer(string image)

Keycloak in image.

NetworkUrl

property
string NetworkUrl

Keycloak's address on its network, as Cognos and TM1 reach it.

Url

property
string Url

Keycloak's address on the Docker host.

IdTokenAsync

Task<string> IdTokenAsync(string user, string password, CancellationToken cancellationToken = default)

An ID token for a test user, by the password grant of AppClient.

Throws

InvalidOperationException
Keycloak refused.

DockerImageName

property
string DockerImageName

The image it runs.

EnvMap

property
IReadOnlyDictionary<string, string> EnvMap

Its environment variables, so far.

CommandParts

property
IReadOnlyList<string> CommandParts

The command it runs, if not the image's.

ExposedPorts

property
IReadOnlyList<int> ExposedPorts

The ports it exposes on the Docker host.

Network

property
Network? Network

The network it joins, or null for Docker's default bridge.

NetworkAliases

property
IReadOnlyList<string> NetworkAliases

Its names on Network.

Dependencies

property
IReadOnlyCollection<IStartable> Dependencies

What starts before it.

Container

property
IContainer Container

The started container.

Throws

InvalidOperationException
It isn't started.

IsRunning

property
bool IsRunning

Host

property
string Host

The host its ports are mapped on.

ContainerId

property
string ContainerId

The Docker container's ID.

GetMappedPort

int GetMappedPort(int port)

The host port port is mapped to.

WithEnv

TSelf WithEnv(string name, string value)

Sets an environment variable.

WithEnv

TSelf WithEnv(IReadOnlyDictionary<string, string> variables)

Sets environment variables.

WithCommand

TSelf WithCommand(params string[] commandParts)

Runs commandParts in place of the image's command.

WithExposedPorts

TSelf WithExposedPorts(params int[] exposedPorts)

Exposes ports on the Docker host, each on a free port.

WithNetwork

TSelf WithNetwork(Network? network)

Joins network (created when the first container on it starts).

WithNetworkAliases

TSelf WithNetworkAliases(params string[] networkAliases)

Adds names it's reached by on Network.

DependsOn

TSelf DependsOn(params IStartable[] startables)

Starts startables before it.

WithExtraHost

TSelf WithExtraHost(string host, string ipAddress)

Adds an /etc/hosts entry.

WithReuse

TSelf WithReuse(bool reusable)

Keeps the container for later runs, when reuse is switched on as Testcontainers for Java has it (testcontainers.reuse.enable=true in ~/.testcontainers.properties, or TESTCONTAINERS_REUSE_ENABLE=true); otherwise it's removed after the run.

WithCopyFileToContainer

TSelf WithCopyFileToContainer(string hostPath, string containerPath)

Copies a host file or folder into the container before it starts.

WithStartupTimeout

TSelf WithStartupTimeout(TimeSpan timeout)

How long to wait for it to be ready.

StartAsync

Task StartAsync(CancellationToken cancellationToken = default)

StopAsync

Task StopAsync(CancellationToken cancellationToken = default)

DisposeAsync

ValueTask DisposeAsync()

Stops it.

GetLogsAsync

Task<string> GetLogsAsync(CancellationToken cancellationToken = default)

Its log, so far.