dasniko / testcontainers-keycloak

A Testcontainer implementation for Keycloak IAM & SSO.
Apache License 2.0
327 stars 50 forks source link

Smtp support #111

Closed dilipdhankecha2530 closed 10 months ago

dilipdhankecha2530 commented 10 months ago

Description

Test send email mechanism by keycloak.

Motivation

No response

Details

No response

dasniko commented 10 months ago

You can pre-configure this in your imported realm file or by using the admin client. I currently see no need to add this as a desicated method.

wombat9000 commented 8 months ago

Hi,

I'm very happy that I found this project today as it has helped me out a great deal in setting up some integration tests for our keycloak setup.

However, I have not been able to configure the smtp config at runtime using the admin client, could you briefly highlight the relevant method for this? Setting the config in the imported realms file is not useful to me, because the smtp port/host are dynamically set at runtime when the smtp server is started. I would like to avoid having to write & cleanup the realms file programatically during the testsetup.

I tried two methods which seemed related:

keycloak.keycloakAdminClient.realm("acme").partialImport(partialImportRepresentation)

but the partialImportRepresentation does not include the smtpServer config. And

keycloak.keycloakAdminClient.realm("acme").testSMTPConnection(smtpConfig)

Did not seem to do the trick either, im guessing its not setting the config but just testing the smtp connection?

Any pointers appreciated, thanks!

dasniko commented 8 months ago

Well, for the records, this is not related to this project, but on how to use the admin api properly...

The SMTP configuration is part of the realm config, so use the RealmRepresentation object, there is a method setSmtpServer() which takes a Map<String, String> for configuration properties.