Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.3 KB

File metadata and controls

26 lines (21 loc) · 1.3 KB

Nuget

Testcontainers module for Keycloak

A pre-configured testcontainers container for Keycloak.

Usage

In addition to the default container configuration, it is also possible to specify realms, clients and users that should be created before the container is considered started:

var client = new Client("demoapp", new("http://localhost:8000/*")) { Secret = "client_secret" };
var user = new User("john.doe", "password123");
var realmConfiguration = new RealmConfiguration("demorealm", new List<Client> { client }, new List<User> { user });
var keycloakConfiguration = new KeycloakTestcontainerConfiguration { Realms = new[] { realmConfiguration } };

await using var keycloak = new TestcontainersBuilder<KeycloakTestcontainer>()
    .WithKeycloak(keycloakConfiguration)
    .Build();

await keycloak.StartAsync();

After starting the container, additional realm information is available:

var realm = keycloak.Realms.Single();
var realmBaseAddress = realm.ServerRealm;
var oidcMetadat = realm.Metadata;