@@ -151,6 +151,46 @@ func TestAccKeycloakRealm_SmtpServerUpdate(t *testing.T) {
151151 },
152152 })
153153}
154+ func TestAccKeycloakRealm_SmtpServerOauth (t * testing.T ) {
155+ realm := acctest .RandomWithPrefix ("tf-acc" )
156+ realmDisplayNameHtml := acctest .RandomWithPrefix ("tf-acc" )
157+
158+ resource .Test (t , resource.TestCase {
159+ ProviderFactories : testAccProviderFactories ,
160+ PreCheck : func () { testAccPreCheck (t ) },
161+ CheckDestroy : testAccCheckKeycloakRealmDestroy (),
162+ Steps : []resource.TestStep {
163+ {
164+ Config : testKeycloakRealm_WithSmtpServerWithOauth (realm , "myhost.com" , "My Host" , "user" ),
165+ Check : testAccCheckKeycloakRealmSmtp ("keycloak_realm.realm" , "myhost.com" , "My Host" , "user" ),
166+ },
167+ {
168+ Config : testKeycloakRealm_basic (realm , realm , realmDisplayNameHtml ),
169+ Check : testAccCheckKeycloakRealmSmtp ("keycloak_realm.realm" , "" , "" , "" ),
170+ },
171+ },
172+ })
173+ }
174+
175+ func TestAccKeycloakRealm_SmtpServerOauthUpdate (t * testing.T ) {
176+ realm := acctest .RandomWithPrefix ("tf-acc" )
177+
178+ resource .Test (t , resource.TestCase {
179+ ProviderFactories : testAccProviderFactories ,
180+ PreCheck : func () { testAccPreCheck (t ) },
181+ CheckDestroy : testAccCheckKeycloakRealmDestroy (),
182+ Steps : []resource.TestStep {
183+ {
184+ Config : testKeycloakRealm_WithSmtpServerWithOauth (realm , "myhost.com" , "My Host" , "user" ),
185+ Check : testAccCheckKeycloakRealmSmtp ("keycloak_realm.realm" , "myhost.com" , "My Host" , "user" ),
186+ },
187+ {
188+ Config : testKeycloakRealm_WithSmtpServerWithOauth (realm , "myhost2.com" , "My Host2" , "user2" ),
189+ Check : testAccCheckKeycloakRealmSmtp ("keycloak_realm.realm" , "myhost2.com" , "My Host2" , "user2" ),
190+ },
191+ },
192+ })
193+ }
154194
155195func TestAccKeycloakRealm_SmtpServerInvalid (t * testing.T ) {
156196 realm := acctest .RandomWithPrefix ("tf-acc" )
@@ -1344,6 +1384,34 @@ resource "keycloak_realm" "realm" {
13441384 ` , realm , realm , host , from , user )
13451385}
13461386
1387+ func testKeycloakRealm_WithSmtpServerWithOauth (realm , host , from , user string ) string {
1388+ return fmt .Sprintf (`
1389+ resource "keycloak_realm" "realm" {
1390+ realm = "%s"
1391+ enabled = true
1392+ display_name = "%s"
1393+ smtp_server {
1394+ host = "%s"
1395+ port = 25
1396+ from_display_name = "Tom"
1397+ from = "%s"
1398+ reply_to_display_name = "Tom"
1399+ 1400+ ssl = true
1401+ starttls = true
1402+ envelope_from = "[email protected] " 1403+ token_auth {
1404+ username = "%s"
1405+ url = "wibble.com"
1406+ client_id = "wibble"
1407+ client_secret = "wobble"
1408+ scope = "wiggle"
1409+ }
1410+ }
1411+ }
1412+ ` , realm , realm , host , from , user )
1413+ }
1414+
13471415func testKeycloakRealm_WithOTP (realm , otpType , algorithm string , period int ) string {
13481416 return fmt .Sprintf (`
13491417resource "keycloak_realm" "realm" {
0 commit comments