{"id":17697898,"url":"https://github.com/dasniko/testcontainers-keycloak","last_synced_at":"2026-03-13T02:39:15.571Z","repository":{"id":40362120,"uuid":"227774286","full_name":"dasniko/testcontainers-keycloak","owner":"dasniko","description":"A Testcontainer implementation for Keycloak IAM \u0026 SSO.","archived":false,"fork":false,"pushed_at":"2026-03-08T09:12:59.000Z","size":555,"stargazers_count":444,"open_issues_count":0,"forks_count":63,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-03-08T12:31:54.723Z","etag":null,"topics":["container","docker","iam","java","keycloak","oidc","sso","testcontainers","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dasniko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":"https://paypal.me/dasniko"}},"created_at":"2019-12-13T06:43:58.000Z","updated_at":"2026-03-08T09:13:02.000Z","dependencies_parsed_at":"2024-02-21T23:25:58.007Z","dependency_job_id":"1b753ac8-23bd-466d-8bf8-d4c1faedcc60","html_url":"https://github.com/dasniko/testcontainers-keycloak","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/dasniko/testcontainers-keycloak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasniko%2Ftestcontainers-keycloak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasniko%2Ftestcontainers-keycloak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasniko%2Ftestcontainers-keycloak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasniko%2Ftestcontainers-keycloak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dasniko","download_url":"https://codeload.github.com/dasniko/testcontainers-keycloak/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasniko%2Ftestcontainers-keycloak/sbom","scorecard":{"id":323879,"data":{"date":"2025-08-11","repo":{"name":"github.com/dasniko/testcontainers-keycloak","commit":"a4a7ba97ff7652325923c5f4af15651caa44c62e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/deploy-snapshot.yml:1","Warn: no topLevel permission defined: .github/workflows/maven.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy-snapshot.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/dasniko/testcontainers-keycloak/deploy-snapshot.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy-snapshot.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/dasniko/testcontainers-keycloak/deploy-snapshot.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/dasniko/testcontainers-keycloak/maven.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/dasniko/testcontainers-keycloak/maven.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/deploy-snapshot.yml:9"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'","Warn: branch protection not enabled for branch 'release/3.6'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 24 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T02:00:46.273Z","repository_id":40362120,"created_at":"2025-08-18T02:00:46.273Z","updated_at":"2025-08-18T02:00:46.273Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30456121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T02:22:12.178Z","status":"ssl_error","status_checked_at":"2026-03-13T02:06:49.475Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container","docker","iam","java","keycloak","oidc","sso","testcontainers","testing"],"created_at":"2024-10-24T15:00:52.464Z","updated_at":"2026-03-13T02:39:15.554Z","avatar_url":"https://github.com/dasniko.png","language":"Java","funding_links":["https://paypal.me/dasniko"],"categories":["Testcontainer implementation for Keycloak IAM \u0026 SSO","测试"],"sub_categories":[],"readme":"# Keycloak Testcontainer\n\nA [Testcontainers](https://www.testcontainers.org/) implementation for [Keycloak](https://www.keycloak.org/) SSO.\n\n[![GitHub Release](https://img.shields.io/github/v/release/dasniko/testcontainers-keycloak?label=Release)](https://github.com/dasniko/testcontainers-keycloak/releases)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.dasniko/testcontainers-keycloak.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.github.dasniko/testcontainers-keycloak)\n![GitHub Release Date](https://img.shields.io/github/release-date-pre/dasniko/testcontainers-keycloak)\n![Github Last Commit](https://img.shields.io/github/last-commit/dasniko/testcontainers-keycloak)\n![License](https://img.shields.io/github/license/dasniko/testcontainers-keycloak?label=License)\n\n[![Keycloak Version](https://img.shields.io/badge/Keycloak-26.5-blue)](https://www.keycloak.org)\n![Java Version](https://img.shields.io/badge/Java-11-f89820)\n[![GitHub Stars](https://img.shields.io/github/stars/dasniko/testcontainers-keycloak)](https://github.com/dasniko/testcontainers-keycloak/stargazers)\n[![CI build](https://github.com/dasniko/testcontainers-keycloak/actions/workflows/maven.yml/badge.svg)](https://github.com/dasniko/testcontainers-keycloak/actions/workflows/maven.yml)\n\n## IMPORTANT!!! VERSIONS!!!\n\n\u003e See [version overview](versions.md) for an overview which Keycloak release works with this library by default and which [Testcontainers](https://www.testcontainers.org/) version is used.  \n\u003e This library is, like Keycloak, only being developed in forward direction, there is no LTS, no backports, etc. available. So make sure to stay up to date.\n\n## How to use\n\n_The `@Container` annotation used here in the readme is from the JUnit 5 support of Testcontainers.\nPlease refer to the Testcontainers documentation for more information._\n\n### Default\n\nSimply spin up a default Keycloak instance:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer();\n```\n\n### Custom image\n\nUse another Keycloak Docker image/version than used in this Testcontainer:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer(\"quay.io/keycloak/keycloak:26.4\");\n```\n\n### Initial admin user credentials\n\nUse different admin credentials than the default internal (`admin`/`admin`) ones:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withAdminUsername(\"myKeycloakAdminUser\")\n    .withAdminPassword(\"tops3cr3t\");\n```\n\n### Realm Import\n\nPower up a Keycloak instance with one or more existing realm JSON config files (from classpath):\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withRealmImportFile(\"/test-realm.json\");\n```\nor\n```java\n    .withRealmImportFiles(\"/test-realm-1.json\", \"/test-realm-2.json\");\n```\n\nIf your realm JSON configuration file includes user definitions - particularly the admin user \nfor the master realm - ensure you disable the automatic bootstrapping of the admin user:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withBootstrapAdminDisabled()\n    .withRealmImportFile(\"/test-realm.json\");\n```\n\nTo retrieve a working Keycloak Admin Client from the container, make sure to override the admin \ncredentials to match those in your imported realm JSON configuration file:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withBootstrapAdminDisabled()\n    .withRealmImportFile(\"/test-realm.json\")\n    .withAdminUsername(\"myKeycloakAdminUser\")\n    .withAdminPassword(\"tops3cr3t\");\n```\n\n### Getting an admin client and other information from the testcontainer\n\nYou can get an instance of `org.keycloak.admin.Keycloak` admin client directly from the container, using\n\n```java\norg.keycloak.admin.Keycloak keycloakAdmin = keycloakContainer.getKeycloakAdminClient();\n```\nThe admin client is configured with current admin credentials.\n\n\u003e The `org.keycloak:keycloak-admin-client` package is now a transitive dependency of this project, ready to be used by you in your tests, no more need to add it on your own.\n\nYou can also obtain several properties from the Keycloak container:\n\n```java\nString authServerUrl = keycloak.getAuthServerUrl();\nString adminUsername = keycloak.getAdminUsername();\nString adminPassword = keycloak.getAdminPassword();\n```\n\nwith these properties, you can create e.g. a custom `org.keycloak.admin.client.Keycloak` object to connect to the container and do optional further configuration:\n\n```java\nKeycloak keycloakAdminClient = KeycloakBuilder.builder()\n    .serverUrl(keycloak.getAuthServerUrl())\n    .realm(KeycloakContainer.MASTER_REALM)\n    .clientId(KeycloakContainer.ADMIN_CLI_CLIENT)\n    .username(keycloak.getAdminUsername())\n    .password(keycloak.getAdminPassword())\n    .build();\n```\n\n### Context Path\n\nAs Keycloak comes with the default context path `/`, you can set your custom context path, e.g. for compatibility reasons to previous versions, with:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withContextPath(\"/auth\");\n```\n\n### Management Port\n\nStarting from Keycloak version 25.0.0, Keycloak will propagate `/health` and `/metrics` on \"Management Port\", see [Configuraing the Management Interface](https://www.keycloak.org/server/management-interface) and [Migration Guide](https://www.keycloak.org/docs/latest/upgrading/index.html#management-port-for-metrics-and-health-endpoints)\n\n```java\nKeycloakContainer keycloak = new KeycloakContainer().withEnabledMetrics()\nkeycloak.start();\nkeycloak.getMgmtServerUrl();\n```\n\n### Memory Settings\n\nAs of Keycloak 24 the container doesn't use an absolute amount of memory, but a relative percentage of the overall available memory to the container, [see also here](https://www.keycloak.org/server/containers#_specifying_different_memory_settings).\n\nThis testcontainer has an initial memory setting of\n\n    JAVA_OPTS_KC_HEAP=\"-XX:InitialRAMPercentage=1 -XX:MaxRAMPercentage=5\"\n\nto not overload your environment.\nYou can override this settng with the `withRamPercentage(initial, max)` method:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withRamPercentage(50, 70);\n```\n\n## TLS (SSL) Usage\n\nYou have three options to use HTTPS/TLS secured communication with your Keycloak Testcontainer.\n\n### Built-in TLS Keystore\n\nThis Keycloak Testcontainer comes with built-in TLS certificate (`tls.crt`), key (`tls.key`) and Java KeyStore (`tls.jks`) files, located in the `resources` folder.\nYou can use this configuration by only configuring your testcontainer like this:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer().useTls();\n```\n\nThe password for the provided Java KeyStore file is `changeit`.\nSee also [`KeycloakContainerHttpsTest.shouldStartKeycloakWithProvidedTlsKeystore`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerHttpsTest.java#L39).\n\nThe method `getAuthServerUrl()` will then return the HTTPS url.\n\n### Custom TLS Cert and Key\n\nOf course you can also provide your own certificate and key file for usage in this Testcontainer:\n\n```java\n@Container\nprivate KeycloakContainer keycloak = new KeycloakContainer()\n.useTls(\"your_custom.crt\", \"your_custom.key\");\n```\n\nSee also [`KeycloakContainerHttpsTest.shouldStartKeycloakWithCustomTlsCertAndKey`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerHttpsTest.java#L47).\n\nThe method getAuthServerUrl() will also return the HTTPS url.\n\n### Custom TLS Keystore\n\nLast but not least, you can also provide your own keystore file for usage in this Testcontainer:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .useTlsKeystore(\"your_custom.jks\", \"password_for_your_custom_keystore\");\n```\n\nSee also [`KeycloakContainerHttpsTest.shouldStartKeycloakWithCustomTlsKeystore`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerHttpsTest.java#L55).\n\nThe method `getAuthServerUrl()` will also return the HTTPS url.\n\n## Features\n\nYou can enable and disable features on your Testcontainer:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withFeaturesEnabled(\"docker\", \"scripts\", \"...\")\n    .withFeaturesDisabled(\"authorization\", \"impersonation\", \"...\");\n```\n\n## Custom CLI Config arguments\n\nAll default configurations in this Testcontainer is done through environment variables.\nYou can overwrite and/or add config settings on command-line-level (cli args) with this method:\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withCustomCommand(\"--hostname=keycloak.local\");\n```\n\nA warning will be printed to the log output when custom command parts are being used, so that you are aware that you are responsible on your own for proper execution of this container.\n\n## Starting in production mode\n\nBy default, the container is started in dev mode (`start-dev`).\nIf needed you can enable production mode: \n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withProductionMode();\n```\n\n### Optimized flag\n\nIt is possible that you use your own pre-build image with the `--optimized` flag.\nSetting this option will implicitly enable production mode!\n\n```java\n@Container\nKeycloakContainer keycloak = new KeycloakContainer(\"\u003cYOUR_IMAGE\u003e\" + \":\u003cYOUR_TAG\u003e\")\n    .withOptimizedFlag();\n```\n\nNOTE: If you don't enable the health endpoint, the container will not be healthy.\nIn this case please provide your own waitStrategy.\nCheck out the tests at [`KeycloakContainerOptimizedTest`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerOptimizedTest.java).\n\n## Testing Custom Extensions\n\nTo ease extension testing, you can tell the Keycloak Testcontainer to detect extensions in a given classpath folder.\nThis allows to test extensions directly in the same module without a packaging step.\n\nIf you have your Keycloak extension code in the `src/main/java` folder, then the resulting classes will be generated to the `target/classes` folder.\nTo test your extensions you just need to tell `KeycloakContainer` to consider extensions from the `target/classes` folder.\n\nKeycloak Testcontainer will then dynamically generate a packaged jar file with the extension code that is then picked up by Keycloak.\n\n```java\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withProviderClassesFrom(\"target/classes\");\n```\n\nFor your convenience, there's now (since 3.3) a default method, which yields to `target/classes` internally:\n\n```java\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withDefaultProviderClasses();\n```\n\nSee also [`KeycloakContainerExtensionTest`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerExtensionTest.java) class.\n\n### Dependencies \u0026 3rd-party Libraries\n\nIf you need to provide any 3rd-party dependency or library, you can do this with\n\n```java\nList\u003cFile\u003e libs = ...;\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withProviderLibsFrom(libs);\n```\n\nYou have to provide a list of resolvable `File`s.\n\n#### TIP\n\nIf you want/need to use dependencies from e.g., Maven (or Gradle), you can use [ShrinkWrap Resolvers](https://github.com/shrinkwrap/resolver).\nSee, as an example, how this is used at the [`KeycloakContainerExtensionTest#shouldDeployProviderWithDependencyAndCallCustomEndpoint()`](./src/test/java/dasniko/testcontainers/keycloak/KeycloakContainerExtensionTest.java) test.\n\n### Extending KeycloakContainer\n\nIn case you need a custom implementation of the default `KeycloakContainer`, you should inherit from `ExtendableKeycloakContainer`. This allows to set the generics and use your custom implementation without the need for type casts.  \n\n```java\npublic class MyCustomKeycloakContainer extends ExtendableKeycloakContainer\u003cMyCustomKeycloakContainer\u003e {\n  public MyCustomKeycloakContainer() {\n    super();\n  }\n  public MyCustomKeycloakContainer(String dockerImageName) {\n    super(dockerImageName);\n  }\n}\n\n...\n\nMyCustomKeycloakContainer keycloakContainer = new MyCustomKeycloakContainer()\n    .withAdminPassword(\"password\");\n```\n\n### Remote Debugger Support\n\nYou can tell the Keycloak Testcontainer to open a debug port for attaching a remote debugger.\n\nThis command will enable remote debugging in Keycloak and expose the used debug port in the container on a random port to the outside:\n\n```java\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withDebug();\n```\n\nIf you want to enable remote debugging on a fixed port and optionally have Keycloak wait (suspend) until a debugger has attached to this port, use this command:\n\n```java\nKeycloakContainer keycloak = new KeycloakContainer()\n    .withDebugFixedPort(int hostPort, boolean suspend);\n```\n\n## Setup\n\nThe release versions of this project are available at [Maven Central](https://central.sonatype.com/artifact/com.github.dasniko/testcontainers-keycloak).\nSimply put the dependency coordinates to your `pom.xml` (or something similar, if you use e.g. Gradle or something else):\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.dasniko\u003c/groupId\u003e\n  \u003cartifactId\u003etestcontainers-keycloak\u003c/artifactId\u003e\n  \u003cversion\u003eVERSION\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\nFor a version overview, see [here](versions.md).\n\n\u003e There is also a `999.0.0-SNAPSHOT` version available, pointing to `nightly` Docker image by default and using the `999.0.0-SNAPSHOT` Keycloak libraries as dependencies.\n\n## Usage in your application framework tests\n\n\u003e This info is not specific to the Keycloak Testcontainer, but using Testcontainers in general.\n\nI mention it here, as I see people asking again and again on how to use it in their test setup, when they think they need to specify a fixed port in their properties or YAML files...  \nYou don't have to!  \nBut you have to read the Testcontainers docs and the docs of your application framework on testing resources!!\n\n### Spring (Boot)\n\nDynamic context configuration with context initializers is your friend.\nIn particular, look for `@ContextConfiguration` and `ApplicationContextInitializer\u003cConfigurableApplicationContext\u003e`:\n* https://docs.spring.io/spring-framework/docs/current/reference/html/testing.html#spring-testing-annotation-contextconfiguration\n* https://docs.spring.io/spring-framework/docs/current/reference/html/testing.html#testcontext-ctx-management-initializers\n\n### Quarkus\n\nRead the docs about the Quarkus Test Resources and use `@QuarkusTestResource` with `QuarkusTestResourceLifecycleManager`\n* https://quarkus.io/guides/getting-started-testing#quarkus-test-resource\n\n### Others\n\nConsult the docs of your application framework testing capabilities on how to dynamically configure your stack for testing!\n\n## YouTube Videos about Keycloak Testcontainers\n\n| [![](http://img.youtube.com/vi/FEbIW23RoXk/maxresdefault.jpg)](http://www.youtube.com/watch?v=FEbIW23RoXk \"\")  | [![](http://img.youtube.com/vi/l2Lk2Z9mHBs/maxresdefault.jpg)](http://www.youtube.com/watch?v=l2Lk2Z9mHBs \"\") |\n|---|---|\n| [![](http://img.youtube.com/vi/lBC51XZUM90/maxresdefault.jpg)](https://www.youtube.com/watch?v=lBC51XZUM90 \"\") |\n\n## Credits\n\nMany thanks to the creators and maintainers of [Testcontainers](https://www.testcontainers.org/).\nYou do an awesome job!\n\nSame goes to the whole [Keycloak](https://www.keycloak.org/) team!\n\nKudos to [@thomasdarimont](https://github.com/thomasdarimont) for some inspiration for this project.\n\n## License\n\nApache License 2.0\n\nCopyright (c) 2019-2025 Niko Köbler\n\nSee [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasniko%2Ftestcontainers-keycloak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdasniko%2Ftestcontainers-keycloak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasniko%2Ftestcontainers-keycloak/lists"}