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 static | The image Keycloak runs in. |
Image static | The setting that replaces DefaultImage. |
HttpPort static | Keycloak's HTTP port. |
NetworkAlias static | Its name on the network. |
Realm static | The realm the Cognos users are in. |
AppClient static | The client an app gets ID tokens with. |
KeycloakContainer constructor | Keycloak in DefaultImage, or KEYCLOAK_IMAGE if set. |
KeycloakContainer constructor | Keycloak in image. |
NetworkUrl property | Keycloak's address on its network, as Cognos and TM1 reach it. |
Url property | Keycloak's address on the Docker host. |
IdTokenAsync | An ID token for a test user, by the password grant of AppClient. |
DockerImageName property | The image it runs. |
EnvMap property | Its environment variables, so far. |
CommandParts property | The command it runs, if not the image's. |
ExposedPorts property | The ports it exposes on the Docker host. |
Network property | The network it joins, or null for Docker's default bridge. |
NetworkAliases property | Its names on Network. |
Dependencies property | What starts before it. |
Container property | The started container. |
IsRunning property | |
Host property | The host its ports are mapped on. |
ContainerId property | The Docker container's ID. |
GetMappedPort | The host port port is mapped to. |
WithEnv | Sets an environment variable. |
WithEnv | Sets environment variables. |
WithCommand | Runs commandParts in place of the image's command. |
WithExposedPorts | Exposes ports on the Docker host, each on a free port. |
WithNetwork | Joins network (created when the first container on it starts). |
WithNetworkAliases | Adds names it's reached by on Network. |
DependsOn | Starts startables before it. |
WithExtraHost | Adds an /etc/hosts entry. |
WithReuse | 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 | Copies a host file or folder into the container before it starts. |
WithStartupTimeout | How long to wait for it to be ready. |
StartAsync | |
StopAsync | |
DisposeAsync | Stops it. |
GetLogsAsync | Its log, so far. |
DefaultImage
staticconst string DefaultImageThe image Keycloak runs in.
Image
staticconst string ImageThe setting that replaces DefaultImage.
HttpPort
staticconst int HttpPortKeycloak's HTTP port.
NetworkAlias
staticconst string NetworkAliasIts name on the network.
Realm
staticconst string RealmThe realm the Cognos users are in.
AppClient
staticconst string AppClientThe client an app gets ID tokens with.
KeycloakContainer
constructorKeycloakContainer()Keycloak in DefaultImage, or KEYCLOAK_IMAGE if set.
KeycloakContainer
constructorKeycloakContainer(string image)Keycloak in image.
NetworkUrl
propertystring NetworkUrlKeycloak's address on its network, as Cognos and TM1 reach it.
Url
propertystring UrlKeycloak'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
propertystring DockerImageNameThe image it runs.
EnvMap
propertyIReadOnlyDictionary<string, string> EnvMapIts environment variables, so far.
CommandParts
propertyIReadOnlyList<string> CommandPartsThe command it runs, if not the image's.
ExposedPorts
propertyIReadOnlyList<int> ExposedPortsThe ports it exposes on the Docker host.
Network
propertyNetwork? NetworkThe network it joins, or null for Docker's default bridge.
NetworkAliases
propertyIReadOnlyList<string> NetworkAliasesIts names on Network.
Dependencies
propertyIReadOnlyCollection<IStartable> DependenciesWhat starts before it.
Container
propertyIContainer ContainerThe started container.
Throws
InvalidOperationException- It isn't started.
IsRunning
propertybool IsRunningHost
propertystring HostThe host its ports are mapped on.
ContainerId
propertystring ContainerIdThe 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.