Skip to content

Commit

Permalink
fix(keycloak): realm import (#584)
Browse files Browse the repository at this point in the history
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 <sebastian.scholz@cemocom.de>
  • Loading branch information
sebassz and Sebastian Scholz authored May 27, 2024
1 parent 78b6f0e commit 111bd09
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion modules/keycloak/testcontainers/keycloak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def _readiness_probe(self) -> None:
wait_for_logs(self, "Added user .* to realm .*")

def start(self) -> "KeycloakContainer":
self._configure()
super().start()
self._readiness_probe()
return self
Expand Down

0 comments on commit 111bd09

Please sign in to comment.