diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go index e5451d9c67..f7b1fa200f 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -177,4 +177,28 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "ManagedAccount", schema: resources.ManagedAccount().Schema, }, + { + name: "NetworkPolicy", + schema: resources.NetworkPolicy().Schema, + }, + { + name: "ScimSecurityIntegration", + schema: resources.SCIMIntegration().Schema, + }, + { + name: "Saml2SecurityIntegration", + schema: resources.SAML2Integration().Schema, + }, + { + name: "ApiAuthenticationIntegrationWithAuthorizationCodeGrant", + schema: resources.ApiAuthenticationIntegrationWithAuthorizationCodeGrant().Schema, + }, + { + name: "ApiAuthenticationIntegrationWithClientCredentials", + schema: resources.ApiAuthenticationIntegrationWithClientCredentials().Schema, + }, + { + name: "ExternalOauthSecurityIntegration", + schema: resources.ExternalOauthIntegration().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go index 2674d03810..3d295a14a9 100644 --- a/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go @@ -46,4 +46,24 @@ var allDatasourcesSchemaDefs = []DatasourceSchemaDef{ name: "Grants", schema: datasources.Grants().Schema, }, + { + name: "NetworkPolicies", + schema: datasources.NetworkPolicies().Schema, + }, + { + name: "ResourceMonitors", + schema: datasources.ResourceMonitors().Schema, + }, + { + name: "Schemas", + schema: datasources.Schemas().Schema, + }, + { + name: "Secrets", + schema: datasources.Secrets().Schema, + }, + { + name: "SecurityIntegrations", + schema: datasources.SecurityIntegrations().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/network_policies_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/network_policies_model_gen.go new file mode 100644 index 0000000000..1722a655ab --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/network_policies_model_gen.go @@ -0,0 +1,93 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" +) + +type NetworkPoliciesModel struct { + Like tfconfig.Variable `json:"like,omitempty"` + NetworkPolicies tfconfig.Variable `json:"network_policies,omitempty"` + WithDescribe tfconfig.Variable `json:"with_describe,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func NetworkPolicies( + datasourceName string, +) *NetworkPoliciesModel { + n := &NetworkPoliciesModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.NetworkPolicies)} + return n +} + +func NetworkPoliciesWithDefaultMeta() *NetworkPoliciesModel { + n := &NetworkPoliciesModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.NetworkPolicies)} + return n +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (n *NetworkPoliciesModel) MarshalJSON() ([]byte, error) { + type Alias NetworkPoliciesModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + SingleAttributeWorkaround config.ReplacementPlaceholder `json:"single_attribute_workaround,omitempty"` + }{ + Alias: (*Alias)(n), + DependsOn: n.DependsOn(), + SingleAttributeWorkaround: config.SnowflakeProviderConfigSingleAttributeWorkaround, + }) +} + +func (n *NetworkPoliciesModel) WithDependsOn(values ...string) *NetworkPoliciesModel { + n.SetDependsOn(values...) + return n +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (n *NetworkPoliciesModel) WithLike(like string) *NetworkPoliciesModel { + n.Like = tfconfig.StringVariable(like) + return n +} + +// network_policies attribute type is not yet supported, so WithNetworkPolicies can't be generated + +func (n *NetworkPoliciesModel) WithWithDescribe(withDescribe bool) *NetworkPoliciesModel { + n.WithDescribe = tfconfig.BoolVariable(withDescribe) + return n +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (n *NetworkPoliciesModel) WithLikeValue(value tfconfig.Variable) *NetworkPoliciesModel { + n.Like = value + return n +} + +func (n *NetworkPoliciesModel) WithNetworkPoliciesValue(value tfconfig.Variable) *NetworkPoliciesModel { + n.NetworkPolicies = value + return n +} + +func (n *NetworkPoliciesModel) WithWithDescribeValue(value tfconfig.Variable) *NetworkPoliciesModel { + n.WithDescribe = value + return n +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/resource_monitors_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/resource_monitors_model_gen.go new file mode 100644 index 0000000000..77580e68f0 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/resource_monitors_model_gen.go @@ -0,0 +1,82 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" +) + +type ResourceMonitorsModel struct { + Like tfconfig.Variable `json:"like,omitempty"` + ResourceMonitors tfconfig.Variable `json:"resource_monitors,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ResourceMonitors( + datasourceName string, +) *ResourceMonitorsModel { + r := &ResourceMonitorsModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.ResourceMonitors)} + return r +} + +func ResourceMonitorsWithDefaultMeta() *ResourceMonitorsModel { + r := &ResourceMonitorsModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.ResourceMonitors)} + return r +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (r *ResourceMonitorsModel) MarshalJSON() ([]byte, error) { + type Alias ResourceMonitorsModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + SingleAttributeWorkaround config.ReplacementPlaceholder `json:"single_attribute_workaround,omitempty"` + }{ + Alias: (*Alias)(r), + DependsOn: r.DependsOn(), + SingleAttributeWorkaround: config.SnowflakeProviderConfigSingleAttributeWorkaround, + }) +} + +func (r *ResourceMonitorsModel) WithDependsOn(values ...string) *ResourceMonitorsModel { + r.SetDependsOn(values...) + return r +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (r *ResourceMonitorsModel) WithLike(like string) *ResourceMonitorsModel { + r.Like = tfconfig.StringVariable(like) + return r +} + +// resource_monitors attribute type is not yet supported, so WithResourceMonitors can't be generated + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (r *ResourceMonitorsModel) WithLikeValue(value tfconfig.Variable) *ResourceMonitorsModel { + r.Like = value + return r +} + +func (r *ResourceMonitorsModel) WithResourceMonitorsValue(value tfconfig.Variable) *ResourceMonitorsModel { + r.ResourceMonitors = value + return r +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_ext.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_ext.go new file mode 100644 index 0000000000..9d531149b7 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_ext.go @@ -0,0 +1,32 @@ +package datasourcemodel + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +func (s *SchemasModel) WithLimit(rows int) *SchemasModel { + return s.WithLimitValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "rows": tfconfig.IntegerVariable(rows), + }), + ) +} + +func (s *SchemasModel) WithRowsAndFrom(rows int, from string) *SchemasModel { + return s.WithLimitValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "rows": tfconfig.IntegerVariable(rows), + "from": tfconfig.StringVariable(from), + }), + ) +} + +func (s *SchemasModel) WithIn(databaseId sdk.AccountObjectIdentifier) *SchemasModel { + return s.WithInValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "database": tfconfig.StringVariable(databaseId.Name()), + }), + ) +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_gen.go new file mode 100644 index 0000000000..ec50a7e2c5 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/schemas_model_gen.go @@ -0,0 +1,131 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" +) + +type SchemasModel struct { + In tfconfig.Variable `json:"in,omitempty"` + Like tfconfig.Variable `json:"like,omitempty"` + Limit tfconfig.Variable `json:"limit,omitempty"` + Schemas tfconfig.Variable `json:"schemas,omitempty"` + StartsWith tfconfig.Variable `json:"starts_with,omitempty"` + WithDescribe tfconfig.Variable `json:"with_describe,omitempty"` + WithParameters tfconfig.Variable `json:"with_parameters,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func Schemas( + datasourceName string, +) *SchemasModel { + s := &SchemasModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.Schemas)} + return s +} + +func SchemasWithDefaultMeta() *SchemasModel { + s := &SchemasModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.Schemas)} + return s +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (s *SchemasModel) MarshalJSON() ([]byte, error) { + type Alias SchemasModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + SingleAttributeWorkaround config.ReplacementPlaceholder `json:"single_attribute_workaround,omitempty"` + }{ + Alias: (*Alias)(s), + DependsOn: s.DependsOn(), + SingleAttributeWorkaround: config.SnowflakeProviderConfigSingleAttributeWorkaround, + }) +} + +func (s *SchemasModel) WithDependsOn(values ...string) *SchemasModel { + s.SetDependsOn(values...) + return s +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// in attribute type is not yet supported, so WithIn can't be generated + +func (s *SchemasModel) WithLike(like string) *SchemasModel { + s.Like = tfconfig.StringVariable(like) + return s +} + +// limit attribute type is not yet supported, so WithLimit can't be generated + +// schemas attribute type is not yet supported, so WithSchemas can't be generated + +func (s *SchemasModel) WithStartsWith(startsWith string) *SchemasModel { + s.StartsWith = tfconfig.StringVariable(startsWith) + return s +} + +func (s *SchemasModel) WithWithDescribe(withDescribe bool) *SchemasModel { + s.WithDescribe = tfconfig.BoolVariable(withDescribe) + return s +} + +func (s *SchemasModel) WithWithParameters(withParameters bool) *SchemasModel { + s.WithParameters = tfconfig.BoolVariable(withParameters) + return s +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (s *SchemasModel) WithInValue(value tfconfig.Variable) *SchemasModel { + s.In = value + return s +} + +func (s *SchemasModel) WithLikeValue(value tfconfig.Variable) *SchemasModel { + s.Like = value + return s +} + +func (s *SchemasModel) WithLimitValue(value tfconfig.Variable) *SchemasModel { + s.Limit = value + return s +} + +func (s *SchemasModel) WithSchemasValue(value tfconfig.Variable) *SchemasModel { + s.Schemas = value + return s +} + +func (s *SchemasModel) WithStartsWithValue(value tfconfig.Variable) *SchemasModel { + s.StartsWith = value + return s +} + +func (s *SchemasModel) WithWithDescribeValue(value tfconfig.Variable) *SchemasModel { + s.WithDescribe = value + return s +} + +func (s *SchemasModel) WithWithParametersValue(value tfconfig.Variable) *SchemasModel { + s.WithParameters = value + return s +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_ext.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_ext.go new file mode 100644 index 0000000000..e6578aed87 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_ext.go @@ -0,0 +1,31 @@ +package datasourcemodel + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +func (s *SecretsModel) WithInDatabase(databaseId sdk.AccountObjectIdentifier) *SecretsModel { + return s.WithInValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "database": tfconfig.StringVariable(databaseId.Name()), + }), + ) +} + +func (s *SecretsModel) WithInSchema(schemaId sdk.DatabaseObjectIdentifier) *SecretsModel { + return s.WithInValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "schema": tfconfig.StringVariable(schemaId.FullyQualifiedName()), + }), + ) +} + +func (s *SecretsModel) WithInAccount() *SecretsModel { + return s.WithInValue( + tfconfig.ObjectVariable(map[string]tfconfig.Variable{ + "account": tfconfig.BoolVariable(true), + }), + ) +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_gen.go new file mode 100644 index 0000000000..d5f9e868fb --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/secrets_model_gen.go @@ -0,0 +1,101 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" +) + +type SecretsModel struct { + In tfconfig.Variable `json:"in,omitempty"` + Like tfconfig.Variable `json:"like,omitempty"` + Secrets tfconfig.Variable `json:"secrets,omitempty"` + WithDescribe tfconfig.Variable `json:"with_describe,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func Secrets( + datasourceName string, +) *SecretsModel { + s := &SecretsModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.Secrets)} + return s +} + +func SecretsWithDefaultMeta() *SecretsModel { + s := &SecretsModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.Secrets)} + return s +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (s *SecretsModel) MarshalJSON() ([]byte, error) { + type Alias SecretsModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + SingleAttributeWorkaround config.ReplacementPlaceholder `json:"single_attribute_workaround,omitempty"` + }{ + Alias: (*Alias)(s), + DependsOn: s.DependsOn(), + SingleAttributeWorkaround: config.SnowflakeProviderConfigSingleAttributeWorkaround, + }) +} + +func (s *SecretsModel) WithDependsOn(values ...string) *SecretsModel { + s.SetDependsOn(values...) + return s +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// in attribute type is not yet supported, so WithIn can't be generated + +func (s *SecretsModel) WithLike(like string) *SecretsModel { + s.Like = tfconfig.StringVariable(like) + return s +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (s *SecretsModel) WithWithDescribe(withDescribe bool) *SecretsModel { + s.WithDescribe = tfconfig.BoolVariable(withDescribe) + return s +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (s *SecretsModel) WithInValue(value tfconfig.Variable) *SecretsModel { + s.In = value + return s +} + +func (s *SecretsModel) WithLikeValue(value tfconfig.Variable) *SecretsModel { + s.Like = value + return s +} + +func (s *SecretsModel) WithSecretsValue(value tfconfig.Variable) *SecretsModel { + s.Secrets = value + return s +} + +func (s *SecretsModel) WithWithDescribeValue(value tfconfig.Variable) *SecretsModel { + s.WithDescribe = value + return s +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/security_integrations_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/security_integrations_model_gen.go new file mode 100644 index 0000000000..3d146fdbec --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/security_integrations_model_gen.go @@ -0,0 +1,93 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" +) + +type SecurityIntegrationsModel struct { + Like tfconfig.Variable `json:"like,omitempty"` + SecurityIntegrations tfconfig.Variable `json:"security_integrations,omitempty"` + WithDescribe tfconfig.Variable `json:"with_describe,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func SecurityIntegrations( + datasourceName string, +) *SecurityIntegrationsModel { + s := &SecurityIntegrationsModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.SecurityIntegrations)} + return s +} + +func SecurityIntegrationsWithDefaultMeta() *SecurityIntegrationsModel { + s := &SecurityIntegrationsModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.SecurityIntegrations)} + return s +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (s *SecurityIntegrationsModel) MarshalJSON() ([]byte, error) { + type Alias SecurityIntegrationsModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + SingleAttributeWorkaround config.ReplacementPlaceholder `json:"single_attribute_workaround,omitempty"` + }{ + Alias: (*Alias)(s), + DependsOn: s.DependsOn(), + SingleAttributeWorkaround: config.SnowflakeProviderConfigSingleAttributeWorkaround, + }) +} + +func (s *SecurityIntegrationsModel) WithDependsOn(values ...string) *SecurityIntegrationsModel { + s.SetDependsOn(values...) + return s +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (s *SecurityIntegrationsModel) WithLike(like string) *SecurityIntegrationsModel { + s.Like = tfconfig.StringVariable(like) + return s +} + +// security_integrations attribute type is not yet supported, so WithSecurityIntegrations can't be generated + +func (s *SecurityIntegrationsModel) WithWithDescribe(withDescribe bool) *SecurityIntegrationsModel { + s.WithDescribe = tfconfig.BoolVariable(withDescribe) + return s +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (s *SecurityIntegrationsModel) WithLikeValue(value tfconfig.Variable) *SecurityIntegrationsModel { + s.Like = value + return s +} + +func (s *SecurityIntegrationsModel) WithSecurityIntegrationsValue(value tfconfig.Variable) *SecurityIntegrationsModel { + s.SecurityIntegrations = value + return s +} + +func (s *SecurityIntegrationsModel) WithWithDescribeValue(value tfconfig.Variable) *SecurityIntegrationsModel { + s.WithDescribe = value + return s +} diff --git a/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_authorization_code_grant_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_authorization_code_grant_model_gen.go new file mode 100644 index 0000000000..528f0d5eeb --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_authorization_code_grant_model_gen.go @@ -0,0 +1,207 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel struct { + Comment tfconfig.Variable `json:"comment,omitempty"` + Enabled tfconfig.Variable `json:"enabled,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + OauthAccessTokenValidity tfconfig.Variable `json:"oauth_access_token_validity,omitempty"` + OauthAllowedScopes tfconfig.Variable `json:"oauth_allowed_scopes,omitempty"` + OauthAuthorizationEndpoint tfconfig.Variable `json:"oauth_authorization_endpoint,omitempty"` + OauthClientAuthMethod tfconfig.Variable `json:"oauth_client_auth_method,omitempty"` + OauthClientId tfconfig.Variable `json:"oauth_client_id,omitempty"` + OauthClientSecret tfconfig.Variable `json:"oauth_client_secret,omitempty"` + OauthRefreshTokenValidity tfconfig.Variable `json:"oauth_refresh_token_validity,omitempty"` + OauthTokenEndpoint tfconfig.Variable `json:"oauth_token_endpoint,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ApiAuthenticationIntegrationWithAuthorizationCodeGrant( + resourceName string, + enabled bool, + name string, + oauthClientId string, + oauthClientSecret string, +) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a := &ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel{ResourceModelMeta: config.Meta(resourceName, resources.ApiAuthenticationIntegrationWithAuthorizationCodeGrant)} + a.WithEnabled(enabled) + a.WithName(name) + a.WithOauthClientId(oauthClientId) + a.WithOauthClientSecret(oauthClientSecret) + return a +} + +func ApiAuthenticationIntegrationWithAuthorizationCodeGrantWithDefaultMeta( + enabled bool, + name string, + oauthClientId string, + oauthClientSecret string, +) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a := &ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel{ResourceModelMeta: config.DefaultMeta(resources.ApiAuthenticationIntegrationWithAuthorizationCodeGrant)} + a.WithEnabled(enabled) + a.WithName(name) + a.WithOauthClientId(oauthClientId) + a.WithOauthClientSecret(oauthClientSecret) + return a +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) MarshalJSON() ([]byte, error) { + type Alias ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(a), + DependsOn: a.DependsOn(), + }) +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithDependsOn(values ...string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.SetDependsOn(values...) + return a +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithComment(comment string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Comment = tfconfig.StringVariable(comment) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithEnabled(enabled bool) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Enabled = tfconfig.BoolVariable(enabled) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithFullyQualifiedName(fullyQualifiedName string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithName(name string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Name = tfconfig.StringVariable(name) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthAccessTokenValidity(oauthAccessTokenValidity int) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthAccessTokenValidity = tfconfig.IntegerVariable(oauthAccessTokenValidity) + return a +} + +// oauth_allowed_scopes attribute type is not yet supported, so WithOauthAllowedScopes can't be generated + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthAuthorizationEndpoint(oauthAuthorizationEndpoint string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthAuthorizationEndpoint = tfconfig.StringVariable(oauthAuthorizationEndpoint) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientAuthMethod(oauthClientAuthMethod string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientAuthMethod = tfconfig.StringVariable(oauthClientAuthMethod) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientId(oauthClientId string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientId = tfconfig.StringVariable(oauthClientId) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientSecret(oauthClientSecret string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientSecret = tfconfig.StringVariable(oauthClientSecret) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthRefreshTokenValidity(oauthRefreshTokenValidity int) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthRefreshTokenValidity = tfconfig.IntegerVariable(oauthRefreshTokenValidity) + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthTokenEndpoint(oauthTokenEndpoint string) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthTokenEndpoint = tfconfig.StringVariable(oauthTokenEndpoint) + return a +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithCommentValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Comment = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithEnabledValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Enabled = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.FullyQualifiedName = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithNameValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.Name = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthAccessTokenValidityValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthAccessTokenValidity = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthAllowedScopesValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthAllowedScopes = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthAuthorizationEndpointValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthAuthorizationEndpoint = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientAuthMethodValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientAuthMethod = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientIdValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientId = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthClientSecretValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthClientSecret = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthRefreshTokenValidityValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthRefreshTokenValidity = value + return a +} + +func (a *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel) WithOauthTokenEndpointValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithAuthorizationCodeGrantModel { + a.OauthTokenEndpoint = value + return a +} diff --git a/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_client_credentials_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_client_credentials_model_gen.go new file mode 100644 index 0000000000..8aced921e7 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/api_authentication_integration_with_client_credentials_model_gen.go @@ -0,0 +1,196 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type ApiAuthenticationIntegrationWithClientCredentialsModel struct { + Comment tfconfig.Variable `json:"comment,omitempty"` + Enabled tfconfig.Variable `json:"enabled,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + OauthAccessTokenValidity tfconfig.Variable `json:"oauth_access_token_validity,omitempty"` + OauthAllowedScopes tfconfig.Variable `json:"oauth_allowed_scopes,omitempty"` + OauthClientAuthMethod tfconfig.Variable `json:"oauth_client_auth_method,omitempty"` + OauthClientId tfconfig.Variable `json:"oauth_client_id,omitempty"` + OauthClientSecret tfconfig.Variable `json:"oauth_client_secret,omitempty"` + OauthRefreshTokenValidity tfconfig.Variable `json:"oauth_refresh_token_validity,omitempty"` + OauthTokenEndpoint tfconfig.Variable `json:"oauth_token_endpoint,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ApiAuthenticationIntegrationWithClientCredentials( + resourceName string, + enabled bool, + name string, + oauthClientId string, + oauthClientSecret string, +) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a := &ApiAuthenticationIntegrationWithClientCredentialsModel{ResourceModelMeta: config.Meta(resourceName, resources.ApiAuthenticationIntegrationWithClientCredentials)} + a.WithEnabled(enabled) + a.WithName(name) + a.WithOauthClientId(oauthClientId) + a.WithOauthClientSecret(oauthClientSecret) + return a +} + +func ApiAuthenticationIntegrationWithClientCredentialsWithDefaultMeta( + enabled bool, + name string, + oauthClientId string, + oauthClientSecret string, +) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a := &ApiAuthenticationIntegrationWithClientCredentialsModel{ResourceModelMeta: config.DefaultMeta(resources.ApiAuthenticationIntegrationWithClientCredentials)} + a.WithEnabled(enabled) + a.WithName(name) + a.WithOauthClientId(oauthClientId) + a.WithOauthClientSecret(oauthClientSecret) + return a +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) MarshalJSON() ([]byte, error) { + type Alias ApiAuthenticationIntegrationWithClientCredentialsModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(a), + DependsOn: a.DependsOn(), + }) +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithDependsOn(values ...string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.SetDependsOn(values...) + return a +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithComment(comment string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Comment = tfconfig.StringVariable(comment) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithEnabled(enabled bool) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Enabled = tfconfig.BoolVariable(enabled) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithFullyQualifiedName(fullyQualifiedName string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithName(name string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Name = tfconfig.StringVariable(name) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthAccessTokenValidity(oauthAccessTokenValidity int) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthAccessTokenValidity = tfconfig.IntegerVariable(oauthAccessTokenValidity) + return a +} + +// oauth_allowed_scopes attribute type is not yet supported, so WithOauthAllowedScopes can't be generated + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientAuthMethod(oauthClientAuthMethod string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientAuthMethod = tfconfig.StringVariable(oauthClientAuthMethod) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientId(oauthClientId string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientId = tfconfig.StringVariable(oauthClientId) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientSecret(oauthClientSecret string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientSecret = tfconfig.StringVariable(oauthClientSecret) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthRefreshTokenValidity(oauthRefreshTokenValidity int) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthRefreshTokenValidity = tfconfig.IntegerVariable(oauthRefreshTokenValidity) + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthTokenEndpoint(oauthTokenEndpoint string) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthTokenEndpoint = tfconfig.StringVariable(oauthTokenEndpoint) + return a +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithCommentValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Comment = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithEnabledValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Enabled = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.FullyQualifiedName = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithNameValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.Name = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthAccessTokenValidityValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthAccessTokenValidity = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthAllowedScopesValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthAllowedScopes = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientAuthMethodValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientAuthMethod = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientIdValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientId = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthClientSecretValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthClientSecret = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthRefreshTokenValidityValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthRefreshTokenValidity = value + return a +} + +func (a *ApiAuthenticationIntegrationWithClientCredentialsModel) WithOauthTokenEndpointValue(value tfconfig.Variable) *ApiAuthenticationIntegrationWithClientCredentialsModel { + a.OauthTokenEndpoint = value + return a +} diff --git a/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_ext.go new file mode 100644 index 0000000000..67a5ff88a9 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_ext.go @@ -0,0 +1,42 @@ +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +// WithExternalOauthTokenUserMappingClaim was added to satisfy the default builders. The method itself is not generated because its type is not yet supported. +// This method will conflict the generated one when the type is supported. +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthTokenUserMappingClaim(externalOauthTokenUserMappingClaim string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthTokenUserMappingClaim = tfconfig.SetVariable(tfconfig.StringVariable(externalOauthTokenUserMappingClaim)) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAllowedRoles(roles ...sdk.AccountObjectIdentifier) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAllowedRolesList = tfconfig.SetVariable( + collections.Map(roles, func(role sdk.AccountObjectIdentifier) tfconfig.Variable { + return tfconfig.StringVariable(role.Name()) + })..., + ) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAudiences(values ...string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAudienceList = tfconfig.SetVariable( + collections.Map(values, func(value string) tfconfig.Variable { + return tfconfig.StringVariable(value) + })..., + ) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthJwsKeysUrls(urls ...string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthJwsKeysUrl = tfconfig.SetVariable( + collections.Map(urls, func(url string) tfconfig.Variable { + return tfconfig.StringVariable(url) + })..., + ) + return e +} diff --git a/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_gen.go new file mode 100644 index 0000000000..b4987e16f8 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/external_oauth_security_integration_model_gen.go @@ -0,0 +1,266 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type ExternalOauthSecurityIntegrationModel struct { + Comment tfconfig.Variable `json:"comment,omitempty"` + Enabled tfconfig.Variable `json:"enabled,omitempty"` + ExternalOauthAllowedRolesList tfconfig.Variable `json:"external_oauth_allowed_roles_list,omitempty"` + ExternalOauthAnyRoleMode tfconfig.Variable `json:"external_oauth_any_role_mode,omitempty"` + ExternalOauthAudienceList tfconfig.Variable `json:"external_oauth_audience_list,omitempty"` + ExternalOauthBlockedRolesList tfconfig.Variable `json:"external_oauth_blocked_roles_list,omitempty"` + ExternalOauthIssuer tfconfig.Variable `json:"external_oauth_issuer,omitempty"` + ExternalOauthJwsKeysUrl tfconfig.Variable `json:"external_oauth_jws_keys_url,omitempty"` + ExternalOauthRsaPublicKey tfconfig.Variable `json:"external_oauth_rsa_public_key,omitempty"` + ExternalOauthRsaPublicKey2 tfconfig.Variable `json:"external_oauth_rsa_public_key_2,omitempty"` + ExternalOauthScopeDelimiter tfconfig.Variable `json:"external_oauth_scope_delimiter,omitempty"` + ExternalOauthScopeMappingAttribute tfconfig.Variable `json:"external_oauth_scope_mapping_attribute,omitempty"` + ExternalOauthSnowflakeUserMappingAttribute tfconfig.Variable `json:"external_oauth_snowflake_user_mapping_attribute,omitempty"` + ExternalOauthTokenUserMappingClaim tfconfig.Variable `json:"external_oauth_token_user_mapping_claim,omitempty"` + ExternalOauthType tfconfig.Variable `json:"external_oauth_type,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + RelatedParameters tfconfig.Variable `json:"related_parameters,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ExternalOauthSecurityIntegration( + resourceName string, + enabled bool, + externalOauthIssuer string, + externalOauthSnowflakeUserMappingAttribute string, + externalOauthTokenUserMappingClaim, + externalOauthType string, + name string, +) *ExternalOauthSecurityIntegrationModel { + e := &ExternalOauthSecurityIntegrationModel{ResourceModelMeta: config.Meta(resourceName, resources.ExternalOauthSecurityIntegration)} + e.WithEnabled(enabled) + e.WithExternalOauthIssuer(externalOauthIssuer) + e.WithExternalOauthSnowflakeUserMappingAttribute(externalOauthSnowflakeUserMappingAttribute) + e.WithExternalOauthTokenUserMappingClaim(externalOauthTokenUserMappingClaim) + e.WithExternalOauthType(externalOauthType) + e.WithName(name) + return e +} + +func ExternalOauthSecurityIntegrationWithDefaultMeta( + enabled bool, + externalOauthIssuer string, + externalOauthSnowflakeUserMappingAttribute string, + externalOauthTokenUserMappingClaim, + externalOauthType string, + name string, +) *ExternalOauthSecurityIntegrationModel { + e := &ExternalOauthSecurityIntegrationModel{ResourceModelMeta: config.DefaultMeta(resources.ExternalOauthSecurityIntegration)} + e.WithEnabled(enabled) + e.WithExternalOauthIssuer(externalOauthIssuer) + e.WithExternalOauthSnowflakeUserMappingAttribute(externalOauthSnowflakeUserMappingAttribute) + e.WithExternalOauthTokenUserMappingClaim(externalOauthTokenUserMappingClaim) + e.WithExternalOauthType(externalOauthType) + e.WithName(name) + return e +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (e *ExternalOauthSecurityIntegrationModel) MarshalJSON() ([]byte, error) { + type Alias ExternalOauthSecurityIntegrationModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(e), + DependsOn: e.DependsOn(), + }) +} + +func (e *ExternalOauthSecurityIntegrationModel) WithDependsOn(values ...string) *ExternalOauthSecurityIntegrationModel { + e.SetDependsOn(values...) + return e +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (e *ExternalOauthSecurityIntegrationModel) WithComment(comment string) *ExternalOauthSecurityIntegrationModel { + e.Comment = tfconfig.StringVariable(comment) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithEnabled(enabled bool) *ExternalOauthSecurityIntegrationModel { + e.Enabled = tfconfig.BoolVariable(enabled) + return e +} + +// external_oauth_allowed_roles_list attribute type is not yet supported, so WithExternalOauthAllowedRolesList can't be generated + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAnyRoleMode(externalOauthAnyRoleMode string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAnyRoleMode = tfconfig.StringVariable(externalOauthAnyRoleMode) + return e +} + +// external_oauth_audience_list attribute type is not yet supported, so WithExternalOauthAudienceList can't be generated + +// external_oauth_blocked_roles_list attribute type is not yet supported, so WithExternalOauthBlockedRolesList can't be generated + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthIssuer(externalOauthIssuer string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthIssuer = tfconfig.StringVariable(externalOauthIssuer) + return e +} + +// external_oauth_jws_keys_url attribute type is not yet supported, so WithExternalOauthJwsKeysUrl can't be generated + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthRsaPublicKey(externalOauthRsaPublicKey string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthRsaPublicKey = tfconfig.StringVariable(externalOauthRsaPublicKey) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthRsaPublicKey2(externalOauthRsaPublicKey2 string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthRsaPublicKey2 = tfconfig.StringVariable(externalOauthRsaPublicKey2) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthScopeDelimiter(externalOauthScopeDelimiter string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthScopeDelimiter = tfconfig.StringVariable(externalOauthScopeDelimiter) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthScopeMappingAttribute(externalOauthScopeMappingAttribute string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthScopeMappingAttribute = tfconfig.StringVariable(externalOauthScopeMappingAttribute) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthSnowflakeUserMappingAttribute(externalOauthSnowflakeUserMappingAttribute string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthSnowflakeUserMappingAttribute = tfconfig.StringVariable(externalOauthSnowflakeUserMappingAttribute) + return e +} + +// external_oauth_token_user_mapping_claim attribute type is not yet supported, so WithExternalOauthTokenUserMappingClaim can't be generated + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthType(externalOauthType string) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthType = tfconfig.StringVariable(externalOauthType) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithFullyQualifiedName(fullyQualifiedName string) *ExternalOauthSecurityIntegrationModel { + e.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithName(name string) *ExternalOauthSecurityIntegrationModel { + e.Name = tfconfig.StringVariable(name) + return e +} + +// related_parameters attribute type is not yet supported, so WithRelatedParameters can't be generated + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (e *ExternalOauthSecurityIntegrationModel) WithCommentValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.Comment = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithEnabledValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.Enabled = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAllowedRolesListValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAllowedRolesList = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAnyRoleModeValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAnyRoleMode = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthAudienceListValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthAudienceList = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthBlockedRolesListValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthBlockedRolesList = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthIssuerValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthIssuer = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthJwsKeysUrlValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthJwsKeysUrl = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthRsaPublicKeyValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthRsaPublicKey = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthRsaPublicKey2Value(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthRsaPublicKey2 = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthScopeDelimiterValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthScopeDelimiter = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthScopeMappingAttributeValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthScopeMappingAttribute = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthSnowflakeUserMappingAttributeValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthSnowflakeUserMappingAttribute = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthTokenUserMappingClaimValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthTokenUserMappingClaim = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithExternalOauthTypeValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.ExternalOauthType = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.FullyQualifiedName = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithNameValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.Name = value + return e +} + +func (e *ExternalOauthSecurityIntegrationModel) WithRelatedParametersValue(value tfconfig.Variable) *ExternalOauthSecurityIntegrationModel { + e.RelatedParameters = value + return e +} diff --git a/pkg/acceptance/bettertestspoc/config/model/gen/multiline_attributes_overrides.go b/pkg/acceptance/bettertestspoc/config/model/gen/multiline_attributes_overrides.go index a3f188f6ee..bc93bbc9a8 100644 --- a/pkg/acceptance/bettertestspoc/config/model/gen/multiline_attributes_overrides.go +++ b/pkg/acceptance/bettertestspoc/config/model/gen/multiline_attributes_overrides.go @@ -1,18 +1,20 @@ package gen var multilineAttributesOverrides = map[string][]string{ - "User": {"rsa_public_key", "rsa_public_key_2"}, - "ServiceUser": {"rsa_public_key", "rsa_public_key_2"}, - "LegacyServiceUser": {"rsa_public_key", "rsa_public_key_2"}, - "FunctionJava": {"function_definition"}, - "FunctionJavascript": {"function_definition"}, - "FunctionPython": {"function_definition"}, - "FunctionScala": {"function_definition"}, - "FunctionSql": {"function_definition"}, - "ProcedureJava": {"procedure_definition"}, - "ProcedureJavascript": {"procedure_definition"}, - "ProcedurePython": {"procedure_definition"}, - "ProcedureScala": {"procedure_definition"}, - "ProcedureSql": {"procedure_definition"}, - "Account": {"admin_rsa_public_key"}, + "User": {"rsa_public_key", "rsa_public_key_2"}, + "ServiceUser": {"rsa_public_key", "rsa_public_key_2"}, + "LegacyServiceUser": {"rsa_public_key", "rsa_public_key_2"}, + "FunctionJava": {"function_definition"}, + "FunctionJavascript": {"function_definition"}, + "FunctionPython": {"function_definition"}, + "FunctionScala": {"function_definition"}, + "FunctionSql": {"function_definition"}, + "ProcedureJava": {"procedure_definition"}, + "ProcedureJavascript": {"procedure_definition"}, + "ProcedurePython": {"procedure_definition"}, + "ProcedureScala": {"procedure_definition"}, + "ProcedureSql": {"procedure_definition"}, + "Account": {"admin_rsa_public_key"}, + "Saml2SecurityIntegration": {"saml2_x509_cert"}, + "OauthIntegrationForCustomClients": {"oauth_client_rsa_public_key", "oauth_client_rsa_public_key_2"}, } diff --git a/pkg/acceptance/bettertestspoc/config/model/network_policy_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/network_policy_model_ext.go new file mode 100644 index 0000000000..71c14d1ce4 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/network_policy_model_ext.go @@ -0,0 +1,44 @@ +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +func (n *NetworkPolicyModel) WithAllowedNetworkRules(rules ...sdk.SchemaObjectIdentifier) *NetworkPolicyModel { + return n.WithAllowedNetworkRuleListValue( + tfconfig.SetVariable( + collections.Map(rules, func(rule sdk.SchemaObjectIdentifier) tfconfig.Variable { + return tfconfig.StringVariable(rule.FullyQualifiedName()) + })..., + ), + ) +} + +func (n *NetworkPolicyModel) WithBlockedNetworkRules(rules ...sdk.SchemaObjectIdentifier) *NetworkPolicyModel { + return n.WithBlockedNetworkRuleListValue( + tfconfig.SetVariable( + collections.Map(rules, func(rule sdk.SchemaObjectIdentifier) tfconfig.Variable { + return tfconfig.StringVariable(rule.FullyQualifiedName()) + })..., + ), + ) +} + +func (n *NetworkPolicyModel) WithAllowedIps(ips ...string) *NetworkPolicyModel { + return n.WithAllowedIpListValue( + tfconfig.SetVariable( + collections.Map(ips, func(ip string) tfconfig.Variable { return tfconfig.StringVariable(ip) })..., + ), + ) +} + +func (n *NetworkPolicyModel) WithBlockedIps(ips ...string) *NetworkPolicyModel { + return n.WithBlockedIpListValue( + tfconfig.SetVariable( + collections.Map(ips, func(ip string) tfconfig.Variable { return tfconfig.StringVariable(ip) })..., + ), + ) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/network_policy_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/network_policy_model_gen.go new file mode 100644 index 0000000000..2ade3d4605 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/network_policy_model_gen.go @@ -0,0 +1,131 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type NetworkPolicyModel struct { + AllowedIpList tfconfig.Variable `json:"allowed_ip_list,omitempty"` + AllowedNetworkRuleList tfconfig.Variable `json:"allowed_network_rule_list,omitempty"` + BlockedIpList tfconfig.Variable `json:"blocked_ip_list,omitempty"` + BlockedNetworkRuleList tfconfig.Variable `json:"blocked_network_rule_list,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func NetworkPolicy( + resourceName string, + name string, +) *NetworkPolicyModel { + n := &NetworkPolicyModel{ResourceModelMeta: config.Meta(resourceName, resources.NetworkPolicy)} + n.WithName(name) + return n +} + +func NetworkPolicyWithDefaultMeta( + name string, +) *NetworkPolicyModel { + n := &NetworkPolicyModel{ResourceModelMeta: config.DefaultMeta(resources.NetworkPolicy)} + n.WithName(name) + return n +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (n *NetworkPolicyModel) MarshalJSON() ([]byte, error) { + type Alias NetworkPolicyModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(n), + DependsOn: n.DependsOn(), + }) +} + +func (n *NetworkPolicyModel) WithDependsOn(values ...string) *NetworkPolicyModel { + n.SetDependsOn(values...) + return n +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// allowed_ip_list attribute type is not yet supported, so WithAllowedIpList can't be generated + +// allowed_network_rule_list attribute type is not yet supported, so WithAllowedNetworkRuleList can't be generated + +// blocked_ip_list attribute type is not yet supported, so WithBlockedIpList can't be generated + +// blocked_network_rule_list attribute type is not yet supported, so WithBlockedNetworkRuleList can't be generated + +func (n *NetworkPolicyModel) WithComment(comment string) *NetworkPolicyModel { + n.Comment = tfconfig.StringVariable(comment) + return n +} + +func (n *NetworkPolicyModel) WithFullyQualifiedName(fullyQualifiedName string) *NetworkPolicyModel { + n.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return n +} + +func (n *NetworkPolicyModel) WithName(name string) *NetworkPolicyModel { + n.Name = tfconfig.StringVariable(name) + return n +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (n *NetworkPolicyModel) WithAllowedIpListValue(value tfconfig.Variable) *NetworkPolicyModel { + n.AllowedIpList = value + return n +} + +func (n *NetworkPolicyModel) WithAllowedNetworkRuleListValue(value tfconfig.Variable) *NetworkPolicyModel { + n.AllowedNetworkRuleList = value + return n +} + +func (n *NetworkPolicyModel) WithBlockedIpListValue(value tfconfig.Variable) *NetworkPolicyModel { + n.BlockedIpList = value + return n +} + +func (n *NetworkPolicyModel) WithBlockedNetworkRuleListValue(value tfconfig.Variable) *NetworkPolicyModel { + n.BlockedNetworkRuleList = value + return n +} + +func (n *NetworkPolicyModel) WithCommentValue(value tfconfig.Variable) *NetworkPolicyModel { + n.Comment = value + return n +} + +func (n *NetworkPolicyModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *NetworkPolicyModel { + n.FullyQualifiedName = value + return n +} + +func (n *NetworkPolicyModel) WithNameValue(value tfconfig.Variable) *NetworkPolicyModel { + n.Name = value + return n +} diff --git a/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_ext.go index 3d3605ca78..8a29b4ce3a 100644 --- a/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_ext.go +++ b/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_ext.go @@ -2,6 +2,9 @@ package model import ( tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" ) func (t *OauthIntegrationForCustomClientsModel) WithBlockedRolesList(blockedRoles ...string) *OauthIntegrationForCustomClientsModel { @@ -13,3 +16,12 @@ func (t *OauthIntegrationForCustomClientsModel) WithBlockedRolesList(blockedRole t.BlockedRolesList = tfconfig.SetVariable(blockedRolesListStringVariables...) return t } + +func (t *OauthIntegrationForCustomClientsModel) WithPreAuthorizedRoles(roles ...sdk.AccountObjectIdentifier) *OauthIntegrationForCustomClientsModel { + t.PreAuthorizedRolesList = tfconfig.SetVariable( + collections.Map(roles, func(role sdk.AccountObjectIdentifier) tfconfig.Variable { + return tfconfig.StringVariable(role.Name()) + })..., + ) + return t +} diff --git a/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_gen.go index dac9701685..62752e5b06 100644 --- a/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_gen.go +++ b/pkg/acceptance/bettertestspoc/config/model/oauth_integration_for_custom_clients_model_gen.go @@ -119,12 +119,12 @@ func (o *OauthIntegrationForCustomClientsModel) WithOauthAllowNonTlsRedirectUri( } func (o *OauthIntegrationForCustomClientsModel) WithOauthClientRsaPublicKey(oauthClientRsaPublicKey string) *OauthIntegrationForCustomClientsModel { - o.OauthClientRsaPublicKey = tfconfig.StringVariable(oauthClientRsaPublicKey) + o.OauthClientRsaPublicKey = config.MultilineWrapperVariable(oauthClientRsaPublicKey) return o } func (o *OauthIntegrationForCustomClientsModel) WithOauthClientRsaPublicKey2(oauthClientRsaPublicKey2 string) *OauthIntegrationForCustomClientsModel { - o.OauthClientRsaPublicKey2 = tfconfig.StringVariable(oauthClientRsaPublicKey2) + o.OauthClientRsaPublicKey2 = config.MultilineWrapperVariable(oauthClientRsaPublicKey2) return o } diff --git a/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_ext.go new file mode 100644 index 0000000000..8de42dee24 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_ext.go @@ -0,0 +1,25 @@ +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" +) + +func (s *Saml2SecurityIntegrationModel) WithAllowedEmailPatterns(values ...string) *Saml2SecurityIntegrationModel { + s.AllowedEmailPatterns = tfconfig.SetVariable( + collections.Map(values, func(value string) tfconfig.Variable { + return tfconfig.StringVariable(value) + })..., + ) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithAllowedUserDomains(values ...string) *Saml2SecurityIntegrationModel { + s.AllowedUserDomains = tfconfig.SetVariable( + collections.Map(values, func(value string) tfconfig.Variable { + return tfconfig.StringVariable(value) + })..., + ) + return s +} diff --git a/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_gen.go new file mode 100644 index 0000000000..c768f1acc9 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/saml2_security_integration_model_gen.go @@ -0,0 +1,274 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type Saml2SecurityIntegrationModel struct { + AllowedEmailPatterns tfconfig.Variable `json:"allowed_email_patterns,omitempty"` + AllowedUserDomains tfconfig.Variable `json:"allowed_user_domains,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Enabled tfconfig.Variable `json:"enabled,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + Saml2EnableSpInitiated tfconfig.Variable `json:"saml2_enable_sp_initiated,omitempty"` + Saml2ForceAuthn tfconfig.Variable `json:"saml2_force_authn,omitempty"` + Saml2Issuer tfconfig.Variable `json:"saml2_issuer,omitempty"` + Saml2PostLogoutRedirectUrl tfconfig.Variable `json:"saml2_post_logout_redirect_url,omitempty"` + Saml2Provider tfconfig.Variable `json:"saml2_provider,omitempty"` + Saml2RequestedNameidFormat tfconfig.Variable `json:"saml2_requested_nameid_format,omitempty"` + Saml2SignRequest tfconfig.Variable `json:"saml2_sign_request,omitempty"` + Saml2SnowflakeAcsUrl tfconfig.Variable `json:"saml2_snowflake_acs_url,omitempty"` + Saml2SnowflakeIssuerUrl tfconfig.Variable `json:"saml2_snowflake_issuer_url,omitempty"` + Saml2SpInitiatedLoginPageLabel tfconfig.Variable `json:"saml2_sp_initiated_login_page_label,omitempty"` + Saml2SsoUrl tfconfig.Variable `json:"saml2_sso_url,omitempty"` + Saml2X509Cert tfconfig.Variable `json:"saml2_x509_cert,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func Saml2SecurityIntegration( + resourceName string, + name string, + saml2Issuer string, + saml2Provider string, + saml2SsoUrl string, + saml2X509Cert string, +) *Saml2SecurityIntegrationModel { + s := &Saml2SecurityIntegrationModel{ResourceModelMeta: config.Meta(resourceName, resources.Saml2SecurityIntegration)} + s.WithName(name) + s.WithSaml2Issuer(saml2Issuer) + s.WithSaml2Provider(saml2Provider) + s.WithSaml2SsoUrl(saml2SsoUrl) + s.WithSaml2X509Cert(saml2X509Cert) + return s +} + +func Saml2SecurityIntegrationWithDefaultMeta( + name string, + saml2Issuer string, + saml2Provider string, + saml2SsoUrl string, + saml2X509Cert string, +) *Saml2SecurityIntegrationModel { + s := &Saml2SecurityIntegrationModel{ResourceModelMeta: config.DefaultMeta(resources.Saml2SecurityIntegration)} + s.WithName(name) + s.WithSaml2Issuer(saml2Issuer) + s.WithSaml2Provider(saml2Provider) + s.WithSaml2SsoUrl(saml2SsoUrl) + s.WithSaml2X509Cert(saml2X509Cert) + return s +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (s *Saml2SecurityIntegrationModel) MarshalJSON() ([]byte, error) { + type Alias Saml2SecurityIntegrationModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(s), + DependsOn: s.DependsOn(), + }) +} + +func (s *Saml2SecurityIntegrationModel) WithDependsOn(values ...string) *Saml2SecurityIntegrationModel { + s.SetDependsOn(values...) + return s +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// allowed_email_patterns attribute type is not yet supported, so WithAllowedEmailPatterns can't be generated + +// allowed_user_domains attribute type is not yet supported, so WithAllowedUserDomains can't be generated + +func (s *Saml2SecurityIntegrationModel) WithComment(comment string) *Saml2SecurityIntegrationModel { + s.Comment = tfconfig.StringVariable(comment) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithEnabled(enabled string) *Saml2SecurityIntegrationModel { + s.Enabled = tfconfig.StringVariable(enabled) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithFullyQualifiedName(fullyQualifiedName string) *Saml2SecurityIntegrationModel { + s.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithName(name string) *Saml2SecurityIntegrationModel { + s.Name = tfconfig.StringVariable(name) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2EnableSpInitiated(saml2EnableSpInitiated string) *Saml2SecurityIntegrationModel { + s.Saml2EnableSpInitiated = tfconfig.StringVariable(saml2EnableSpInitiated) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2ForceAuthn(saml2ForceAuthn string) *Saml2SecurityIntegrationModel { + s.Saml2ForceAuthn = tfconfig.StringVariable(saml2ForceAuthn) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2Issuer(saml2Issuer string) *Saml2SecurityIntegrationModel { + s.Saml2Issuer = tfconfig.StringVariable(saml2Issuer) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2PostLogoutRedirectUrl(saml2PostLogoutRedirectUrl string) *Saml2SecurityIntegrationModel { + s.Saml2PostLogoutRedirectUrl = tfconfig.StringVariable(saml2PostLogoutRedirectUrl) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2Provider(saml2Provider string) *Saml2SecurityIntegrationModel { + s.Saml2Provider = tfconfig.StringVariable(saml2Provider) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2RequestedNameidFormat(saml2RequestedNameidFormat string) *Saml2SecurityIntegrationModel { + s.Saml2RequestedNameidFormat = tfconfig.StringVariable(saml2RequestedNameidFormat) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SignRequest(saml2SignRequest string) *Saml2SecurityIntegrationModel { + s.Saml2SignRequest = tfconfig.StringVariable(saml2SignRequest) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SnowflakeAcsUrl(saml2SnowflakeAcsUrl string) *Saml2SecurityIntegrationModel { + s.Saml2SnowflakeAcsUrl = tfconfig.StringVariable(saml2SnowflakeAcsUrl) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SnowflakeIssuerUrl(saml2SnowflakeIssuerUrl string) *Saml2SecurityIntegrationModel { + s.Saml2SnowflakeIssuerUrl = tfconfig.StringVariable(saml2SnowflakeIssuerUrl) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SpInitiatedLoginPageLabel(saml2SpInitiatedLoginPageLabel string) *Saml2SecurityIntegrationModel { + s.Saml2SpInitiatedLoginPageLabel = tfconfig.StringVariable(saml2SpInitiatedLoginPageLabel) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SsoUrl(saml2SsoUrl string) *Saml2SecurityIntegrationModel { + s.Saml2SsoUrl = tfconfig.StringVariable(saml2SsoUrl) + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2X509Cert(saml2X509Cert string) *Saml2SecurityIntegrationModel { + s.Saml2X509Cert = config.MultilineWrapperVariable(saml2X509Cert) + return s +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (s *Saml2SecurityIntegrationModel) WithAllowedEmailPatternsValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.AllowedEmailPatterns = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithAllowedUserDomainsValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.AllowedUserDomains = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithCommentValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Comment = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithEnabledValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Enabled = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.FullyQualifiedName = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithNameValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Name = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2EnableSpInitiatedValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2EnableSpInitiated = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2ForceAuthnValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2ForceAuthn = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2IssuerValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2Issuer = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2PostLogoutRedirectUrlValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2PostLogoutRedirectUrl = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2ProviderValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2Provider = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2RequestedNameidFormatValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2RequestedNameidFormat = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SignRequestValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2SignRequest = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SnowflakeAcsUrlValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2SnowflakeAcsUrl = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SnowflakeIssuerUrlValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2SnowflakeIssuerUrl = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SpInitiatedLoginPageLabelValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2SpInitiatedLoginPageLabel = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2SsoUrlValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2SsoUrl = value + return s +} + +func (s *Saml2SecurityIntegrationModel) WithSaml2X509CertValue(value tfconfig.Variable) *Saml2SecurityIntegrationModel { + s.Saml2X509Cert = value + return s +} diff --git a/pkg/acceptance/bettertestspoc/config/model/scim_security_integration_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/scim_security_integration_model_gen.go new file mode 100644 index 0000000000..e41068f172 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/scim_security_integration_model_gen.go @@ -0,0 +1,166 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + "encoding/json" + + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type ScimSecurityIntegrationModel struct { + Comment tfconfig.Variable `json:"comment,omitempty"` + Enabled tfconfig.Variable `json:"enabled,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NetworkPolicy tfconfig.Variable `json:"network_policy,omitempty"` + RunAsRole tfconfig.Variable `json:"run_as_role,omitempty"` + ScimClient tfconfig.Variable `json:"scim_client,omitempty"` + SyncPassword tfconfig.Variable `json:"sync_password,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ScimSecurityIntegration( + resourceName string, + enabled bool, + name string, + runAsRole string, + scimClient string, +) *ScimSecurityIntegrationModel { + s := &ScimSecurityIntegrationModel{ResourceModelMeta: config.Meta(resourceName, resources.ScimSecurityIntegration)} + s.WithEnabled(enabled) + s.WithName(name) + s.WithRunAsRole(runAsRole) + s.WithScimClient(scimClient) + return s +} + +func ScimSecurityIntegrationWithDefaultMeta( + enabled bool, + name string, + runAsRole string, + scimClient string, +) *ScimSecurityIntegrationModel { + s := &ScimSecurityIntegrationModel{ResourceModelMeta: config.DefaultMeta(resources.ScimSecurityIntegration)} + s.WithEnabled(enabled) + s.WithName(name) + s.WithRunAsRole(runAsRole) + s.WithScimClient(scimClient) + return s +} + +/////////////////////////////////////////////////////// +// set proper json marshalling and handle depends on // +/////////////////////////////////////////////////////// + +func (s *ScimSecurityIntegrationModel) MarshalJSON() ([]byte, error) { + type Alias ScimSecurityIntegrationModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(s), + DependsOn: s.DependsOn(), + }) +} + +func (s *ScimSecurityIntegrationModel) WithDependsOn(values ...string) *ScimSecurityIntegrationModel { + s.SetDependsOn(values...) + return s +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (s *ScimSecurityIntegrationModel) WithComment(comment string) *ScimSecurityIntegrationModel { + s.Comment = tfconfig.StringVariable(comment) + return s +} + +func (s *ScimSecurityIntegrationModel) WithEnabled(enabled bool) *ScimSecurityIntegrationModel { + s.Enabled = tfconfig.BoolVariable(enabled) + return s +} + +func (s *ScimSecurityIntegrationModel) WithFullyQualifiedName(fullyQualifiedName string) *ScimSecurityIntegrationModel { + s.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return s +} + +func (s *ScimSecurityIntegrationModel) WithName(name string) *ScimSecurityIntegrationModel { + s.Name = tfconfig.StringVariable(name) + return s +} + +func (s *ScimSecurityIntegrationModel) WithNetworkPolicy(networkPolicy string) *ScimSecurityIntegrationModel { + s.NetworkPolicy = tfconfig.StringVariable(networkPolicy) + return s +} + +func (s *ScimSecurityIntegrationModel) WithRunAsRole(runAsRole string) *ScimSecurityIntegrationModel { + s.RunAsRole = tfconfig.StringVariable(runAsRole) + return s +} + +func (s *ScimSecurityIntegrationModel) WithScimClient(scimClient string) *ScimSecurityIntegrationModel { + s.ScimClient = tfconfig.StringVariable(scimClient) + return s +} + +func (s *ScimSecurityIntegrationModel) WithSyncPassword(syncPassword string) *ScimSecurityIntegrationModel { + s.SyncPassword = tfconfig.StringVariable(syncPassword) + return s +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (s *ScimSecurityIntegrationModel) WithCommentValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.Comment = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithEnabledValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.Enabled = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.FullyQualifiedName = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithNameValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.Name = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithNetworkPolicyValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.NetworkPolicy = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithRunAsRoleValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.RunAsRole = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithScimClientValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.ScimClient = value + return s +} + +func (s *ScimSecurityIntegrationModel) WithSyncPasswordValue(value tfconfig.Variable) *ScimSecurityIntegrationModel { + s.SyncPassword = value + return s +} diff --git a/pkg/acceptance/helpers/database_client.go b/pkg/acceptance/helpers/database_client.go index a0ea93ebab..df47c09f56 100644 --- a/pkg/acceptance/helpers/database_client.go +++ b/pkg/acceptance/helpers/database_client.go @@ -30,6 +30,17 @@ func (c *DatabaseClient) CreateDatabase(t *testing.T) (*sdk.Database, func()) { return c.CreateDatabaseWithOptions(t, c.ids.RandomAccountObjectIdentifier(), &sdk.CreateDatabaseOptions{}) } +// DatabaseWithParametersSet should be used to create database which sets the parameters that can be altered on the account level in other tests; this way, the test is not affected by the changes. +func (c *DatabaseClient) DatabaseWithParametersSet(t *testing.T) (*sdk.Database, func()) { + t.Helper() + return c.CreateDatabaseWithOptions(t, c.ids.RandomAccountObjectIdentifier(), &sdk.CreateDatabaseOptions{ + DataRetentionTimeInDays: sdk.Int(1), + MaxDataExtensionTimeInDays: sdk.Int(1), + // according to the docs SNOWFLAKE is a valid value (https://docs.snowflake.com/en/sql-reference/parameters#catalog) + Catalog: sdk.Pointer(sdk.NewAccountObjectIdentifier("SNOWFLAKE")), + }) +} + func (c *DatabaseClient) CreateDatabaseWithIdentifier(t *testing.T, id sdk.AccountObjectIdentifier) (*sdk.Database, func()) { t.Helper() return c.CreateDatabaseWithOptions(t, id, &sdk.CreateDatabaseOptions{}) diff --git a/pkg/datasources/file_formats_acceptance_test.go b/pkg/datasources/file_formats_acceptance_test.go index eca32a01d2..8309dac048 100644 --- a/pkg/datasources/file_formats_acceptance_test.go +++ b/pkg/datasources/file_formats_acceptance_test.go @@ -27,7 +27,7 @@ func TestAcc_FileFormats(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: fileFormats(fileFormatId), + Config: fileFormatsInSchema(fileFormatId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.snowflake_file_formats.t", "database", fileFormatId.DatabaseName()), resource.TestCheckResourceAttr("data.snowflake_file_formats.t", "schema", fileFormatId.SchemaName()), @@ -53,7 +53,7 @@ func TestAcc_FileFormatsEmpty(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: zeroFileFormats(), + Config: fileFormatsInSchemaWithoutCreation(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.snowflake_file_formats.t", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("data.snowflake_file_formats.t", "schema", acc.TestSchemaName), @@ -65,7 +65,7 @@ func TestAcc_FileFormatsEmpty(t *testing.T) { }) } -func fileFormats(fileFormatId sdk.SchemaObjectIdentifier) string { +func fileFormatsInSchema(fileFormatId sdk.SchemaObjectIdentifier) string { return fmt.Sprintf(` resource snowflake_file_format "t"{ name = "%[3]s" @@ -103,7 +103,7 @@ func fileFormats(fileFormatId sdk.SchemaObjectIdentifier) string { `, fileFormatId.DatabaseName(), fileFormatId.SchemaName(), fileFormatId.Name()) } -func zeroFileFormats() string { +func fileFormatsInSchemaWithoutCreation() string { return fmt.Sprintf(` data snowflake_file_formats "t" { database = "%[1]s" diff --git a/pkg/datasources/masking_policies_acceptance_test.go b/pkg/datasources/masking_policies_acceptance_test.go index 495e6ab61d..3e82b84e64 100644 --- a/pkg/datasources/masking_policies_acceptance_test.go +++ b/pkg/datasources/masking_policies_acceptance_test.go @@ -6,21 +6,25 @@ import ( "testing" acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + tfconfig "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert" - tfconfig "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config/model" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/snowflakeroles" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/hashicorp/terraform-plugin-testing/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAcc_MaskingPolicies(t *testing.T) { + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + id := acc.TestClient().Ids.RandomSchemaObjectIdentifier() body := "case when current_role() in ('ANALYST') then 'true' else 'false' end" @@ -96,6 +100,9 @@ func TestAcc_MaskingPolicies(t *testing.T) { } func TestAcc_MaskingPolicies_Filtering(t *testing.T) { + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + prefix := random.AlphaN(4) idOne := acc.TestClient().Ids.RandomAccountObjectIdentifierWithPrefix(prefix) idTwo := acc.TestClient().Ids.RandomAccountObjectIdentifierWithPrefix(prefix) diff --git a/pkg/datasources/materialized_views_acceptance_test.go b/pkg/datasources/materialized_views_acceptance_test.go index bf1e7524be..e04f090f67 100644 --- a/pkg/datasources/materialized_views_acceptance_test.go +++ b/pkg/datasources/materialized_views_acceptance_test.go @@ -6,13 +6,18 @@ import ( acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAcc_MaterializedViews(t *testing.T) { - tableName := acc.TestClient().Ids.Alpha() - viewName := acc.TestClient().Ids.Alpha() + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + + tableId := acc.TestClient().Ids.RandomSchemaObjectIdentifier() + viewId := acc.TestClient().Ids.RandomSchemaObjectIdentifier() resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, @@ -23,20 +28,20 @@ func TestAcc_MaterializedViews(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: materializedViews(acc.TestWarehouseName, acc.TestDatabaseName, acc.TestSchemaName, tableName, viewName), + Config: materializedViews(acc.TestWarehouseName, tableId, viewId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.snowflake_materialized_views.v", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("data.snowflake_materialized_views.v", "schema", acc.TestSchemaName), resource.TestCheckResourceAttrSet("data.snowflake_materialized_views.v", "materialized_views.#"), resource.TestCheckResourceAttr("data.snowflake_materialized_views.v", "materialized_views.#", "1"), - resource.TestCheckResourceAttr("data.snowflake_materialized_views.v", "materialized_views.0.name", viewName), + resource.TestCheckResourceAttr("data.snowflake_materialized_views.v", "materialized_views.0.name", viewId.Name()), ), }, }, }) } -func materializedViews(warehouseName string, databaseName string, schemaName string, tableName string, viewName string) string { +func materializedViews(warehouseName string, tableId sdk.SchemaObjectIdentifier, viewId sdk.SchemaObjectIdentifier) string { return fmt.Sprintf(` resource snowflake_table "t"{ name = "%[4]v" @@ -64,5 +69,5 @@ func materializedViews(warehouseName string, databaseName string, schemaName str schema = "%[3]s" depends_on = [snowflake_materialized_view.v] } - `, warehouseName, databaseName, schemaName, tableName, viewName) + `, warehouseName, tableId.DatabaseName(), tableId.SchemaName(), tableId.Name(), viewId.Name()) } diff --git a/pkg/datasources/network_policies_acceptance_test.go b/pkg/datasources/network_policies_acceptance_test.go index 57b5858290..889ce84754 100644 --- a/pkg/datasources/network_policies_acceptance_test.go +++ b/pkg/datasources/network_policies_acceptance_test.go @@ -1,19 +1,25 @@ package datasources_test import ( - "encoding/json" - "fmt" "regexp" "testing" acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + accconfig "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config/datasourcemodel" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config/model" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAcc_NetworkPolicies_Complete(t *testing.T) { + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() id2 := acc.TestClient().Ids.RandomAccountObjectIdentifier() comment := random.Comment() @@ -23,6 +29,29 @@ func TestAcc_NetworkPolicies_Complete(t *testing.T) { blockedNetworkRuleId1 := acc.TestClient().Ids.RandomSchemaObjectIdentifier() blockedNetworkRuleId2 := acc.TestClient().Ids.RandomSchemaObjectIdentifier() + networkPolicyModel1 := model.NetworkPolicy("test", id.Name()). + WithComment(comment). + WithAllowedNetworkRules(allowedNetworkRuleId1, allowedNetworkRuleId2). + WithBlockedNetworkRules(blockedNetworkRuleId1, blockedNetworkRuleId2). + WithAllowedIps("1.1.1.1", "2.2.2.2"). + WithBlockedIps("3.3.3.3", "4.4.4.4") + networkPolicyModel2 := model.NetworkPolicy("test2", id2.Name()) + networkPoliciesModel := datasourcemodel.NetworkPolicies("test"). + WithLike(id.Name()). + WithDependsOn(networkPolicyModel1.ResourceReference(), networkPolicyModel2.ResourceReference()) + networkPoliciesModel2WithDescribe := datasourcemodel.NetworkPolicies("test"). + WithWithDescribe(true). + WithLike(id2.Name()). + WithDependsOn(networkPolicyModel1.ResourceReference(), networkPolicyModel2.ResourceReference()) + networkPoliciesModel1WithDescribe := datasourcemodel.NetworkPolicies("test"). + WithWithDescribe(true). + WithLike(id.Name()). + WithDependsOn(networkPolicyModel1.ResourceReference(), networkPolicyModel2.ResourceReference()) + networkPoliciesModel1WithoutDescribe := datasourcemodel.NetworkPolicies("test"). + WithWithDescribe(false). + WithLike(id.Name()). + WithDependsOn(networkPolicyModel1.ResourceReference(), networkPolicyModel2.ResourceReference()) + resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -38,144 +67,81 @@ func TestAcc_NetworkPolicies_Complete(t *testing.T) { acc.TestClient().NetworkRule.CreateWithIdentifier(t, blockedNetworkRuleId1) acc.TestClient().NetworkRule.CreateWithIdentifier(t, blockedNetworkRuleId2) }, - Config: networkPolicyConfigComplete( - id.Name(), - []string{allowedNetworkRuleId1.FullyQualifiedName(), allowedNetworkRuleId2.FullyQualifiedName()}, - []string{blockedNetworkRuleId1.FullyQualifiedName(), blockedNetworkRuleId2.FullyQualifiedName()}, - []string{"1.1.1.1", "2.2.2.2"}, - []string{"3.3.3.3", "4.4.4.4"}, - comment, - id2.Name(), - ), + Config: accconfig.FromModels(t, networkPolicyModel1, networkPolicyModel2, networkPoliciesModel), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.#", "1"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.show_output.0.created_on"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.name", id.Name()), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_ip_list", "2"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_ip_list", "2"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_network_rules", "2"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_network_rules", "2"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.comment", comment), - - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.#", "1"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_ip_list"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_ip_list"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_network_rule_list"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_network_rule_list"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.created_on"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.name", id.Name()), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.comment", comment), + + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_ip_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_ip_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_network_rule_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_network_rule_list"), ), }, { - Config: networkPolicyConfigBasic(id.Name(), true), + Config: accconfig.FromModels(t, networkPolicyModel1, networkPolicyModel2, networkPoliciesModel1WithDescribe), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.#", "1"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.show_output.0.created_on"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.name", id.Name()), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.comment", ""), - - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.#", "1"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_ip_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_ip_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_network_rule_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_network_rule_list"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.created_on"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.name", id.Name()), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.comment", comment), + + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_ip_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_ip_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_network_rule_list"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_network_rule_list"), ), }, { - Config: networkPolicyConfigBasic(id2.Name(), true), + Config: accconfig.FromModels(t, networkPolicyModel1, networkPolicyModel2, networkPoliciesModel2WithDescribe), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.#", "1"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.show_output.0.created_on"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.name", id2.Name()), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.comment", ""), - - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.#", "1"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_ip_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_ip_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.allowed_network_rule_list"), - resource.TestCheckNoResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.0.blocked_network_rule_list"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.created_on"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.name", id2.Name()), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_ip_list", "0"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_ip_list", "0"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_network_rules", "0"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_network_rules", "0"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.comment", ""), + + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.#", "1"), + resource.TestCheckNoResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_ip_list"), + resource.TestCheckNoResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_ip_list"), + resource.TestCheckNoResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.allowed_network_rule_list"), + resource.TestCheckNoResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.0.blocked_network_rule_list"), ), }, { - Config: networkPolicyConfigBasic(id.Name(), false), + Config: accconfig.FromModels(t, networkPolicyModel1, networkPolicyModel2, networkPoliciesModel1WithoutDescribe), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.#", "1"), - resource.TestCheckResourceAttrSet("data.snowflake_network_policies.test", "network_policies.0.show_output.0.created_on"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.name", id.Name()), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_ip_list", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_allowed_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.entries_in_blocked_network_rules", "0"), - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.show_output.0.comment", ""), - - resource.TestCheckResourceAttr("data.snowflake_network_policies.test", "network_policies.0.describe_output.#", "0"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.#", "1"), + resource.TestCheckResourceAttrSet(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.created_on"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.name", id.Name()), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_ip_list", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_allowed_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.entries_in_blocked_network_rules", "2"), + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.show_output.0.comment", comment), + + resource.TestCheckResourceAttr(networkPoliciesModel.DatasourceReference(), "network_policies.0.describe_output.#", "0"), ), }, }, }) } -func networkPolicyConfigBasic(name string, withDescribe bool) string { - return fmt.Sprintf(` - resource "snowflake_network_policy" "test" { - name = "%v" - } - - data "snowflake_network_policies" "test" { - with_describe = %t - like = snowflake_network_policy.test.name - } -`, name, withDescribe) -} - -func networkPolicyConfigComplete( - name string, - allowedRuleList []string, - blockedRuleList []string, - allowedIpList []string, - blockedIpList []string, - comment string, - name2 string, -) string { - allowedRuleListBytes, _ := json.Marshal(allowedRuleList) - blockedRuleListBytes, _ := json.Marshal(blockedRuleList) - allowedIpListBytes, _ := json.Marshal(allowedIpList) - blockedIpListBytes, _ := json.Marshal(blockedIpList) - - return fmt.Sprintf(` - resource "snowflake_network_policy" "test" { - name = "%[1]s" - allowed_network_rule_list = %[2]s - blocked_network_rule_list = %[3]s - allowed_ip_list = %[4]s - blocked_ip_list = %[5]s - comment = "%[6]s" - } - - resource "snowflake_network_policy" "test2" { - name = "%[7]s" - } - - data "snowflake_network_policies" "test" { - like = snowflake_network_policy.test.name - } -`, - name, - string(allowedRuleListBytes), - string(blockedRuleListBytes), - string(allowedIpListBytes), - string(blockedIpListBytes), - comment, - name2, - ) -} - func TestAcc_NetworkPolicies_NetworkPolicyNotFound_WithPostConditions(t *testing.T) { resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, diff --git a/pkg/datasources/parameters_acceptance_test.go b/pkg/datasources/parameters_acceptance_test.go index 9fbef94d26..423e29efa6 100644 --- a/pkg/datasources/parameters_acceptance_test.go +++ b/pkg/datasources/parameters_acceptance_test.go @@ -6,6 +6,8 @@ import ( acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) @@ -33,7 +35,11 @@ func TestAcc_ParametersOnAccount(t *testing.T) { } func TestAcc_ParametersOnSession(t *testing.T) { - userName := acc.TestClient().Ids.Alpha() + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + + userId := acc.TestClient().Context.CurrentUser(t) + resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -43,12 +49,12 @@ func TestAcc_ParametersOnSession(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: parametersConfigOnSession(userName), + Config: parametersConfigOnSession(userId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.#"), resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.key"), resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.value"), - resource.TestCheckResourceAttr("data.snowflake_parameters.p", "user", userName), + resource.TestCheckResourceAttr("data.snowflake_parameters.p", "user", userId.Name()), ), }, }, @@ -56,7 +62,11 @@ func TestAcc_ParametersOnSession(t *testing.T) { } func TestAcc_ParametersOnObject(t *testing.T) { - dbName := acc.TestClient().Ids.Alpha() + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + + dbId := acc.TestClient().Ids.DatabaseId() + resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -66,37 +76,18 @@ func TestAcc_ParametersOnObject(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: parametersConfigOnObject(dbName), + Config: parametersConfigOnObject(dbId), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.#"), resource.TestCheckResourceAttrSet("data.snowflake_parameters.p", "parameters.0.key"), resource.TestCheckResourceAttr("data.snowflake_parameters.p", "object_type", "DATABASE"), - resource.TestCheckResourceAttr("data.snowflake_parameters.p", "object_name", dbName), + resource.TestCheckResourceAttr("data.snowflake_parameters.p", "object_name", dbId.Name()), ), }, }, }) } -// proves https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2353 is fixed -func TestAcc_Parameters_TransactionAbortOnErrorCanBeSet(t *testing.T) { - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, - PreCheck: func() { acc.TestAccPreCheck(t) }, - TerraformVersionChecks: []tfversion.TerraformVersionCheck{ - tfversion.RequireAbove(tfversion.Version1_5_0), - }, - Steps: []resource.TestStep{ - { - Config: `resource "snowflake_account_parameter" "test" { - key = "TRANSACTION_ABORT_ON_ERROR" - value = "true" - }`, - }, - }, - }) -} - func parametersConfigOnAccount() string { return `data "snowflake_parameters" "p" { parameter_type = "ACCOUNT" @@ -104,28 +95,21 @@ func parametersConfigOnAccount() string { }` } -func parametersConfigOnSession(user string) string { +func parametersConfigOnSession(userId sdk.AccountObjectIdentifier) string { s := ` - resource "snowflake_user" "u" { - name = "%s" - } - data "snowflake_parameters" "p" { parameter_type = "SESSION" - user = snowflake_user.u.name + user = "%s" }` - return fmt.Sprintf(s, user) + return fmt.Sprintf(s, userId.Name()) } -func parametersConfigOnObject(name string) string { +func parametersConfigOnObject(databaseId sdk.AccountObjectIdentifier) string { stmt := ` - resource "snowflake_database" "d" { - name = "%s" - } data "snowflake_parameters" "p" { parameter_type = "OBJECT" object_type = "DATABASE" - object_name = snowflake_database.d.name + object_name = "%s" }` - return fmt.Sprintf(stmt, name) + return fmt.Sprintf(stmt, databaseId.Name()) } diff --git a/pkg/datasources/pipes_acceptance_test.go b/pkg/datasources/pipes_acceptance_test.go index 34a893a9c1..00e7146b13 100644 --- a/pkg/datasources/pipes_acceptance_test.go +++ b/pkg/datasources/pipes_acceptance_test.go @@ -6,14 +6,20 @@ import ( acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAcc_Pipes(t *testing.T) { - databaseName := acc.TestClient().Ids.Alpha() - schemaName := acc.TestClient().Ids.Alpha() - pipeName := acc.TestClient().Ids.Alpha() + _ = testenvs.GetOrSkipTest(t, testenvs.EnableAcceptance) + acc.TestAccPreCheck(t) + + tableId := acc.TestClient().Ids.RandomSchemaObjectIdentifier() + stageId := acc.TestClient().Ids.RandomSchemaObjectIdentifier() + pipeId := acc.TestClient().Ids.RandomSchemaObjectIdentifier() + resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -23,36 +29,25 @@ func TestAcc_Pipes(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: pipes(databaseName, schemaName, pipeName), + Config: pipes(tableId, stageId, pipeId), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.snowflake_pipes.t", "database", databaseName), - resource.TestCheckResourceAttr("data.snowflake_pipes.t", "schema", schemaName), + resource.TestCheckResourceAttr("data.snowflake_pipes.t", "database", acc.TestDatabaseName), + resource.TestCheckResourceAttr("data.snowflake_pipes.t", "schema", acc.TestSchemaName), resource.TestCheckResourceAttrSet("data.snowflake_pipes.t", "pipes.#"), resource.TestCheckResourceAttr("data.snowflake_pipes.t", "pipes.#", "1"), - resource.TestCheckResourceAttr("data.snowflake_pipes.t", "pipes.0.name", pipeName), + resource.TestCheckResourceAttr("data.snowflake_pipes.t", "pipes.0.name", pipeId.Name()), ), }, }, }) } -func pipes(databaseName string, schemaName string, pipeName string) string { - s := ` -resource "snowflake_database" "test" { - name = "%v" - comment = "Terraform acceptance test" -} - -resource "snowflake_schema" "test" { - name = "%v" - database = snowflake_database.test.name - comment = "Terraform acceptance test" -} - +func pipes(tableId sdk.SchemaObjectIdentifier, stageId sdk.SchemaObjectIdentifier, pipeId sdk.SchemaObjectIdentifier) string { + return fmt.Sprintf(` resource "snowflake_table" "test" { - database = snowflake_database.test.name - schema = snowflake_schema.test.name - name = snowflake_schema.test.name + database = "%[1]s" + schema = "%[2]s" + name = "%[3]s" column { name = "id" type = "NUMBER(5,0)" @@ -64,30 +59,27 @@ resource "snowflake_table" "test" { } resource "snowflake_stage" "test" { - name = snowflake_schema.test.name - database = snowflake_database.test.name - schema = snowflake_schema.test.name - comment = "Terraform acceptance test" -} - -data snowflake_pipes "t" { - database = snowflake_pipe.test.database - schema = snowflake_pipe.test.schema - depends_on = [snowflake_pipe.test] + database = "%[1]s" + schema = "%[2]s" + name = "%[4]s" } resource "snowflake_pipe" "test" { - database = snowflake_database.test.name - schema = snowflake_schema.test.name - name = "%v" + database = "%[1]s" + schema = "%[2]s" + name = "%[5]s" comment = "Terraform acceptance test" copy_statement = <