Skip to content

Commit

Permalink
fix: integration errors (#1623)
Browse files Browse the repository at this point in the history
* fix-oauth-integration

* fix oauth integration test
  • Loading branch information
sfc-gh-swinkler authored Mar 16, 2023
1 parent 9087220 commit 83a40d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/resources/oauth_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 11 additions & 8 deletions pkg/resources/oauth_integration_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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)
}

0 comments on commit 83a40d6

Please sign in to comment.