Skip to content

Commit

Permalink
Merge branch 'main' into fix-data-retention-time-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak authored Feb 14, 2024
2 parents 95b3dba + dfb247f commit b075e0f
Show file tree
Hide file tree
Showing 24 changed files with 701 additions and 14 deletions.
49 changes: 49 additions & 0 deletions pkg/resources/grant_privileges_to_account_role_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,55 @@ func TestAcc_GrantPrivilegesToAccountRole_OnSchemaObject_OnAll_InDatabase(t *tes
})
}

func TestAcc_GrantPrivilegesToAccountRole_OnSchemaObject_OnAllPipes(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
roleName := sdk.NewAccountObjectIdentifier(name).FullyQualifiedName()
databaseName := sdk.NewAccountObjectIdentifier(acc.TestDatabaseName).FullyQualifiedName()
configVariables := config.Variables{
"name": config.StringVariable(roleName),
"privileges": config.ListVariable(
config.StringVariable(string(sdk.SchemaObjectPrivilegeMonitor)),
),
"database": config.StringVariable(databaseName),
"with_grant_option": config.BoolVariable(false),
}
resourceName := "snowflake_grant_privileges_to_account_role.test"

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: testAccCheckAccountRolePrivilegesRevoked(name),
Steps: []resource.TestStep{
{
PreConfig: func() { createAccountRoleOutsideTerraform(t, name) },
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToAccountRole/OnAllPipes"),
ConfigVariables: configVariables,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "account_role_name", roleName),
resource.TestCheckResourceAttr(resourceName, "privileges.#", "1"),
resource.TestCheckResourceAttr(resourceName, "privileges.0", string(sdk.SchemaObjectPrivilegeMonitor)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.object_type_plural", string(sdk.PluralObjectTypePipes)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.in_database", databaseName),
resource.TestCheckResourceAttr(resourceName, "with_grant_option", "false"),
resource.TestCheckResourceAttr(resourceName, "id", fmt.Sprintf("%s|false|false|MONITOR|OnSchemaObject|OnAll|PIPES|InDatabase|%s", roleName, databaseName)),
),
},
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToAccountRole/OnAllPipes"),
ConfigVariables: configVariables,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAcc_GrantPrivilegesToAccountRole_OnSchemaObject_OnFuture_InDatabase(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
roleName := sdk.NewAccountObjectIdentifier(name).FullyQualifiedName()
Expand Down
50 changes: 50 additions & 0 deletions pkg/resources/grant_privileges_to_database_role_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,56 @@ func TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAll_InDatabase(t *te
})
}

func TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAllPipes(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
configVariables := config.Variables{
"name": config.StringVariable(name),
"privileges": config.ListVariable(
config.StringVariable(string(sdk.SchemaObjectPrivilegeMonitor)),
),
"database": config.StringVariable(acc.TestDatabaseName),
"with_grant_option": config.BoolVariable(false),
}
resourceName := "snowflake_grant_privileges_to_database_role.test"

databaseRoleName := sdk.NewDatabaseObjectIdentifier(acc.TestDatabaseName, name).FullyQualifiedName()
databaseName := sdk.NewAccountObjectIdentifier(acc.TestDatabaseName).FullyQualifiedName()

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: testAccCheckDatabaseRolePrivilegesRevoked,
Steps: []resource.TestStep{
{
PreConfig: func() { createDatabaseRoleOutsideTerraform(t, name) },
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToDatabaseRole/OnAllPipes"),
ConfigVariables: configVariables,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "database_role_name", databaseRoleName),
resource.TestCheckResourceAttr(resourceName, "privileges.#", "1"),
resource.TestCheckResourceAttr(resourceName, "privileges.0", string(sdk.SchemaObjectPrivilegeMonitor)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.object_type_plural", string(sdk.PluralObjectTypePipes)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.in_database", databaseName),
resource.TestCheckResourceAttr(resourceName, "with_grant_option", "false"),
resource.TestCheckResourceAttr(resourceName, "id", fmt.Sprintf("%s|false|false|MONITOR|OnSchemaObject|OnAll|PIPES|InDatabase|%s", databaseRoleName, databaseName)),
),
},
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToDatabaseRole/OnAllPipes"),
ConfigVariables: configVariables,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnFuture_InDatabase(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
configVariables := config.Variables{
Expand Down
51 changes: 50 additions & 1 deletion pkg/resources/grant_privileges_to_role_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func grantPrivilegesToRole_multipleResources(name string, privileges1, privilege
func TestAcc_GrantPrivilegesToRole_onSchemaObject_futureInDatabase_externalTable(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
objectType := "EXTERNAL TABLES"
resource.ParallelTest(t, resource.TestCase{
resource.Test(t, resource.TestCase{
Providers: acc.TestAccProviders(),
PreCheck: func() { acc.TestAccPreCheck(t) },
CheckDestroy: nil,
Expand Down Expand Up @@ -921,6 +921,55 @@ func TestAcc_GrantPrivilegesToRole_onSchemaObject_futureInDatabase_externalTable
})
}

func TestAcc_GrantPrivilegesToRole_OnAllPipes(t *testing.T) {
name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
roleName := sdk.NewAccountObjectIdentifier(name).FullyQualifiedName()
databaseName := sdk.NewAccountObjectIdentifier(acc.TestDatabaseName).FullyQualifiedName()
configVariables := config.Variables{
"name": config.StringVariable(roleName),
"privileges": config.ListVariable(
config.StringVariable(string(sdk.SchemaObjectPrivilegeMonitor)),
),
"database": config.StringVariable(databaseName),
"with_grant_option": config.BoolVariable(false),
}
resourceName := "snowflake_grant_privileges_to_role.test"

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: testAccCheckAccountRolePrivilegesRevoked(name),
Steps: []resource.TestStep{
{
PreConfig: func() { createAccountRoleOutsideTerraform(t, name) },
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToRole/OnAllPipes"),
ConfigVariables: configVariables,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "role_name", roleName),
resource.TestCheckResourceAttr(resourceName, "privileges.#", "1"),
resource.TestCheckResourceAttr(resourceName, "privileges.0", string(sdk.SchemaObjectPrivilegeMonitor)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.#", "1"),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.object_type_plural", string(sdk.PluralObjectTypePipes)),
resource.TestCheckResourceAttr(resourceName, "on_schema_object.0.all.0.in_database", databaseName),
resource.TestCheckResourceAttr(resourceName, "with_grant_option", "false"),
resource.TestCheckResourceAttr(resourceName, "id", fmt.Sprintf("%s|MONITOR|false|false|false|false|false|true|true|false|||PIPES|false||true|%s", roleName, databaseName)),
),
},
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToRole/OnAllPipes"),
ConfigVariables: configVariables,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAcc_GrantPrivilegesToRole_onSchemaObject_futureIcebergTables(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "snowflake_grant_privileges_to_account_role" "test" {
account_role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

on_schema_object {
all {
object_type_plural = "PIPES"
in_database = var.database
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "name" {
type = string
}

variable "privileges" {
type = list(string)
}

variable "database" {
type = string
}

variable "with_grant_option" {
type = bool
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
privileges = var.privileges
with_grant_option = var.with_grant_option

on_schema_object {
all {
object_type_plural = "PIPES"
in_database = "\"${var.database}\""
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "name" {
type = string
}

variable "privileges" {
type = list(string)
}

variable "database" {
type = string
}

variable "with_grant_option" {
type = bool
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "snowflake_grant_privileges_to_role" "test" {
role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

on_schema_object {
all {
object_type_plural = "PIPES"
in_database = var.database
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "name" {
type = string
}

variable "privileges" {
type = list(string)
}

variable "database" {
type = string
}

variable "with_grant_option" {
type = bool
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
name = var.to_share
depends_on = [snowflake_database.test]
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_share" "test" {
depends_on = [snowflake_database.test]
name = var.to_share
}

resource "snowflake_database" "test" {
depends_on = [snowflake_share.test]
name = var.database
}

Expand Down
Loading

0 comments on commit b075e0f

Please sign in to comment.