Skip to content

Commit 111bd09

Browse files
sebasszSebastian Scholz
andauthored
fix(keycloak): realm import (#584)
With the option to import keycloak realms, introduced with #565, the[_configure()](https://github.com/testcontainers/testcontainers-python/blob/78b6f0ecb15e8cba687eb4588c5ce19ca32208bc/modules/keycloak/testcontainers/keycloak/__init__.py#L57) method is called twice. Once it is called in the [start()](https://github.com/testcontainers/testcontainers-python/blob/78b6f0ecb15e8cba687eb4588c5ce19ca32208bc/modules/keycloak/testcontainers/keycloak/__init__.py#L83) method of keycloak itself and then it is called a second time in the [start()](https://github.com/testcontainers/testcontainers-python/blob/78b6f0ecb15e8cba687eb4588c5ce19ca32208bc/core/testcontainers/core/container.py#L90) method of DockerContainer. This wasn't an issue so far. But if a realm shall be imported (self.has_realm_import in keycloak is True), then every time the string " --import-realm" is added to the start command in the _configure() method. The keycloak container won't start if "--import-realm" is specified multiple times. This is probably the easiest solution to solve the issue. If wished, I can also work on a more robust solution, e.g. by storing the start command in a list and checking that "--import-realm" is only added once. Co-authored-by: Sebastian Scholz <[email protected]>
1 parent 78b6f0e commit 111bd09

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

modules/keycloak/testcontainers/keycloak/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def _readiness_probe(self) -> None:
8080
wait_for_logs(self, "Added user .* to realm .*")
8181

8282
def start(self) -> "KeycloakContainer":
83-
self._configure()
8483
super().start()
8584
self._readiness_probe()
8685
return self

0 commit comments

Comments
 (0)