Skip to content

Commit

Permalink
Randomize test issuer for oauth integration acceptance test. (#1728)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ngaberel authored Apr 18, 2023
1 parent 19a4156 commit c62bad1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/resources/external_oauth_integration_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand All @@ -13,17 +14,19 @@ func TestAcc_ExternalOauthIntegration(t *testing.T) {
oauthIntName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
integrationType := "AZURE"

issuer := fmt.Sprintf("https://sts.windows.net/%s", uuid.NewString())

resource.ParallelTest(t, resource.TestCase{
Providers: providers(),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: externalOauthIntegrationConfig(oauthIntName, integrationType),
Config: externalOauthIntegrationConfig(oauthIntName, integrationType, issuer),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "name", oauthIntName),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "type", integrationType),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "enabled", "true"),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "issuer", "https://sts.windows.net/00000000-0000-0000-0000-000000000000"),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "issuer", issuer),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "snowflake_user_mapping_attribute", "LOGIN_NAME"),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "token_user_mapping_claims.#", "1"),
resource.TestCheckResourceAttr("snowflake_external_oauth_integration.test", "token_user_mapping_claims.0", "upn"),
Expand All @@ -38,17 +41,17 @@ func TestAcc_ExternalOauthIntegration(t *testing.T) {
})
}

func externalOauthIntegrationConfig(name string, integrationType string) string {
func externalOauthIntegrationConfig(name, integrationType, issuer string) string {
return fmt.Sprintf(`
resource "snowflake_external_oauth_integration" "test" {
name = "%s"
type = "%s"
enabled = true
issuer = "https://sts.windows.net/00000000-0000-0000-0000-000000000000"
issuer = "%s"
snowflake_user_mapping_attribute = "LOGIN_NAME"
jws_keys_urls = ["https://login.windows.net/common/discovery/keys"]
audience_urls = ["https://analysis.windows.net/powerbi/connector/Snowflake"]
token_user_mapping_claims = ["upn"]
}
`, name, integrationType)
`, name, integrationType, issuer)
}

0 comments on commit c62bad1

Please sign in to comment.