From 83a40d6361be0685b3864a0f3994298f3991de21 Mon Sep 17 00:00:00 2001 From: Scott Winkler Date: Thu, 16 Mar 2023 09:01:28 -0700 Subject: [PATCH] fix: integration errors (#1623) * fix-oauth-integration * fix oauth integration test --- pkg/resources/oauth_integration.go | 2 +- .../oauth_integration_acceptance_test.go | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/resources/oauth_integration.go b/pkg/resources/oauth_integration.go index cc05706a31..738dc24eac 100644 --- a/pkg/resources/oauth_integration.go +++ b/pkg/resources/oauth_integration.go @@ -242,7 +242,7 @@ func ReadOAuthIntegration(d *schema.ResourceData, meta interface{}) error { } case "OAUTH_CLIENT_TYPE": if err = d.Set("oauth_client_type", v.(string)); err != nil { - return errors.Wrap(err, "unable to set OAuth client type for security integration") + return fmt.Errorf("unable to set OAuth client type for security integration err = %w", err) } case "OAUTH_ENFORCE_PKCE": // Only used for custom OAuth clients (not supported yet) diff --git a/pkg/resources/oauth_integration_acceptance_test.go b/pkg/resources/oauth_integration_acceptance_test.go index d6e5f354d6..23ea87cb19 100644 --- a/pkg/resources/oauth_integration_acceptance_test.go +++ b/pkg/resources/oauth_integration_acceptance_test.go @@ -10,18 +10,20 @@ import ( ) func TestAcc_OAuthIntegration(t *testing.T) { - oauthIntName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) - integrationType := "TABLEAU_SERVER" + name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + oauthClient := "CUSTOM" + clientType := "PUBLIC" resource.ParallelTest(t, resource.TestCase{ Providers: providers(), CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: oauthIntegrationConfig(oauthIntName, integrationType), + Config: oauthIntegrationConfig(name, oauthClient, clientType), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "name", oauthIntName), - resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "oauth_client", integrationType), + resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "name", name), + resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "oauth_client", oauthClient), + resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "oauth_client_type", clientType), resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "oauth_issue_refresh_tokens", "true"), resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "oauth_refresh_token_validity", "3600"), resource.TestCheckResourceAttr("snowflake_oauth_integration.test", "blocked_roles_list.#", "1"), @@ -37,16 +39,17 @@ func TestAcc_OAuthIntegration(t *testing.T) { }) } -func oauthIntegrationConfig(name string, integrationType string) string { +func oauthIntegrationConfig(name, oauthClient, clientType string) string { return fmt.Sprintf(` resource "snowflake_oauth_integration" "test" { name = "%s" oauth_client = "%s" - oauth_client_type = "PUBLIC" + oauth_client_type = "%s" + oauth_redirect_uri = "https://www.example.com/oauth2/callback" enabled = true oauth_issue_refresh_tokens = true oauth_refresh_token_validity = 3600 blocked_roles_list = ["SYSADMIN"] } - `, name, integrationType) + `, name, oauthClient, clientType) }