Skip to content

Commit

Permalink
chore: create access context manager policy ID in test if needed (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-cit authored May 28, 2024
1 parent e1605bd commit 2ca1683
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/integration/org/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ func TestOrg(t *testing.T) {
terraformSA := bootstrap.GetStringOutput("organization_step_terraform_service_account_email")
utils.SetEnv(t, "GOOGLE_IMPERSONATE_SERVICE_ACCOUNT", terraformSA)

// Create Access Context Manager Policy ID if needed
orgID := terraform.OutputMap(t, bootstrap.GetTFOptions(), "common_config")["org_id"]
policyID := testutils.GetOrgACMPolicyID(t, orgID)

if policyID == "" {
_, err := gcloud.RunCmdE(t, fmt.Sprintf("access-context-manager policies create --organization %s --title %s --impersonate-service-account %s", orgID, "defaultpolicy", terraformSA))
// ignore creation error and proceed with the test
if err != nil {
fmt.Printf("Ignore error in creation of access-context-manager policy ID for organization %s. Error: [%s]", orgID, err.Error())
}
}

org := tft.NewTFBlueprintTest(t,
tft.WithTFDir("../../../1-org/envs/shared"),
tft.WithVars(vars),
Expand Down Expand Up @@ -241,10 +253,9 @@ func TestOrg(t *testing.T) {
prjLogsExportDefaultSink := gcloud.Runf(t, "logging sinks describe _Default --project=%s", auditLogsProjectID)
exclusions := prjLogsExportDefaultSink.Get("exclusions").Array()
assert.NotEmpty(exclusions, fmt.Sprintf("exclusion list for _Default sink in project %s must not be empty", auditLogsProjectID))
exclusionFilter := fmt.Sprintf("-logName : \"/%s/\"",auditLogsProjectID)
exclusionFilter := fmt.Sprintf("-logName : \"/%s/\"", auditLogsProjectID)
assert.Equal(exclusions[0].Get("filter").String(), exclusionFilter)


// logging sinks
logsFilter := []string{
"logName: /logs/cloudaudit.googleapis.com%2Factivity",
Expand Down

0 comments on commit 2ca1683

Please sign in to comment.