diff --git a/pkg/acceptance/helpers/test_client.go b/pkg/acceptance/helpers/test_client.go index e11fd6b79b..975c74a061 100644 --- a/pkg/acceptance/helpers/test_client.go +++ b/pkg/acceptance/helpers/test_client.go @@ -15,7 +15,7 @@ type TestClient struct { ApiIntegration *ApiIntegrationClient Application *ApplicationClient ApplicationPackage *ApplicationPackageClient - AuthenticationPolicy *AuthenticationPolicyClient + AuthenticationPolicy *AuthenticationPolicyClient BcrBundles *BcrBundlesClient Context *ContextClient CortexSearchService *CortexSearchServiceClient @@ -80,7 +80,7 @@ func NewTestClient(c *sdk.Client, database string, schema string, warehouse stri ApiIntegration: NewApiIntegrationClient(context, idsGenerator), Application: NewApplicationClient(context, idsGenerator), ApplicationPackage: NewApplicationPackageClient(context, idsGenerator), - AuthenticationPolicy: NewAuthenticationPolicyClient(context, idsGenerator), + AuthenticationPolicy: NewAuthenticationPolicyClient(context, idsGenerator), BcrBundles: NewBcrBundlesClient(context), Context: NewContextClient(context), CortexSearchService: NewCortexSearchServiceClient(context, idsGenerator), diff --git a/pkg/sdk/authentication_policies_def.go b/pkg/sdk/authentication_policies_def.go index cb4d1cb9a2..92665f4ab2 100644 --- a/pkg/sdk/authentication_policies_def.go +++ b/pkg/sdk/authentication_policies_def.go @@ -4,123 +4,123 @@ import g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/gen //go:generate go run ./poc/main.go -var AuthenticationMethodsOptionDef = g.NewQueryStruct("AuthenticationMethods").Text("Method", g.KeywordOptions().SingleQuotes()) -var MfaAuthenticationMethodsOptionDef = g.NewQueryStruct("MfaAuthenticationMethods").Text("Method", g.KeywordOptions().SingleQuotes()) -var ClientTypesOptionDef = g.NewQueryStruct("ClientTypes").Text("ClientType", g.KeywordOptions().SingleQuotes()) -var SecurityIntegrationsOptionDef = g.NewQueryStruct("SecurityIntegrationsOption").Text("Name", g.KeywordOptions().SingleQuotes()) - var ( - AuthenticationPoliciesDef = g.NewInterface( - "AuthenticationPolicies", - "AuthenticationPolicy", - g.KindOfT[SchemaObjectIdentifier](), - ). - CreateOperation( - "https://docs.snowflake.com/en/sql-reference/sql/create-authentication-policy", - g.NewQueryStruct("CreateAuthenticationPolicy"). - Create(). - OrReplace(). - SQL("AUTHENTICATION POLICY"). - Name(). - ListAssignment("AUTHENTICATION_METHODS", "AuthenticationMethods", g.ParameterOptions().Parentheses()). - ListAssignment("MFA_AUTHENTICATION_METHODS", "MfaAuthenticationMethods", g.ParameterOptions().Parentheses()). - OptionalTextAssignment("MFA_ENROLLMENT", g.ParameterOptions()). - ListAssignment("CLIENT_TYPES", "ClientTypes", g.ParameterOptions().Parentheses()). - ListAssignment("SECURITY_INTEGRATIONS", "SecurityIntegrationsOption", g.ParameterOptions().Parentheses()). - OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). - WithValidation(g.ValidIdentifier, "name"), - AuthenticationMethodsOptionDef, - MfaAuthenticationMethodsOptionDef, - ClientTypesOptionDef, - SecurityIntegrationsOptionDef, - ). - AlterOperation( - "https://docs.snowflake.com/en/sql-reference/sql/alter-authentication-policy", - g.NewQueryStruct("AlterAuthenticationPolicy"). - Alter(). - SQL("AUTHENTICATION POLICY"). - IfExists(). - Name(). - OptionalQueryStructField( - "Set", - g.NewQueryStruct("AuthenticationPolicySet"). - ListAssignment("AUTHENTICATION_METHODS", "AuthenticationMethods", g.ParameterOptions().Parentheses()). - ListAssignment("MFA_AUTHENTICATION_METHODS", "MfaAuthenticationMethods", g.ParameterOptions().Parentheses()). - OptionalTextAssignment("MFA_ENROLLMENT", g.ParameterOptions().SingleQuotes()). - ListAssignment("CLIENT_TYPES", "ClientTypes", g.ParameterOptions().Parentheses()). - ListAssignment("SECURITY_INTEGRATIONS", "SecurityIntegrationsOption", g.ParameterOptions().Parentheses()). - OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). - WithValidation(g.AtLeastOneValueSet, "AuthenticationMethods", "MfaAuthenticationMethods", "MfaEnrollment", "ClientTypes", "SecurityIntegrations", "Comment"), - g.KeywordOptions().SQL("SET"), - ). - OptionalQueryStructField( - "Unset", - g.NewQueryStruct("AuthenticationPolicyUnset"). - OptionalSQL("CLIENT_TYPES"). - OptionalSQL("AUTHENTICATION_METHODS"). - OptionalSQL("SECURITY_INTEGRATIONS"). - OptionalSQL("MFA_AUTHENTICATION_METHODS"). - OptionalSQL("MFA_ENROLLMENT"). - OptionalSQL("COMMENT"). - WithValidation(g.AtLeastOneValueSet, "ClientTypes", "AuthenticationMethods", "Comment", "SecurityIntegrations", "MfaAuthenticationMethods", "MfaEnrollment"), - g.ListOptions().NoParentheses().SQL("UNSET"), - ). - Identifier("RenameTo", g.KindOfTPointer[SchemaObjectIdentifier](), g.IdentifierOptions().SQL("RENAME TO")). - WithValidation(g.ValidIdentifier, "name"). - WithValidation(g.ExactlyOneValueSet, "Set", "Unset", "RenameTo"). - WithValidation(g.ValidIdentifierIfSet, "RenameTo"), - ). - DropOperation( - "https://docs.snowflake.com/en/sql-reference/sql/drop-authentication-policy", - g.NewQueryStruct("DropAuthenticationPolicy"). - Drop(). - SQL("AUTHENTICATION POLICY"). - IfExists(). - Name(). - WithValidation(g.ValidIdentifier, "name"), - ). - ShowOperation( - "https://docs.snowflake.com/en/sql-reference/sql/show-authentication-policies", - g.DbStruct("showAuthenticationPolicyDBRow"). - Field("created_on", "string"). - Field("name", "string"). - Field("comment", "string"). - Field("database_name", "string"). - Field("schema_name", "string"). - Field("owner", "string"). - Field("owner_role_type", "string"). - Field("options", "string"), - g.PlainStruct("AuthenticationPolicy"). - Field("CreatedOn", "string"). - Field("Name", "string"). - Field("Comment", "string"). - Field("DatabaseName", "string"). - Field("SchemaName", "string"). - Field("Owner", "string"). - Field("OwnerRoleType", "string"). - Field("Options", "string"), - g.NewQueryStruct("ShowAuthenticationPolicies"). - Show(). - SQL("AUTHENTICATION POLICIES"). - OptionalLike(). - OptionalIn(). - OptionalStartsWith(). - OptionalLimit(), - ). - ShowByIdOperation(). - DescribeOperation( - g.DescriptionMappingKindSlice, - "https://docs.snowflake.com/en/sql-reference/sql/desc-authentication-policy", - g.DbStruct("describeAuthenticationPolicyDBRow"). - Field("property", "string"). - Field("value", "string"), - g.PlainStruct("AuthenticationPolicyDescription"). - Field("Property", "string"). - Field("Value", "string"), - g.NewQueryStruct("DescribeAuthenticationPolicy"). - Describe(). - SQL("AUTHENTICATION POLICY"). - Name(). - WithValidation(g.ValidIdentifier, "name"), - ) + AuthenticationMethodsOptionDef = g.NewQueryStruct("AuthenticationMethods").Text("Method", g.KeywordOptions().SingleQuotes()) + MfaAuthenticationMethodsOptionDef = g.NewQueryStruct("MfaAuthenticationMethods").Text("Method", g.KeywordOptions().SingleQuotes()) + ClientTypesOptionDef = g.NewQueryStruct("ClientTypes").Text("ClientType", g.KeywordOptions().SingleQuotes()) + SecurityIntegrationsOptionDef = g.NewQueryStruct("SecurityIntegrationsOption").Text("Name", g.KeywordOptions().SingleQuotes()) ) + +var AuthenticationPoliciesDef = g.NewInterface( + "AuthenticationPolicies", + "AuthenticationPolicy", + g.KindOfT[SchemaObjectIdentifier](), +). + CreateOperation( + "https://docs.snowflake.com/en/sql-reference/sql/create-authentication-policy", + g.NewQueryStruct("CreateAuthenticationPolicy"). + Create(). + OrReplace(). + SQL("AUTHENTICATION POLICY"). + Name(). + ListAssignment("AUTHENTICATION_METHODS", "AuthenticationMethods", g.ParameterOptions().Parentheses()). + ListAssignment("MFA_AUTHENTICATION_METHODS", "MfaAuthenticationMethods", g.ParameterOptions().Parentheses()). + OptionalTextAssignment("MFA_ENROLLMENT", g.ParameterOptions()). + ListAssignment("CLIENT_TYPES", "ClientTypes", g.ParameterOptions().Parentheses()). + ListAssignment("SECURITY_INTEGRATIONS", "SecurityIntegrationsOption", g.ParameterOptions().Parentheses()). + OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). + WithValidation(g.ValidIdentifier, "name"), + AuthenticationMethodsOptionDef, + MfaAuthenticationMethodsOptionDef, + ClientTypesOptionDef, + SecurityIntegrationsOptionDef, + ). + AlterOperation( + "https://docs.snowflake.com/en/sql-reference/sql/alter-authentication-policy", + g.NewQueryStruct("AlterAuthenticationPolicy"). + Alter(). + SQL("AUTHENTICATION POLICY"). + IfExists(). + Name(). + OptionalQueryStructField( + "Set", + g.NewQueryStruct("AuthenticationPolicySet"). + ListAssignment("AUTHENTICATION_METHODS", "AuthenticationMethods", g.ParameterOptions().Parentheses()). + ListAssignment("MFA_AUTHENTICATION_METHODS", "MfaAuthenticationMethods", g.ParameterOptions().Parentheses()). + OptionalTextAssignment("MFA_ENROLLMENT", g.ParameterOptions().SingleQuotes()). + ListAssignment("CLIENT_TYPES", "ClientTypes", g.ParameterOptions().Parentheses()). + ListAssignment("SECURITY_INTEGRATIONS", "SecurityIntegrationsOption", g.ParameterOptions().Parentheses()). + OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). + WithValidation(g.AtLeastOneValueSet, "AuthenticationMethods", "MfaAuthenticationMethods", "MfaEnrollment", "ClientTypes", "SecurityIntegrations", "Comment"), + g.KeywordOptions().SQL("SET"), + ). + OptionalQueryStructField( + "Unset", + g.NewQueryStruct("AuthenticationPolicyUnset"). + OptionalSQL("CLIENT_TYPES"). + OptionalSQL("AUTHENTICATION_METHODS"). + OptionalSQL("SECURITY_INTEGRATIONS"). + OptionalSQL("MFA_AUTHENTICATION_METHODS"). + OptionalSQL("MFA_ENROLLMENT"). + OptionalSQL("COMMENT"). + WithValidation(g.AtLeastOneValueSet, "ClientTypes", "AuthenticationMethods", "Comment", "SecurityIntegrations", "MfaAuthenticationMethods", "MfaEnrollment"), + g.ListOptions().NoParentheses().SQL("UNSET"), + ). + Identifier("RenameTo", g.KindOfTPointer[SchemaObjectIdentifier](), g.IdentifierOptions().SQL("RENAME TO")). + WithValidation(g.ValidIdentifier, "name"). + WithValidation(g.ExactlyOneValueSet, "Set", "Unset", "RenameTo"). + WithValidation(g.ValidIdentifierIfSet, "RenameTo"), + ). + DropOperation( + "https://docs.snowflake.com/en/sql-reference/sql/drop-authentication-policy", + g.NewQueryStruct("DropAuthenticationPolicy"). + Drop(). + SQL("AUTHENTICATION POLICY"). + IfExists(). + Name(). + WithValidation(g.ValidIdentifier, "name"), + ). + ShowOperation( + "https://docs.snowflake.com/en/sql-reference/sql/show-authentication-policies", + g.DbStruct("showAuthenticationPolicyDBRow"). + Field("created_on", "string"). + Field("name", "string"). + Field("comment", "string"). + Field("database_name", "string"). + Field("schema_name", "string"). + Field("owner", "string"). + Field("owner_role_type", "string"). + Field("options", "string"), + g.PlainStruct("AuthenticationPolicy"). + Field("CreatedOn", "string"). + Field("Name", "string"). + Field("Comment", "string"). + Field("DatabaseName", "string"). + Field("SchemaName", "string"). + Field("Owner", "string"). + Field("OwnerRoleType", "string"). + Field("Options", "string"), + g.NewQueryStruct("ShowAuthenticationPolicies"). + Show(). + SQL("AUTHENTICATION POLICIES"). + OptionalLike(). + OptionalIn(). + OptionalStartsWith(). + OptionalLimit(), + ). + ShowByIdOperation(). + DescribeOperation( + g.DescriptionMappingKindSlice, + "https://docs.snowflake.com/en/sql-reference/sql/desc-authentication-policy", + g.DbStruct("describeAuthenticationPolicyDBRow"). + Field("property", "string"). + Field("value", "string"), + g.PlainStruct("AuthenticationPolicyDescription"). + Field("Property", "string"). + Field("Value", "string"), + g.NewQueryStruct("DescribeAuthenticationPolicy"). + Describe(). + SQL("AUTHENTICATION POLICY"). + Name(). + WithValidation(g.ValidIdentifier, "name"), + ) diff --git a/pkg/sdk/authentication_policies_gen.go b/pkg/sdk/authentication_policies_gen.go index e39f1a6a0c..e9a12ea297 100644 --- a/pkg/sdk/authentication_policies_gen.go +++ b/pkg/sdk/authentication_policies_gen.go @@ -114,12 +114,12 @@ type DescribeAuthenticationPolicyOptions struct { name SchemaObjectIdentifier `ddl:"identifier"` } type describeAuthenticationPolicyDBRow struct { - Property string `db:"property"` - Value string `db:"value"` + Property string `db:"property"` + Value string `db:"value"` } type AuthenticationPolicyDescription struct { - Property string - Value string + Property string + Value string } func (v *AuthenticationPolicy) ID() SchemaObjectIdentifier { diff --git a/pkg/sdk/authentication_policies_gen_test.go b/pkg/sdk/authentication_policies_gen_test.go index e2f9628096..135936d223 100644 --- a/pkg/sdk/authentication_policies_gen_test.go +++ b/pkg/sdk/authentication_policies_gen_test.go @@ -3,12 +3,10 @@ package sdk import "testing" func TestAuthenticationPolicies_Create(t *testing.T) { - id := randomSchemaObjectIdentifier() // Minimal valid CreateAuthenticationPolicyOptions defaultOpts := func() *CreateAuthenticationPolicyOptions { return &CreateAuthenticationPolicyOptions{ - name: id, } } @@ -44,12 +42,10 @@ func TestAuthenticationPolicies_Create(t *testing.T) { } func TestAuthenticationPolicies_Alter(t *testing.T) { - id := randomSchemaObjectIdentifier() // Minimal valid AlterAuthenticationPolicyOptions defaultOpts := func() *AlterAuthenticationPolicyOptions { return &AlterAuthenticationPolicyOptions{ - name: id, } } @@ -137,16 +133,13 @@ func TestAuthenticationPolicies_Alter(t *testing.T) { opts.RenameTo = &target assertOptsValidAndSQLEquals(t, opts, "ALTER AUTHENTICATION POLICY %s RENAME TO %s", id.FullyQualifiedName(), opts.RenameTo.FullyQualifiedName()) }) - } func TestAuthenticationPolicies_Drop(t *testing.T) { - id := randomSchemaObjectIdentifier() // Minimal valid DropAuthenticationPolicyOptions defaultOpts := func() *DropAuthenticationPolicyOptions { return &DropAuthenticationPolicyOptions{ - name: id, } } @@ -186,12 +179,10 @@ func TestAuthenticationPolicies_Show(t *testing.T) { } func TestAuthenticationPolicies_Describe(t *testing.T) { - id := randomSchemaObjectIdentifier() // Minimal valid DescribeAuthenticationPolicyOptions defaultOpts := func() *DescribeAuthenticationPolicyOptions { return &DescribeAuthenticationPolicyOptions{ - name: id, } } diff --git a/pkg/sdk/authentication_policies_impl_gen.go b/pkg/sdk/authentication_policies_impl_gen.go index e4ca557208..077033854c 100644 --- a/pkg/sdk/authentication_policies_impl_gen.go +++ b/pkg/sdk/authentication_policies_impl_gen.go @@ -79,7 +79,6 @@ func (r *AlterAuthenticationPolicyRequest) toOpts() *AlterAuthenticationPolicyOp } if r.Set != nil { - opts.Set = &AuthenticationPolicySet{ AuthenticationMethods: r.Set.AuthenticationMethods, MfaAuthenticationMethods: r.Set.MfaAuthenticationMethods, @@ -88,11 +87,9 @@ func (r *AlterAuthenticationPolicyRequest) toOpts() *AlterAuthenticationPolicyOp SecurityIntegrations: r.Set.SecurityIntegrations, Comment: r.Set.Comment, } - } if r.Unset != nil { - opts.Unset = &AuthenticationPolicyUnset{ ClientTypes: r.Unset.ClientTypes, AuthenticationMethods: r.Unset.AuthenticationMethods, @@ -101,7 +98,6 @@ func (r *AlterAuthenticationPolicyRequest) toOpts() *AlterAuthenticationPolicyOp MfaEnrollment: r.Unset.MfaEnrollment, Comment: r.Unset.Comment, } - } return opts @@ -147,7 +143,7 @@ func (r *DescribeAuthenticationPolicyRequest) toOpts() *DescribeAuthenticationPo func (r describeAuthenticationPolicyDBRow) convert() *AuthenticationPolicyDescription { return &AuthenticationPolicyDescription{ - Property: r.Property, - Value: r.Value, + Property: r.Property, + Value: r.Value, } } diff --git a/pkg/sdk/client.go b/pkg/sdk/client.go index 49727a2129..6f2e57200e 100644 --- a/pkg/sdk/client.go +++ b/pkg/sdk/client.go @@ -45,7 +45,7 @@ type Client struct { ApplicationPackages ApplicationPackages ApplicationRoles ApplicationRoles Applications Applications - AuthenticationPolicies AuthenticationPolicies + AuthenticationPolicies AuthenticationPolicies Comments Comments CortexSearchServices CortexSearchServices DatabaseRoles DatabaseRoles diff --git a/pkg/sdk/poc/main.go b/pkg/sdk/poc/main.go index ca3a70ece5..1d98ea99de 100644 --- a/pkg/sdk/poc/main.go +++ b/pkg/sdk/poc/main.go @@ -44,7 +44,7 @@ var definitionMapping = map[string]*generator.Interface{ "cortex_search_services_def.go": sdk.CortexSearchServiceDef, "data_metric_function_references_def.go": sdk.DataMetricFunctionReferenceDef, "external_volumes_def.go": sdk.ExternalVolumesDef, - "authentication_policies_def.go": sdk.AuthenticationPoliciesDef, + "authentication_policies_def.go": sdk.AuthenticationPoliciesDef, } func main() { diff --git a/pkg/sdk/testint/authentication_policies_gen_integration_test.go b/pkg/sdk/testint/authentication_policies_gen_integration_test.go index 6b0f16f3d3..50d4e9cc3c 100644 --- a/pkg/sdk/testint/authentication_policies_gen_integration_test.go +++ b/pkg/sdk/testint/authentication_policies_gen_integration_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -103,6 +103,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - set authentication methods", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -117,6 +118,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - set client types", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -134,6 +136,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { }) req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -148,6 +151,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - set mfa authentication methods", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -162,6 +166,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - set mfa enrollment", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -176,6 +181,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - set comment", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -190,6 +196,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset authentication methods", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -204,6 +211,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset client types", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -218,6 +226,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset security integrations", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -232,6 +241,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset mfa authentication methods", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -246,6 +256,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset mfa enrollment", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -260,6 +271,7 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - unset comment", func(t *testing.T) { req := defaultCreateRequest() err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) alterErr := client.AuthenticationPolicies.Alter(ctx, sdk.NewAlterAuthenticationPolicyRequest(req.GetName()). @@ -273,7 +285,8 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Alter - rename", func(t *testing.T) { req := defaultCreateRequest() - client.AuthenticationPolicies.Create(ctx, req) + err := client.AuthenticationPolicies.Create(ctx, req) + require.NoError(t, err) t.Cleanup(cleanupAuthenticationPolicyProvider(req.GetName())) newId := testClientHelper().Ids.RandomSchemaObjectIdentifier() @@ -319,7 +332,8 @@ func TestInt_AuthenticationPolicies(t *testing.T) { t.Run("Describe", func(t *testing.T) { request := defaultCreateRequest() - client.AuthenticationPolicies.Create(ctx, request) + err := client.AuthenticationPolicies.Create(ctx, request) + require.NoError(t, err) desc, err := client.AuthenticationPolicies.Describe(ctx, request.GetName()) require.NoError(t, err) diff --git a/pkg/sdk/testint/users_integration_test.go b/pkg/sdk/testint/users_integration_test.go index 805b46f7e0..115bffe084 100644 --- a/pkg/sdk/testint/users_integration_test.go +++ b/pkg/sdk/testint/users_integration_test.go @@ -47,44 +47,47 @@ func TestInt_Users(t *testing.T) { tag2, tag2Cleanup := testClientHelper().Tag.CreateTag(t) t.Cleanup(tag2Cleanup) -func TestInt_UserAlter(t *testing.T) { - client := testClient(t) - ctx := testContext(t) - - randomPrefix := random.AlphaN(6) - - userTest, userCleanup := testClientHelper().User.CreateUserWithPrefix(t, randomPrefix+"_") - t.Cleanup(userCleanup) - - t.Run("set and unset authentication policy", func(t *testing.T) { - authenticationPolicyTest, authenticationPolicyCleanup := testClientHelper().AuthenticationPolicy.CreateAuthenticationPolicy(t) - t.Cleanup(authenticationPolicyCleanup) - - alterOptions := &sdk.AlterUserOptions{ - Set: &sdk.UserSet{ - AuthenticationPolicy: authenticationPolicyTest.ID(), - }, - } - - err := client.Users.Alter(ctx, userTest.ID(), alterOptions) - require.NoError(t, err) - - unsetOptions := &sdk.AlterUserOptions{ - Unset: &sdk.UserUnset{ - AuthenticationPolicy: sdk.Bool(true), - }, - } - - unsetErr := client.Users.Alter(ctx, userTest.ID(), unsetOptions) - require.NoError(t, unsetErr) - }) -} - -func TestInt_UserCreate(t *testing.T) { - client := testClient(t) - ctx := testContext(t) - - networkPolicy, networkPolicyCleanup := testClientHelper().NetworkPolicy.CreateNetworkPolicy(t) + /* + // TODO(SNOW-1528557): Uncomment next pr + func TestInt_UserAlter(t *testing.T) { + client := testClient(t) + ctx := testContext(t) + + randomPrefix := random.AlphaN(6) + + userTest, userCleanup := testClientHelper().User.CreateUserWithPrefix(t, randomPrefix+"_") + t.Cleanup(userCleanup) + + t.Run("set and unset authentication policy", func(t *testing.T) { + authenticationPolicyTest, authenticationPolicyCleanup := testClientHelper().AuthenticationPolicy.CreateAuthenticationPolicy(t) + t.Cleanup(authenticationPolicyCleanup) + + alterOptions := &sdk.AlterUserOptions{ + Set: &sdk.UserSet{ + AuthenticationPolicy: authenticationPolicyTest.ID(), + }, + } + + err := client.Users.Alter(ctx, userTest.ID(), alterOptions) + require.NoError(t, err) + + unsetOptions := &sdk.AlterUserOptions{ + Unset: &sdk.UserUnset{ + AuthenticationPolicy: sdk.Bool(true), + }, + } + + unsetErr := client.Users.Alter(ctx, userTest.ID(), unsetOptions) + require.NoError(t, unsetErr) + }) + } + + func TestInt_UserCreate(t *testing.T) { + client := testClient(t) + ctx := testContext(t) + */ + + networkPolicy, networkPolicyCleanup := testClientHelper().NetworkPolicy.CreateNetworkPolicy(t) t.Cleanup(networkPolicyCleanup) assertParametersSet := func(userParametersAssert *objectparametersassert.UserParametersAssert) { diff --git a/pkg/sdk/users.go b/pkg/sdk/users.go index b1799840b3..b7ed9d4e23 100644 --- a/pkg/sdk/users.go +++ b/pkg/sdk/users.go @@ -388,12 +388,12 @@ func (opts *RemoveDelegatedAuthorization) validate() error { } type UserSet struct { - PasswordPolicy *SchemaObjectIdentifier `ddl:"identifier" sql:"PASSWORD POLICY"` - SessionPolicy *string `ddl:"parameter" sql:"SESSION POLICY"` - AuthenticationPolicy SchemaObjectIdentifier `ddl:"identifier" sql:"AUTHENTICATION POLICY"` - ObjectProperties *UserObjectProperties `ddl:"keyword"` - ObjectParameters *UserObjectParameters `ddl:"keyword"` - SessionParameters *SessionParameters `ddl:"keyword"` + PasswordPolicy *SchemaObjectIdentifier `ddl:"identifier" sql:"PASSWORD POLICY"` + SessionPolicy *string `ddl:"parameter" sql:"SESSION POLICY"` + AuthenticationPolicy SchemaObjectIdentifier `ddl:"identifier" sql:"AUTHENTICATION POLICY"` + ObjectProperties *UserAlterObjectProperties `ddl:"keyword"` + ObjectParameters *UserObjectParameters `ddl:"keyword"` + SessionParameters *SessionParameters `ddl:"keyword"` } func (opts *UserSet) validate() error {