From 6851e57697a4ba36758701bf2f6607526f989f99 Mon Sep 17 00:00:00 2001 From: Ryan Oaks Date: Thu, 9 Feb 2023 14:52:00 -0500 Subject: [PATCH] Move billing tests that require permissions beyond Billing User to master billing account (#7263) --- mmv1/products/billingbudget/terraform.yaml | 12 ++++++------ mmv1/provider/terraform/examples.rb | 2 ++ mmv1/templates/terraform/env_var_context.go.erb | 2 ++ .../terraform/tests/resource_billing_budget_test.go | 6 +++--- .../resource_google_billing_account_iam_test.go | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mmv1/products/billingbudget/terraform.yaml b/mmv1/products/billingbudget/terraform.yaml index 050dd3db8d45..8089e15eb3fd 100644 --- a/mmv1/products/billingbudget/terraform.yaml +++ b/mmv1/products/billingbudget/terraform.yaml @@ -33,21 +33,21 @@ overrides: !ruby/object:Overrides::ResourceOverrides vars: display_name: 'Example Billing Budget' test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT - !ruby/object:Provider::Terraform::Examples name: 'billing_budget_lastperiod' primary_resource_id: 'budget' vars: display_name: 'Example Billing Budget' test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT - !ruby/object:Provider::Terraform::Examples name: 'billing_budget_filter' primary_resource_id: 'budget' vars: display_name: 'Example Billing Budget' test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT - !ruby/object:Provider::Terraform::Examples name: 'billing_budget_notify' primary_resource_id: 'budget' @@ -55,14 +55,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides budget_name: 'Example Billing Budget' channel_name: 'Example Notification Channel' test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT - !ruby/object:Provider::Terraform::Examples name: 'billing_budget_customperiod' primary_resource_id: 'budget' vars: display_name: 'Example Billing Budget' test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT - !ruby/object:Provider::Terraform::Examples name: 'billing_budget_optional' primary_resource_id: 'budget' @@ -71,7 +71,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides display_name: 'Example Billing Budget' topic_name: "example-topic" test_env_vars: - billing_acct: :BILLING_ACCT + billing_acct: :MASTER_BILLING_ACCT properties: name: !ruby/object:Overrides::Terraform::PropertyOverride custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' diff --git a/mmv1/provider/terraform/examples.rb b/mmv1/provider/terraform/examples.rb index 6811b9e5d35e..4a1b7d354b45 100644 --- a/mmv1/provider/terraform/examples.rb +++ b/mmv1/provider/terraform/examples.rb @@ -63,6 +63,7 @@ class Examples < Api::Object # - :ORG_ID # - :ORG_TARGET # - :BILLING_ACCT + # - :MASTER_BILLING_ACCT # - :SERVICE_ACCT # - :CUST_ID # - :IDENTITY_USER @@ -158,6 +159,7 @@ def config_documentation(pwd) ORG_DOMAIN: 'example.com', ORG_TARGET: '123456789', BILLING_ACCT: '000000-0000000-0000000-000000', + MASTER_BILLING_ACCT: '000000-0000000-0000000-000000', SERVICE_ACCT: 'emailAddress:my@service-account.com', CUST_ID: 'A01b123xz', IDENTITY_USER: 'cloud_identity_user' diff --git a/mmv1/templates/terraform/env_var_context.go.erb b/mmv1/templates/terraform/env_var_context.go.erb index 3d9ac7b88a0d..95b11b764da6 100644 --- a/mmv1/templates/terraform/env_var_context.go.erb +++ b/mmv1/templates/terraform/env_var_context.go.erb @@ -11,6 +11,8 @@ "<%= var_name -%>": getTestOrgTargetFromEnv(t), <% elsif var_type == :BILLING_ACCT -%> "<%= var_name -%>": getTestBillingAccountFromEnv(t), + <% elsif var_type == :MASTER_BILLING_ACCT -%> + "<%= var_name -%>": getTestMasterBillingAccountFromEnv(t), <% elsif var_type == :SERVICE_ACCT -%> "<%= var_name -%>": getTestServiceAccountFromEnv(t), <% elsif var_type == :PROJECT_NAME -%> diff --git a/mmv1/third_party/terraform/tests/resource_billing_budget_test.go b/mmv1/third_party/terraform/tests/resource_billing_budget_test.go index e4ccc3cf3773..cc8476b6ce2d 100644 --- a/mmv1/third_party/terraform/tests/resource_billing_budget_test.go +++ b/mmv1/third_party/terraform/tests/resource_billing_budget_test.go @@ -11,7 +11,7 @@ func TestAccBillingBudget_billingBudgetCurrencycode(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "billing_acct": getTestBillingAccountFromEnv(t), + "billing_acct": getTestMasterBillingAccountFromEnv(t), "random_suffix": randString(t, 10), } @@ -69,7 +69,7 @@ func TestAccBillingBudget_billingBudgetUpdate(t *testing.T) { t.Parallel() context := map[string]interface{}{ - "billing_acct": getTestBillingAccountFromEnv(t), + "billing_acct": getTestMasterBillingAccountFromEnv(t), "random_suffix": randString(t, 10), } @@ -542,7 +542,7 @@ func TestAccBillingBudget_budgetFilterProjectsOrdering(t *testing.T) { context := map[string]interface{}{ "org": getTestOrgFromEnv(t), - "billing_acct": getTestBillingAccountFromEnv(t), + "billing_acct": getTestMasterBillingAccountFromEnv(t), "random_suffix_1": randString(t, 10), "random_suffix_2": randString(t, 10), } diff --git a/mmv1/third_party/terraform/tests/resource_google_billing_account_iam_test.go b/mmv1/third_party/terraform/tests/resource_google_billing_account_iam_test.go index 545e14ec232b..7b34187edfc0 100644 --- a/mmv1/third_party/terraform/tests/resource_google_billing_account_iam_test.go +++ b/mmv1/third_party/terraform/tests/resource_google_billing_account_iam_test.go @@ -15,7 +15,7 @@ func TestAccBillingAccountIam(t *testing.T) { skipIfVcr(t) t.Parallel() - billing := getTestBillingAccountFromEnv(t) + billing := getTestMasterBillingAccountFromEnv(t) account := fmt.Sprintf("tf-test-%d", randInt(t)) role := "roles/billing.viewer" vcrTest(t, resource.TestCase{