Skip to content

fix(keycloak): add realm imports - #565

Merged
alexanderankin merged 4 commits into
testcontainers:mainfrom
stefnnn:keycloak-import-realms
May 11, 2024
Merged

fix(keycloak): add realm imports#565
alexanderankin merged 4 commits into
testcontainers:mainfrom
stefnnn:keycloak-import-realms

Conversation

@stefnnn

Copy link
Copy Markdown
Contributor

This PR adds an option to start a keycloak container with importing one or more realms. This mirrors a feature present in the java keycloak testcontainer.

@alexanderankinalexanderankin changed the title feat(keycloak) add realm importsfeat(keycloak): add realm importsMay 8, 2024
@alexanderankin

Copy link
Copy Markdown
Member

if you can make it backwards compatible (ie not break tests) then i dont see why we wouldnt merge

@stefnnn

Copy link
Copy Markdown
ContributorAuthor

My bad! I have fixed a bug I introduced, that prevented to wait for the first user to be added. Additionally I made the cmd configurable, which I think make sense, depending on the use caes.

However, I cannot get the tests running locally, neither on this branch nor on main, so I have a hard time verify whether it works consitently now.

@alexanderankinalexanderankin changed the title feat(keycloak): add realm importsfix(keycloak): add realm importsMay 9, 2024
@alexanderankinalexanderankin added the 👥 community feat feature but its a community module so we wont bump tc core for it label May 9, 2024
@alexanderankin

Copy link
Copy Markdown
Member

so it seems straightforward enough, so lgtm!

also idk if you accounted for this but the command can be a list or a string. since backwards (or anything beyond basic) compatibility is really not a top concern for community modules, im going to merge this, but feel free to follow up before we do a release. not sure how soon that will be since im pretty backlogged and i dont think we have anything to release that is super critical (happy to be corrected about this).

@alexanderankin
alexanderankin merged commit f761b98 into testcontainers:mainMay 11, 2024
@stefnnn

Copy link
Copy Markdown
ContributorAuthor

Backward compatibility will not be an issue, as there was no way to set the docker command in the previous version - it was automatically overwritten to _DEFAULT_DEV_COMMAND by the start() function. So I guess it's good enough for now. Thanks a lot for the thourough review and time!

alexanderankin pushed a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---
##
[4.4.1](testcontainers-v4.4.0...testcontainers-v4.4.1)
(2024-05-14)
### Bug Fixes
* Add memcached container
([#322](#322))
([690b9b4](690b9b4))
* Add selenium video support
[#6](#6)
([#364](#364))
([3c8006c](3c8006c))
* **core:** add empty _configure to DockerContainer
([#556](#556))
([08916c8](08916c8))
* **core:** remove version from compose tests
([#571](#571))
([38946d4](38946d4))
* **keycloak:** add realm imports
([#565](#565))
([f761b98](f761b98))
* **mysql:** Add seed support in MySQL
([#552](#552))
([396079a](396079a))
* url quote passwords
([#549](#549))
([6c5d227](6c5d227))
---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sebasszsebassz mentioned this pull request May 27, 2024
alexanderankin pushed a commit that referenced this pull request May 27, 2024
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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👥 community featfeature but its a community module so we wont bump tc core for it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@stefnnn@alexanderankin