From 1cf3467629421b59ca7d54cb7bad10a5fcc9c8ef Mon Sep 17 00:00:00 2001 From: Thilo Keber Date: Wed, 3 Jul 2019 16:13:40 +0200 Subject: [PATCH] fix connection test fix setting/getting of userMetadata and appMetadat format metadata in user test --- auth0/resource_auth0_connection_test.go | 6 +++--- auth0/resource_auth0_user.go | 8 ++++---- auth0/resource_auth0_user_test.go | 17 +++-------------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/auth0/resource_auth0_connection_test.go b/auth0/resource_auth0_connection_test.go index 431e5d59..e1265cc7 100644 --- a/auth0/resource_auth0_connection_test.go +++ b/auth0/resource_auth0_connection_test.go @@ -22,7 +22,7 @@ func TestAccConnection(t *testing.T) { resource.TestCheckResourceAttr("auth0_connection.my_connection", "strategy", "auth0"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.password_policy", "fair"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.password_no_personal_info.0.enable", "true"), - resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.enabled_database_customization", "false"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.enabled_database_customization", "true"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.brute_force_protection", "true"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.import_mode", "true"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.disable_signup", "false"), @@ -57,7 +57,7 @@ resource "auth0_connection" "my_connection" { password_no_personal_info { enable = true } - enabled_database_customization = false + enabled_database_customization = true brute_force_protection = true import_mode = true disable_signup = false @@ -88,7 +88,7 @@ resource "auth0_connection" "my_connection" { password_no_personal_info { enable = true } - enabled_database_customization = false + enabled_database_customization = true brute_force_protection = false import_mode = true disable_signup = false diff --git a/auth0/resource_auth0_user.go b/auth0/resource_auth0_user.go index 11892779..6b36c855 100644 --- a/auth0/resource_auth0_user.go +++ b/auth0/resource_auth0_user.go @@ -93,11 +93,11 @@ func readUser(d *schema.ResourceData, m interface{}) error { d.Set("verify_email", u.VerifyEmail) d.Set("email", u.Email) - if userMeta, err := structure.FlattenJsonToString(u.UserMetadata); err != nil { + if userMeta, err := structure.FlattenJsonToString(u.UserMetadata); err == nil { d.Set("user_metadata", userMeta) } - if appMeta, err := structure.FlattenJsonToString(u.AppMetadata); err != nil { + if appMeta, err := structure.FlattenJsonToString(u.AppMetadata); err == nil { d.Set("app_metadata", appMeta) } @@ -144,14 +144,14 @@ func buildUser(d *schema.ResourceData) *management.User { if d.HasChange("user_metadata") { userMeta, err := structure.ExpandJsonFromString(d.Get("user_metadata").(string)) - if err != nil { + if err == nil { u.UserMetadata = userMeta } } if d.HasChange("app_metadata") { appMeta, err := structure.ExpandJsonFromString(d.Get("app_metadata").(string)) - if err != nil { + if err == nil { u.AppMetadata = appMeta } } diff --git a/auth0/resource_auth0_user_test.go b/auth0/resource_auth0_user_test.go index 58c14ec0..29c5dee3 100644 --- a/auth0/resource_auth0_user_test.go +++ b/auth0/resource_auth0_user_test.go @@ -49,8 +49,7 @@ func TestAccUserCreateUser(t *testing.T) { } const testAccUserCreateUser = ` -provider "auth0" { -} +provider "auth0" {} resource "auth0_user" "user" { connection_name = "Username-Password-Authentication" @@ -59,17 +58,7 @@ resource "auth0_user" "user" { email = "test@test.com" password = "passpass$12$12" nickname = "testnick" - user_metadata = <