Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SCIM access token Datasource #557

Prev Previous commit
Next Next commit
Randomize scim integration name
Christopher Isidora committed Jun 3, 2021
commit 603bcdb671d2253e0acee8594faa0436e68d42fe
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
package datasources_test

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccSystemGenerateSCIMAccessToken(t *testing.T) {
func TestAcc_SystemGenerateSCIMAccessToken(t *testing.T) {
scimIntName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
resource.ParallelTest(t, resource.TestCase{
Providers: providers(),
Steps: []resource.TestStep{
{
Config: generateAccessTokenConfig(),
Config: generateAccessTokenConfig(scimIntName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.snowflake_system_generate_scim_access_token.p", "integration_name", "AAD_PROVISIONING"),
resource.TestCheckResourceAttr("data.snowflake_system_generate_scim_access_token.p", "integration_name", scimIntName),
resource.TestCheckResourceAttrSet("data.snowflake_system_generate_scim_access_token.p", "access_token"),
),
},
},
})
}

func generateAccessTokenConfig() string {
s := `
resource "snowflake_role" "azure" {
func generateAccessTokenConfig(name string) string {
return fmt.Sprintf(`
resource "snowflake_role" "azured" {
name = "AAD_PROVISIONER"
comment = "test comment"
}
resource "snowflake_account_grant" "azurecu" {
resource "snowflake_account_grant" "azurecud" {
roles = [snowflake_role.azure.name]
privilege = "CREATE USER"
}
resource "snowflake_account_grant" "azurecr" {
resource "snowflake_account_grant" "azurecrd" {
roles = [snowflake_role.azure.name]
privilege = "CREATE ROLE"
}
resource "snowflake_role_grants" "azure" {
resource "snowflake_role_grants" "azured" {
role_name = snowflake_role.azure.name
roles = ["ACCOUNTADMIN"]
}
resource "snowflake_scim_integration" "azure" {
name = "AAD_PROVISIONING"
resource "snowflake_scim_integration" "azured" {
name = "%s"
scim_client = "AZURE"
provisioner_role = snowflake_role.azure.name
depends_on = [
snowflake_account_grant.azurecu,
snowflake_account_grant.azurecr,
snowflake_role_grants.azure
snowflake_account_grant.azurecud,
snowflake_account_grant.azurecrd,
snowflake_role_grants.azured
]
}
data snowflake_system_generate_scim_access_token p {
integration_name = snowflake_scim_integration.azure.name
integration_name = snowflake_scim_integration.azured.name
}
`
return s
`, name)
}