diff --git a/pkg/acceptance/bettertestspoc/README.md b/pkg/acceptance/bettertestspoc/README.md index a7c4d4eec0..1cae4a6760 100644 --- a/pkg/acceptance/bettertestspoc/README.md +++ b/pkg/acceptance/bettertestspoc/README.md @@ -403,6 +403,7 @@ func (w *WarehouseDatasourceShowOutputAssert) IsEmpty() { - consider merging ResourceModel with DatasourceModel (currently the implementation is really similar) - remove schema.TypeMap workaround or make it wiser (e.g. during generation we could programmatically gather all schema.TypeMap and use this workaround only for them) - support asserting resource id in `assert/resourceassert/*_gen.go` +- add possibility for object parameter assert not take any identifier (currently there's a workaround in `account_parameters_snowflake_gen.go`, because `SHOW PARAMETERS FOR ACCOUNT` don't take any identifiers) ## Known limitations - generating provider config may misbehave when used only with one object/map paramter (like `params`), e.g.: diff --git a/pkg/acceptance/bettertestspoc/assert/objectassert/account_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectassert/account_snowflake_gen.go new file mode 100644 index 0000000000..d394c1ae39 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectassert/account_snowflake_gen.go @@ -0,0 +1,423 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package objectassert + +import ( + "fmt" + "testing" + "time" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type AccountAssert struct { + *assert.SnowflakeObjectAssert[sdk.Account, sdk.AccountObjectIdentifier] +} + +func Account(t *testing.T, id sdk.AccountObjectIdentifier) *AccountAssert { + t.Helper() + return &AccountAssert{ + assert.NewSnowflakeObjectAssertWithProvider(sdk.ObjectTypeAccount, id, acc.TestClient().Account.Show), + } +} + +func AccountFromObject(t *testing.T, account *sdk.Account) *AccountAssert { + t.Helper() + return &AccountAssert{ + assert.NewSnowflakeObjectAssertWithObject(sdk.ObjectTypeAccount, account.ID(), account), + } +} + +func (a *AccountAssert) HasOrganizationName(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OrganizationName != expected { + return fmt.Errorf("expected organization name: %v; got: %v", expected, o.OrganizationName) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountName(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountName != expected { + return fmt.Errorf("expected account name: %v; got: %v", expected, o.AccountName) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasSnowflakeRegion(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.SnowflakeRegion != expected { + return fmt.Errorf("expected snowflake region: %v; got: %v", expected, o.SnowflakeRegion) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasRegionGroup(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.RegionGroup == nil { + return fmt.Errorf("expected region group to have value; got: nil") + } + if *o.RegionGroup != expected { + return fmt.Errorf("expected region group: %v; got: %v", expected, *o.RegionGroup) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasEdition(expected sdk.AccountEdition) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.Edition == nil { + return fmt.Errorf("expected edition to have value; got: nil") + } + if *o.Edition != expected { + return fmt.Errorf("expected edition: %v; got: %v", expected, *o.Edition) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountURL(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountURL == nil { + return fmt.Errorf("expected account url to have value; got: nil") + } + if *o.AccountURL != expected { + return fmt.Errorf("expected account url: %v; got: %v", expected, *o.AccountURL) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasCreatedOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.CreatedOn == nil { + return fmt.Errorf("expected created on to have value; got: nil") + } + if *o.CreatedOn != expected { + return fmt.Errorf("expected created on: %v; got: %v", expected, *o.CreatedOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasComment(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.Comment == nil { + return fmt.Errorf("expected comment to have value; got: nil") + } + if *o.Comment != expected { + return fmt.Errorf("expected comment: %v; got: %v", expected, *o.Comment) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountLocator(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountLocator != expected { + return fmt.Errorf("expected account locator: %v; got: %v", expected, o.AccountLocator) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountLocatorURL(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountLocatorURL == nil { + return fmt.Errorf("expected account locator url to have value; got: nil") + } + if *o.AccountLocatorURL != expected { + return fmt.Errorf("expected account locator url: %v; got: %v", expected, *o.AccountLocatorURL) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasManagedAccounts(expected int) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.ManagedAccounts == nil { + return fmt.Errorf("expected managed accounts to have value; got: nil") + } + if *o.ManagedAccounts != expected { + return fmt.Errorf("expected managed accounts: %v; got: %v", expected, *o.ManagedAccounts) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasConsumptionBillingEntityName(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.ConsumptionBillingEntityName == nil { + return fmt.Errorf("expected consumption billing entity name to have value; got: nil") + } + if *o.ConsumptionBillingEntityName != expected { + return fmt.Errorf("expected consumption billing entity name: %v; got: %v", expected, *o.ConsumptionBillingEntityName) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasMarketplaceConsumerBillingEntityName(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.MarketplaceConsumerBillingEntityName == nil { + return fmt.Errorf("expected marketplace consumer billing entity name to have value; got: nil") + } + if *o.MarketplaceConsumerBillingEntityName != expected { + return fmt.Errorf("expected marketplace consumer billing entity name: %v; got: %v", expected, *o.MarketplaceConsumerBillingEntityName) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasMarketplaceProviderBillingEntityName(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.MarketplaceProviderBillingEntityName == nil { + return fmt.Errorf("expected marketplace provider billing entity name to have value; got: nil") + } + if *o.MarketplaceProviderBillingEntityName != expected { + return fmt.Errorf("expected marketplace provider billing entity name: %v; got: %v", expected, *o.MarketplaceProviderBillingEntityName) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasOldAccountURL(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OldAccountURL == nil { + return fmt.Errorf("expected old account url to have value; got: nil") + } + if *o.OldAccountURL != expected { + return fmt.Errorf("expected old account url: %v; got: %v", expected, *o.OldAccountURL) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasIsOrgAdmin(expected bool) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.IsOrgAdmin == nil { + return fmt.Errorf("expected is org admin to have value; got: nil") + } + if *o.IsOrgAdmin != expected { + return fmt.Errorf("expected is org admin: %v; got: %v", expected, *o.IsOrgAdmin) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountOldUrlSavedOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountOldUrlSavedOn == nil { + return fmt.Errorf("expected account old url saved on to have value; got: nil") + } + if *o.AccountOldUrlSavedOn != expected { + return fmt.Errorf("expected account old url saved on: %v; got: %v", expected, *o.AccountOldUrlSavedOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasAccountOldUrlLastUsed(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.AccountOldUrlLastUsed == nil { + return fmt.Errorf("expected account old url last used to have value; got: nil") + } + if *o.AccountOldUrlLastUsed != expected { + return fmt.Errorf("expected account old url last used: %v; got: %v", expected, *o.AccountOldUrlLastUsed) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasOrganizationOldUrl(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OrganizationOldUrl == nil { + return fmt.Errorf("expected organization old url to have value; got: nil") + } + if *o.OrganizationOldUrl != expected { + return fmt.Errorf("expected organization old url: %v; got: %v", expected, *o.OrganizationOldUrl) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasOrganizationOldUrlSavedOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OrganizationOldUrlSavedOn == nil { + return fmt.Errorf("expected organization old url saved on to have value; got: nil") + } + if *o.OrganizationOldUrlSavedOn != expected { + return fmt.Errorf("expected organization old url saved on: %v; got: %v", expected, *o.OrganizationOldUrlSavedOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasOrganizationOldUrlLastUsed(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OrganizationOldUrlLastUsed == nil { + return fmt.Errorf("expected organization old url last used to have value; got: nil") + } + if *o.OrganizationOldUrlLastUsed != expected { + return fmt.Errorf("expected organization old url last used: %v; got: %v", expected, *o.OrganizationOldUrlLastUsed) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasIsEventsAccount(expected bool) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.IsEventsAccount == nil { + return fmt.Errorf("expected is events account to have value; got: nil") + } + if *o.IsEventsAccount != expected { + return fmt.Errorf("expected is events account: %v; got: %v", expected, *o.IsEventsAccount) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasIsOrganizationAccount(expected bool) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.IsOrganizationAccount != expected { + return fmt.Errorf("expected is organization account: %v; got: %v", expected, o.IsOrganizationAccount) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasDroppedOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.DroppedOn == nil { + return fmt.Errorf("expected dropped on to have value; got: nil") + } + if *o.DroppedOn != expected { + return fmt.Errorf("expected dropped on: %v; got: %v", expected, *o.DroppedOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasScheduledDeletionTime(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.ScheduledDeletionTime == nil { + return fmt.Errorf("expected scheduled deletion time to have value; got: nil") + } + if *o.ScheduledDeletionTime != expected { + return fmt.Errorf("expected scheduled deletion time: %v; got: %v", expected, *o.ScheduledDeletionTime) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasRestoredOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.RestoredOn == nil { + return fmt.Errorf("expected restored on to have value; got: nil") + } + if *o.RestoredOn != expected { + return fmt.Errorf("expected restored on: %v; got: %v", expected, *o.RestoredOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasMovedToOrganization(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.MovedToOrganization == nil { + return fmt.Errorf("expected moved to organization to have value; got: nil") + } + if *o.MovedToOrganization != expected { + return fmt.Errorf("expected moved to organization: %v; got: %v", expected, *o.MovedToOrganization) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasMovedOn(expected string) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.MovedOn == nil { + return fmt.Errorf("expected moved on to have value; got: nil") + } + if *o.MovedOn != expected { + return fmt.Errorf("expected moved on: %v; got: %v", expected, *o.MovedOn) + } + return nil + }) + return a +} + +func (a *AccountAssert) HasOrganizationUrlExpirationOn(expected time.Time) *AccountAssert { + a.AddAssertion(func(t *testing.T, o *sdk.Account) error { + t.Helper() + if o.OrganizationUrlExpirationOn == nil { + return fmt.Errorf("expected organization url expiration on to have value; got: nil") + } + if *o.OrganizationUrlExpirationOn != expected { + return fmt.Errorf("expected organization url expiration on: %v; got: %v", expected, *o.OrganizationUrlExpirationOn) + } + return nil + }) + return a +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go b/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go index 42dabe5c9d..636fb40c8e 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go +++ b/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go @@ -87,6 +87,11 @@ var allStructs = []SdkObjectDef{ ObjectType: sdk.ObjectTypeTag, ObjectStruct: sdk.Tag{}, }, + { + IdType: "sdk.AccountObjectIdentifier", + ObjectType: sdk.ObjectTypeAccount, + ObjectStruct: sdk.Account{}, + }, } func GetSdkObjectDetails() []genhelpers.SdkObjectDetails { diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_ext.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_ext.go new file mode 100644 index 0000000000..c5db9e7950 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_ext.go @@ -0,0 +1,27 @@ +package objectparametersassert + +import ( + "testing" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +func AccountParametersExt(t *testing.T) *AccountParametersAssert { + t.Helper() + return &AccountParametersAssert{ + assert.NewSnowflakeParametersAssertWithProvider(sdk.NewAccountObjectIdentifier(""), sdk.ObjectTypeAccount, func(t *testing.T, identifier sdk.AccountObjectIdentifier) []*sdk.Parameter { + t.Helper() + return acc.TestClient().Parameter.ShowAccountParameters(t) + }), + } +} + +func AccountParametersPrefetchedExt(t *testing.T, parameters []*sdk.Parameter) *AccountParametersAssert { + t.Helper() + return &AccountParametersAssert{ + assert.NewSnowflakeParametersAssertWithParameters(sdk.NewAccountObjectIdentifier(""), sdk.ObjectTypeAccount, parameters), + } +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_gen.go new file mode 100644 index 0000000000..2705540146 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/account_parameters_snowflake_gen.go @@ -0,0 +1,113 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package objectparametersassert + +import ( + "testing" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type AccountParametersAssert struct { + *assert.SnowflakeParametersAssert[sdk.AccountObjectIdentifier] +} + +func AccountParameters(t *testing.T, id sdk.AccountObjectIdentifier) *AccountParametersAssert { + t.Helper() + return &AccountParametersAssert{ + // Modified manually, don't override + assert.NewSnowflakeParametersAssertWithProvider(id, sdk.ObjectTypeAccount, func(t *testing.T, identifier sdk.AccountObjectIdentifier) []*sdk.Parameter { + return acc.TestClient().Parameter.ShowAccountParameters(t) + }), + } +} + +func AccountParametersPrefetched(t *testing.T, id sdk.AccountObjectIdentifier, parameters []*sdk.Parameter) *AccountParametersAssert { + t.Helper() + return &AccountParametersAssert{ + assert.NewSnowflakeParametersAssertWithParameters(id, sdk.ObjectTypeAccount, parameters), + } +} + +////////////////////////////// +// Generic parameter checks // +////////////////////////////// + +func (a *AccountParametersAssert) HasBoolParameterValue(parameterName sdk.AccountParameter, expected bool) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterBoolValueSet(parameterName, expected)) + return a +} + +func (a *AccountParametersAssert) HasIntParameterValue(parameterName sdk.AccountParameter, expected int) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterIntValueSet(parameterName, expected)) + return a +} + +func (a *AccountParametersAssert) HasStringParameterValue(parameterName sdk.AccountParameter, expected string) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterValueSet(parameterName, expected)) + return a +} + +func (a *AccountParametersAssert) HasDefaultParameterValue(parameterName sdk.AccountParameter) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterDefaultValueSet(parameterName)) + return a +} + +func (a *AccountParametersAssert) HasDefaultParameterValueOnLevel(parameterName sdk.AccountParameter, parameterType sdk.ParameterType) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterDefaultValueOnLevelSet(parameterName, parameterType)) + return a +} + +/////////////////////////////// +// Aggregated generic checks // +/////////////////////////////// + +// HasAllDefaults checks if all the parameters: +// - have a default value by comparing current value of the sdk.Parameter with its default +// - have an expected level +func (a *AccountParametersAssert) HasAllDefaults() *AccountParametersAssert { + return a. + HasDefaultParameterValueOnLevel(sdk.AccountParameterEnableUnredactedQuerySyntaxError, sdk.ParameterTypeSnowflakeDefault) +} + +func (a *AccountParametersAssert) HasAllDefaultsExplicit() *AccountParametersAssert { + return a. + HasDefaultEnableUnredactedQuerySyntaxErrorValueExplicit() +} + +//////////////////////////// +// Parameter value checks // +//////////////////////////// + +func (a *AccountParametersAssert) HasEnableUnredactedQuerySyntaxError(expected bool) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterBoolValueSet(sdk.AccountParameterEnableUnredactedQuerySyntaxError, expected)) + return a +} + +//////////////////////////// +// Parameter level checks // +//////////////////////////// + +func (a *AccountParametersAssert) HasEnableUnredactedQuerySyntaxErrorLevel(expected sdk.ParameterType) *AccountParametersAssert { + a.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.AccountParameterEnableUnredactedQuerySyntaxError, expected)) + return a +} + +//////////////////////////////////// +// Parameter default value checks // +//////////////////////////////////// + +func (a *AccountParametersAssert) HasDefaultEnableUnredactedQuerySyntaxErrorValue() *AccountParametersAssert { + return a.HasDefaultParameterValue(sdk.AccountParameterEnableUnredactedQuerySyntaxError) +} + +///////////////////////////////////////////// +// Parameter explicit default value checks // +///////////////////////////////////////////// + +func (a *AccountParametersAssert) HasDefaultEnableUnredactedQuerySyntaxErrorValueExplicit() *AccountParametersAssert { + return a.HasEnableUnredactedQuerySyntaxError(false) +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go index e9d8b08092..67a6b4e7a0 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go @@ -196,4 +196,13 @@ var allObjectsParameters = []SnowflakeObjectParameters{ // for the quickfix above AdditionalImports: []string{"strings"}, }, + { + Name: "Account", + IdType: "sdk.AccountObjectIdentifier", + Level: sdk.ParameterTypeAccount, + Parameters: []SnowflakeParameter{ + {ParameterName: string(sdk.UserParameterEnableUnredactedQuerySyntaxError), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + // TODO(SNOW-1348092 - next prs): Add parameters + }, + }, } diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/account_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/account_resource_gen.go new file mode 100644 index 0000000000..c68f6424c1 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/account_resource_gen.go @@ -0,0 +1,187 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type AccountResourceAssert struct { + *assert.ResourceAssert +} + +func AccountResource(t *testing.T, name string) *AccountResourceAssert { + t.Helper() + + return &AccountResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedAccountResource(t *testing.T, id string) *AccountResourceAssert { + t.Helper() + + return &AccountResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (a *AccountResourceAssert) HasAdminNameString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("admin_name", expected)) + return a +} + +func (a *AccountResourceAssert) HasAdminPasswordString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("admin_password", expected)) + return a +} + +func (a *AccountResourceAssert) HasAdminRsaPublicKeyString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("admin_rsa_public_key", expected)) + return a +} + +func (a *AccountResourceAssert) HasCommentString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("comment", expected)) + return a +} + +func (a *AccountResourceAssert) HasEditionString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("edition", expected)) + return a +} + +func (a *AccountResourceAssert) HasEmailString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("email", expected)) + return a +} + +func (a *AccountResourceAssert) HasFirstNameString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("first_name", expected)) + return a +} + +func (a *AccountResourceAssert) HasFullyQualifiedNameString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return a +} + +func (a *AccountResourceAssert) HasGracePeriodInDaysString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("grace_period_in_days", expected)) + return a +} + +func (a *AccountResourceAssert) HasIsOrgAdminString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("is_org_admin", expected)) + return a +} + +func (a *AccountResourceAssert) HasLastNameString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("last_name", expected)) + return a +} + +func (a *AccountResourceAssert) HasMustChangePasswordString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("must_change_password", expected)) + return a +} + +func (a *AccountResourceAssert) HasNameString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("name", expected)) + return a +} + +func (a *AccountResourceAssert) HasRegionString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("region", expected)) + return a +} + +func (a *AccountResourceAssert) HasRegionGroupString(expected string) *AccountResourceAssert { + a.AddAssertion(assert.ValueSet("region_group", expected)) + return a +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (a *AccountResourceAssert) HasNoAdminName() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("admin_name")) + return a +} + +func (a *AccountResourceAssert) HasNoAdminPassword() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("admin_password")) + return a +} + +func (a *AccountResourceAssert) HasNoAdminRsaPublicKey() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("admin_rsa_public_key")) + return a +} + +func (a *AccountResourceAssert) HasNoComment() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("comment")) + return a +} + +func (a *AccountResourceAssert) HasNoEdition() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("edition")) + return a +} + +func (a *AccountResourceAssert) HasNoEmail() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("email")) + return a +} + +func (a *AccountResourceAssert) HasNoFirstName() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("first_name")) + return a +} + +func (a *AccountResourceAssert) HasNoFullyQualifiedName() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return a +} + +func (a *AccountResourceAssert) HasNoGracePeriodInDays() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("grace_period_in_days")) + return a +} + +func (a *AccountResourceAssert) HasNoIsOrgAdmin() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("is_org_admin")) + return a +} + +func (a *AccountResourceAssert) HasNoLastName() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("last_name")) + return a +} + +func (a *AccountResourceAssert) HasNoMustChangePassword() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("must_change_password")) + return a +} + +func (a *AccountResourceAssert) HasNoName() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("name")) + return a +} + +func (a *AccountResourceAssert) HasNoRegion() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("region")) + return a +} + +func (a *AccountResourceAssert) HasNoRegionGroup() *AccountResourceAssert { + a.AddAssertion(assert.ValueNotSet("region_group")) + return a +} 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 0352763bb0..2c48ff623c 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -117,4 +117,8 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "Task", schema: resources.Task().Schema, }, + { + name: "Account", + schema: resources.Account().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/account_resource_parameters_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/account_resource_parameters_gen.go new file mode 100644 index 0000000000..462254c997 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/account_resource_parameters_gen.go @@ -0,0 +1,52 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceparametersassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type AccountResourceParametersAssert struct { + *assert.ResourceAssert +} + +func AccountResourceParameters(t *testing.T, name string) *AccountResourceParametersAssert { + t.Helper() + + resourceParameterAssert := AccountResourceParametersAssert{ + ResourceAssert: assert.NewResourceAssert(name, "parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +func ImportedAccountResourceParameters(t *testing.T, id string) *AccountResourceParametersAssert { + t.Helper() + + resourceParameterAssert := AccountResourceParametersAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +//////////////////////////// +// Parameter value checks // +//////////////////////////// + +func (a *AccountResourceParametersAssert) HasEnableUnredactedQuerySyntaxError(expected bool) *AccountResourceParametersAssert { + a.AddAssertion(assert.ResourceParameterBoolValueSet(sdk.AccountParameterEnableUnredactedQuerySyntaxError, expected)) + return a +} + +//////////////////////////// +// Parameter level checks // +//////////////////////////// + +func (a *AccountResourceParametersAssert) HasEnableUnredactedQuerySyntaxErrorLevel(expected sdk.ParameterType) *AccountResourceParametersAssert { + a.AddAssertion(assert.ResourceParameterLevelSet(sdk.AccountParameterEnableUnredactedQuerySyntaxError, expected)) + return a +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/account_show_output_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/account_show_output_gen.go new file mode 100644 index 0000000000..f2b91e7ad7 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/account_show_output_gen.go @@ -0,0 +1,187 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceshowoutputassert + +import ( + "testing" + "time" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +// to ensure sdk package is used +var _ = sdk.Object{} + +type AccountShowOutputAssert struct { + *assert.ResourceAssert +} + +func AccountShowOutput(t *testing.T, name string) *AccountShowOutputAssert { + t.Helper() + + a := AccountShowOutputAssert{ + ResourceAssert: assert.NewResourceAssert(name, "show_output"), + } + a.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &a +} + +func ImportedAccountShowOutput(t *testing.T, id string) *AccountShowOutputAssert { + t.Helper() + + a := AccountShowOutputAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "show_output"), + } + a.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &a +} + +//////////////////////////// +// Attribute value checks // +//////////////////////////// + +func (a *AccountShowOutputAssert) HasOrganizationName(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("organization_name", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasAccountName(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_name", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasSnowflakeRegion(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("snowflake_region", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasRegionGroup(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("region_group", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasEdition(expected sdk.AccountEdition) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputStringUnderlyingValueSet("edition", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasAccountURL(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_url", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasCreatedOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("created_on", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasComment(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("comment", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasAccountLocator(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_locator", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasAccountLocatorURL(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_locator_url", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasManagedAccounts(expected int) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputIntValueSet("managed_accounts", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasConsumptionBillingEntityName(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("consumption_billing_entity_name", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasMarketplaceConsumerBillingEntityName(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("marketplace_consumer_billing_entity_name", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasMarketplaceProviderBillingEntityName(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("marketplace_provider_billing_entity_name", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasOldAccountURL(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("old_account_url", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasIsOrgAdmin(expected bool) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_org_admin", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasAccountOldUrlSavedOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_old_url_saved_on", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasAccountOldUrlLastUsed(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("account_old_url_last_used", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasOrganizationOldUrl(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("organization_old_url", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasOrganizationOldUrlSavedOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("organization_old_url_saved_on", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasOrganizationOldUrlLastUsed(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("organization_old_url_last_used", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasIsEventsAccount(expected bool) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_events_account", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasIsOrganizationAccount(expected bool) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_organization_account", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasDroppedOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("dropped_on", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasScheduledDeletionTime(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("scheduled_deletion_time", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasRestoredOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("restored_on", expected.String())) + return a +} + +func (a *AccountShowOutputAssert) HasMovedToOrganization(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("moved_to_organization", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasMovedOn(expected string) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("moved_on", expected)) + return a +} + +func (a *AccountShowOutputAssert) HasOrganizationUrlExpirationOn(expected time.Time) *AccountShowOutputAssert { + a.AddAssertion(assert.ResourceShowOutputValueSet("organization_url_expiration_on", expected.String())) + return a +} diff --git a/pkg/acceptance/bettertestspoc/config/datasourcemodel/accounts_model_gen.go b/pkg/acceptance/bettertestspoc/config/datasourcemodel/accounts_model_gen.go new file mode 100644 index 0000000000..382a0d2e28 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/accounts_model_gen.go @@ -0,0 +1,58 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package datasourcemodel + +import ( + 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 AccountsModel struct { + Accounts tfconfig.Variable `json:"accounts,omitempty"` + Pattern tfconfig.Variable `json:"pattern,omitempty"` + + *config.DatasourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func Accounts( + datasourceName string, +) *AccountsModel { + a := &AccountsModel{DatasourceModelMeta: config.DatasourceMeta(datasourceName, datasources.Accounts)} + return a +} + +func AccountsWithDefaultMeta() *AccountsModel { + a := &AccountsModel{DatasourceModelMeta: config.DatasourceDefaultMeta(datasources.Accounts)} + return a +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// accounts attribute type is not yet supported, so WithAccounts can't be generated + +func (a *AccountsModel) WithPattern(pattern string) *AccountsModel { + a.Pattern = tfconfig.StringVariable(pattern) + return a +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (a *AccountsModel) WithAccountsValue(value tfconfig.Variable) *AccountsModel { + a.Accounts = value + return a +} + +func (a *AccountsModel) WithPatternValue(value tfconfig.Variable) *AccountsModel { + a.Pattern = value + return a +} 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 e507ea2800..b0cecb97b0 100644 --- a/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/config/datasourcemodel/gen/datasource_schema_def.go @@ -30,4 +30,8 @@ var allDatasourcesSchemaDefs = []DatasourceSchemaDef{ name: "Databases", schema: datasources.Databases().Schema, }, + { + name: "Accounts", + schema: datasources.Accounts().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/config/model/account_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/account_model_gen.go new file mode 100644 index 0000000000..87ddf58d4e --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/account_model_gen.go @@ -0,0 +1,221 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + 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 AccountModel struct { + AdminName tfconfig.Variable `json:"admin_name,omitempty"` + AdminPassword tfconfig.Variable `json:"admin_password,omitempty"` + AdminRsaPublicKey tfconfig.Variable `json:"admin_rsa_public_key,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Edition tfconfig.Variable `json:"edition,omitempty"` + Email tfconfig.Variable `json:"email,omitempty"` + FirstName tfconfig.Variable `json:"first_name,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + GracePeriodInDays tfconfig.Variable `json:"grace_period_in_days,omitempty"` + IsOrgAdmin tfconfig.Variable `json:"is_org_admin,omitempty"` + LastName tfconfig.Variable `json:"last_name,omitempty"` + MustChangePassword tfconfig.Variable `json:"must_change_password,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + Region tfconfig.Variable `json:"region,omitempty"` + RegionGroup tfconfig.Variable `json:"region_group,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func Account( + resourceName string, + adminName string, + edition string, + email string, + name string, +) *AccountModel { + a := &AccountModel{ResourceModelMeta: config.Meta(resourceName, resources.Account)} + a.WithAdminName(adminName) + a.WithEdition(edition) + a.WithEmail(email) + a.WithName(name) + return a +} + +func AccountWithDefaultMeta( + adminName string, + edition string, + email string, + name string, +) *AccountModel { + a := &AccountModel{ResourceModelMeta: config.DefaultMeta(resources.Account)} + a.WithAdminName(adminName) + a.WithEdition(edition) + a.WithEmail(email) + a.WithName(name) + return a +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (a *AccountModel) WithAdminName(adminName string) *AccountModel { + a.AdminName = tfconfig.StringVariable(adminName) + return a +} + +func (a *AccountModel) WithAdminPassword(adminPassword string) *AccountModel { + a.AdminPassword = tfconfig.StringVariable(adminPassword) + return a +} + +func (a *AccountModel) WithAdminRsaPublicKey(adminRsaPublicKey string) *AccountModel { + a.AdminRsaPublicKey = tfconfig.StringVariable(adminRsaPublicKey) + return a +} + +func (a *AccountModel) WithComment(comment string) *AccountModel { + a.Comment = tfconfig.StringVariable(comment) + return a +} + +func (a *AccountModel) WithEdition(edition string) *AccountModel { + a.Edition = tfconfig.StringVariable(edition) + return a +} + +func (a *AccountModel) WithEmail(email string) *AccountModel { + a.Email = tfconfig.StringVariable(email) + return a +} + +func (a *AccountModel) WithFirstName(firstName string) *AccountModel { + a.FirstName = tfconfig.StringVariable(firstName) + return a +} + +func (a *AccountModel) WithFullyQualifiedName(fullyQualifiedName string) *AccountModel { + a.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return a +} + +func (a *AccountModel) WithGracePeriodInDays(gracePeriodInDays int) *AccountModel { + a.GracePeriodInDays = tfconfig.IntegerVariable(gracePeriodInDays) + return a +} + +func (a *AccountModel) WithIsOrgAdmin(isOrgAdmin bool) *AccountModel { + a.IsOrgAdmin = tfconfig.BoolVariable(isOrgAdmin) + return a +} + +func (a *AccountModel) WithLastName(lastName string) *AccountModel { + a.LastName = tfconfig.StringVariable(lastName) + return a +} + +func (a *AccountModel) WithMustChangePassword(mustChangePassword bool) *AccountModel { + a.MustChangePassword = tfconfig.BoolVariable(mustChangePassword) + return a +} + +func (a *AccountModel) WithName(name string) *AccountModel { + a.Name = tfconfig.StringVariable(name) + return a +} + +func (a *AccountModel) WithRegion(region string) *AccountModel { + a.Region = tfconfig.StringVariable(region) + return a +} + +func (a *AccountModel) WithRegionGroup(regionGroup string) *AccountModel { + a.RegionGroup = tfconfig.StringVariable(regionGroup) + return a +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (a *AccountModel) WithAdminNameValue(value tfconfig.Variable) *AccountModel { + a.AdminName = value + return a +} + +func (a *AccountModel) WithAdminPasswordValue(value tfconfig.Variable) *AccountModel { + a.AdminPassword = value + return a +} + +func (a *AccountModel) WithAdminRsaPublicKeyValue(value tfconfig.Variable) *AccountModel { + a.AdminRsaPublicKey = value + return a +} + +func (a *AccountModel) WithCommentValue(value tfconfig.Variable) *AccountModel { + a.Comment = value + return a +} + +func (a *AccountModel) WithEditionValue(value tfconfig.Variable) *AccountModel { + a.Edition = value + return a +} + +func (a *AccountModel) WithEmailValue(value tfconfig.Variable) *AccountModel { + a.Email = value + return a +} + +func (a *AccountModel) WithFirstNameValue(value tfconfig.Variable) *AccountModel { + a.FirstName = value + return a +} + +func (a *AccountModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *AccountModel { + a.FullyQualifiedName = value + return a +} + +func (a *AccountModel) WithGracePeriodInDaysValue(value tfconfig.Variable) *AccountModel { + a.GracePeriodInDays = value + return a +} + +func (a *AccountModel) WithIsOrgAdminValue(value tfconfig.Variable) *AccountModel { + a.IsOrgAdmin = value + return a +} + +func (a *AccountModel) WithLastNameValue(value tfconfig.Variable) *AccountModel { + a.LastName = value + return a +} + +func (a *AccountModel) WithMustChangePasswordValue(value tfconfig.Variable) *AccountModel { + a.MustChangePassword = value + return a +} + +func (a *AccountModel) WithNameValue(value tfconfig.Variable) *AccountModel { + a.Name = value + return a +} + +func (a *AccountModel) WithRegionValue(value tfconfig.Variable) *AccountModel { + a.Region = value + return a +} + +func (a *AccountModel) WithRegionGroupValue(value tfconfig.Variable) *AccountModel { + a.RegionGroup = value + return a +} diff --git a/pkg/acceptance/helpers/account_client.go b/pkg/acceptance/helpers/account_client.go index 5bcef72bec..96605949ab 100644 --- a/pkg/acceptance/helpers/account_client.go +++ b/pkg/acceptance/helpers/account_client.go @@ -115,6 +115,11 @@ func (c *AccountClient) ShowRegions(t *testing.T) []Region { return regions } +func (c *AccountClient) Show(t *testing.T, id sdk.AccountObjectIdentifier) (*sdk.Account, error) { + t.Helper() + return c.client().ShowByID(context.Background(), id) +} + func (c *AccountClient) CreateAndLogIn(t *testing.T) (*sdk.Account, *sdk.Client, func()) { t.Helper() id := c.ids.RandomAccountObjectIdentifier() diff --git a/pkg/acceptance/helpers/random/certs.go b/pkg/acceptance/helpers/random/certs.go index b314a0cbfa..c0e0142d7c 100644 --- a/pkg/acceptance/helpers/random/certs.go +++ b/pkg/acceptance/helpers/random/certs.go @@ -60,6 +60,15 @@ func GenerateRSAPublicKeyFromPrivateKey(t *testing.T, key *rsa.PrivateKey) (stri return encode(t, "RSA PUBLIC KEY", b), hash(t, b) } +func GenerateRSAPublicKeyBasedOnPrivateKey(t *testing.T, key *rsa.PrivateKey) (string, string) { + t.Helper() + + pub := key.Public() + b, err := x509.MarshalPKIXPublicKey(pub.(*rsa.PublicKey)) + require.NoError(t, err) + return encode(t, "RSA PUBLIC KEY", b), hash(t, b) +} + // GenerateRSAPrivateKey returns an RSA private key. func GenerateRSAPrivateKey(t *testing.T) *rsa.PrivateKey { t.Helper()