Skip to content

Commit

Permalink
Unskip password policy user attachment test; add a test for v0.87.0
Browse files Browse the repository at this point in the history
References: #3005
  • Loading branch information
sfc-gh-asawicki committed Nov 7, 2024
1 parent 04cd9f0 commit 8995d8f
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions pkg/resources/user_password_policy_attachment_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
)

func TestAcc_UserPasswordPolicyAttachment(t *testing.T) {
// TODO [SNOW-1423486]: unskip
t.Skipf("Skip because error %s; will be fixed in SNOW-1423486", "Error: 000606 (57P03): No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.")
userId := acc.TestClient().Ids.RandomAccountObjectIdentifier()
userName := userId.Name()
newUserId := acc.TestClient().Ids.RandomAccountObjectIdentifier()
Expand Down Expand Up @@ -41,7 +39,42 @@ func TestAcc_UserPasswordPolicyAttachment(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "user_name", newUserName),
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "password_policy_name", newPasswordPolicyId.FullyQualifiedName()),
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "id", fmt.Sprintf("%s|%s", userId.FullyQualifiedName(), newPasswordPolicyId.FullyQualifiedName())),
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "id", fmt.Sprintf("%s|%s", newUserId.FullyQualifiedName(), newPasswordPolicyId.FullyQualifiedName())),
),
},
// IMPORT
{
ResourceName: "snowflake_user_password_policy_attachment.ppa",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAcc_UserPasswordPolicyAttachment_gh3005(t *testing.T) {
userId := acc.TestClient().Ids.RandomAccountObjectIdentifier()
userName := userId.Name()
passwordPolicyId := acc.TestClient().Ids.RandomSchemaObjectIdentifier()
passwordPolicyName := passwordPolicyId.Name()

resource.Test(t, resource.TestCase{
ExternalProviders: map[string]resource.ExternalProvider{
"snowflake": {
VersionConstraint: "=0.87.0",
Source: "Snowflake-Labs/snowflake",
},
},
PreCheck: func() { acc.TestAccPreCheck(t) },
CheckDestroy: acc.CheckUserPasswordPolicyAttachmentDestroy(t),
Steps: []resource.TestStep{
// CREATE
{
Config: userPasswordPolicyAttachmentConfigV087(userName, acc.TestDatabaseName, acc.TestSchemaName, passwordPolicyName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "user_name", userName),
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "password_policy_name", passwordPolicyId.FullyQualifiedName()),
resource.TestCheckResourceAttr("snowflake_user_password_policy_attachment.ppa", "id", fmt.Sprintf("%s|%s", userId.FullyQualifiedName(), passwordPolicyId.FullyQualifiedName())),
),
},
// IMPORT
Expand Down Expand Up @@ -72,3 +105,23 @@ resource "snowflake_user_password_policy_attachment" "ppa" {
}
`, userName, databaseName, schemaName, passwordPolicyName)
}

func userPasswordPolicyAttachmentConfigV087(userName, databaseName, schemaName, passwordPolicyName string) string {
return fmt.Sprintf(`
resource "snowflake_user" "user" {
name = "%[1]s"
}
resource "snowflake_password_policy" "pp" {
database = "%[2]s"
schema = "%[3]s"
name = "%[4]s"
}
resource "snowflake_user_password_policy_attachment" "ppa" {
depends_on = [snowflake_password_policy.pp]
password_policy_name = "\"%[2]s\".\"%[3]s\".\"%[4]s\""
user_name = snowflake_user.user.name
}
`, userName, databaseName, schemaName, passwordPolicyName)
}

0 comments on commit 8995d8f

Please sign in to comment.