From 94099443ba56fa210b6b0a2ea72d23b4fe643df5 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea Date: Tue, 19 Apr 2022 14:48:04 +0200 Subject: [PATCH 1/4] Remove SetId in connection read method --- auth0/resource_auth0_connection.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/auth0/resource_auth0_connection.go b/auth0/resource_auth0_connection.go index 4d1a0e99f..e420b3016 100644 --- a/auth0/resource_auth0_connection.go +++ b/auth0/resource_auth0_connection.go @@ -789,8 +789,6 @@ func readConnection(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } - d.SetId(auth0.StringValue(connection.ID)) - result := multierror.Append( d.Set("name", connection.Name), d.Set("display_name", connection.DisplayName), From 56da3eae9962f9d4d578aa91e5363eb57edc3b55 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea Date: Tue, 19 Apr 2022 14:48:19 +0200 Subject: [PATCH 2/4] Set connection.options as computed --- auth0/resource_auth0_connection.go | 1 + 1 file changed, 1 insertion(+) diff --git a/auth0/resource_auth0_connection.go b/auth0/resource_auth0_connection.go index e420b3016..09421d14e 100644 --- a/auth0/resource_auth0_connection.go +++ b/auth0/resource_auth0_connection.go @@ -56,6 +56,7 @@ var connectionSchema = map[string]*schema.Schema{ }, "options": { Type: schema.TypeList, + Computed: true, Optional: true, MaxItems: 1, Elem: &schema.Resource{ From aae4d3d3c190a5ad15d056c09c58b8ea13eb22a0 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea Date: Tue, 19 Apr 2022 14:48:54 +0200 Subject: [PATCH 3/4] Remove checking if state has options when reading a conn options --- auth0/structure_auth0_connection.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/auth0/structure_auth0_connection.go b/auth0/structure_auth0_connection.go index 2237bee61..d375083e1 100644 --- a/auth0/structure_auth0_connection.go +++ b/auth0/structure_auth0_connection.go @@ -8,7 +8,7 @@ import ( ) func flattenConnectionOptions(d ResourceData, options interface{}) []interface{} { - if options == nil || optionsBlockIsNotDefined(d) { + if options == nil { return nil } @@ -54,11 +54,6 @@ func flattenConnectionOptions(d ResourceData, options interface{}) []interface{} return []interface{}{m} } -func optionsBlockIsNotDefined(d ResourceData) bool { - _, ok := d.GetOk("options") - return !ok -} - func flattenConnectionOptionsGitHub(options *management.ConnectionOptionsGitHub) interface{} { return map[string]interface{}{ "client_id": options.GetClientID(), From b107ecd5c78c88dbcc0cc1c01d0ee5009ec78ecc Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea Date: Tue, 19 Apr 2022 14:56:10 +0200 Subject: [PATCH 4/4] Add extra assertions in conn samlp test --- auth0/resource_auth0_connection_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/auth0/resource_auth0_connection_test.go b/auth0/resource_auth0_connection_test.go index d312e6b0b..ea60b4c8e 100644 --- a/auth0/resource_auth0_connection_test.go +++ b/auth0/resource_auth0_connection_test.go @@ -485,6 +485,7 @@ func TestAccConnectionWithEnabledClients(t *testing.T) { Check: resource.ComposeTestCheckFunc( random.TestCheckResourceAttr("auth0_connection.my_connection", "name", "Acceptance-Test-Connection-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.my_connection", "enabled_clients.#", "4"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"), // Gets computed with defaults by the API. ), }, }, @@ -1314,15 +1315,20 @@ func TestAccConnectionSAML(t *testing.T) { Config: random.Template(testConnectionSAMLConfigCreate, rand), Check: resource.ComposeTestCheckFunc( random.TestCheckResourceAttr("auth0_connection.my_connection", "name", "Acceptance-Test-SAML-{{.random}}", rand), + random.TestCheckResourceAttr("auth0_connection.my_connection", "display_name", "Acceptance-Test-SAML-{{.random}}", rand), resource.TestCheckResourceAttr("auth0_connection.my_connection", "strategy", "samlp"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "show_as_button", "false"), - random.TestCheckResourceAttr("auth0_connection.my_connection", "display_name", "Acceptance-Test-SAML-{{.random}}", rand), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.sign_out_endpoint", "https://saml.provider/sign_out"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.entity_id", ""), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.idp_initiated.0.client_authorize_query", "type=code&timeout=30"), ), }, { Config: random.Template(testConnectionSAMLConfigUpdate, rand), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("auth0_connection.my_connection", "show_as_button", "true"), + resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.#", "1"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.idp_initiated.0.client_authorize_query", "type=code&timeout=60"), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.sign_out_endpoint", ""), resource.TestCheckResourceAttr("auth0_connection.my_connection", "options.0.entity_id", "example"),