diff --git a/internal/provider/resource_auth0_connection_test.go b/internal/provider/resource_auth0_connection_test.go index 0952629ce..717d23aeb 100644 --- a/internal/provider/resource_auth0_connection_test.go +++ b/internal/provider/resource_auth0_connection_test.go @@ -96,6 +96,8 @@ func TestAccConnection(t *testing.T) { resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.brute_force_protection", "false"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.mfa.0.return_enroll_settings", "false"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.upstream_params", ""), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.enabled_database_customization", "true"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.set_user_root_attributes", "on_first_login"), ), }, }, @@ -175,7 +177,8 @@ resource "auth0_connection" "my_connection" { password_no_personal_info { enable = true } - enabled_database_customization = false + enabled_database_customization = true + set_user_root_attributes = "on_first_login" brute_force_protection = false import_mode = false disable_signup = false diff --git a/internal/provider/structure_auth0_connection.go b/internal/provider/structure_auth0_connection.go index aba811aa4..1f8028069 100644 --- a/internal/provider/structure_auth0_connection.go +++ b/internal/provider/structure_auth0_connection.go @@ -105,6 +105,7 @@ func flattenConnectionOptionsAuth0(d ResourceData, options *management.Connectio "custom_scripts": options.CustomScripts, "configuration": Map(d, "options.0.configuration"), // does not get read back "non_persistent_attrs": options.GetNonPersistentAttrs(), + "set_user_root_attributes": options.GetSetUserAttributes(), } if options.PasswordComplexityOptions != nil { @@ -649,6 +650,7 @@ func expandConnectionOptionsAuth0(d ResourceData) (*management.ConnectionOptions options := &management.ConnectionOptions{ PasswordPolicy: String(d, "password_policy"), NonPersistentAttrs: castToListOfStrings(Set(d, "non_persistent_attrs").List()), + SetUserAttributes: String(d, "set_user_root_attributes"), } List(d, "validation").Elem(func(d ResourceData) { diff --git a/test/data/recordings/TestAccConnection.yaml b/test/data/recordings/TestAccConnection.yaml index 8903ed333..5ee563534 100644 --- a/test/data/recordings/TestAccConnection.yaml +++ b/test/data/recordings/TestAccConnection.yaml @@ -89,7 +89,7 @@ interactions: url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_QpRZXwUduHKEGdJP method: PATCH response: - body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":false},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' + body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":true,"set_user_root_attributes":"on_first_login"},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' headers: Content-Type: - application/json; charset=utf-8 @@ -108,7 +108,7 @@ interactions: url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_QpRZXwUduHKEGdJP method: GET response: - body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":false},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' + body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":true,"set_user_root_attributes":"on_first_login"},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' headers: Content-Type: - application/json; charset=utf-8 @@ -127,7 +127,7 @@ interactions: url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_QpRZXwUduHKEGdJP method: GET response: - body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":false},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' + body: '{"id":"con_QpRZXwUduHKEGdJP","options":{"mfa":{"active":true,"return_enroll_settings":false},"import_mode":false,"configuration":{"foo":"2.0$c093f4779d2dabf49617ebe6fd6ea3a8$ea46dfbbe4f971491f8fe2a51fabd3ff$ffceec6a68430196fb435c8f1d6717a3d535eadc8ef36468a64181b119484f50"},"customScripts":{"get_user":"myFunction"},"disable_signup":false,"passwordPolicy":"fair","password_history":{"size":5,"enable":true},"requires_username":true,"password_dictionary":{"enable":true,"dictionary":["password","admin","1234"]},"non_persistent_attrs":null,"brute_force_protection":false,"password_no_personal_info":{"enable":true},"password_complexity_options":{"min_length":6},"enabledDatabaseCustomization":true,"set_user_root_attributes":"on_first_login"},"strategy":"auth0","name":"Acceptance-Test-Connection-TestAccConnection","is_domain_connection":true,"enabled_clients":[],"realms":["Acceptance-Test-Connection-TestAccConnection"],"metadata":{"key1":"foo","key2":"bar"}}' headers: Content-Type: - application/json; charset=utf-8