Skip to content

Commit

Permalink
fix: add infra pipeline CB SA role test (#450)
Browse files Browse the repository at this point in the history
* Update gcloud_projects.rb

This PR adds the test for the editor role on the Cloud Build service account and also removes the indexing from both service account tests.

* Update gcloud_projects.rb

* Update gcloud_projects.rb
  • Loading branch information
chris-ingrisani committed Apr 24, 2021
1 parent f1d90b3 commit e30fe8c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/integration/projects/controls/gcloud_projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
end
end
end

describe command("gcloud iam service-accounts get-iam-policy #{base_project_sa[environment_code][business_unit]} --format=json") do
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }
Expand All @@ -216,6 +217,31 @@
end
end

describe command("gcloud projects get-iam-policy #{base_projects_id[environment_code][business_unit]} --format=json") do
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }

let(:data) do
if subject.exit_status.zero?
JSON.parse(subject.stdout)
else
{}
end
end

describe "#{base_projects_id[environment_code][business_unit]} IAM Policy" do
it 'should exist' do
expect(data).to_not be_empty
end
it "#{base_project_sa[environment_code][business_unit]} Base project SA should have the Editor role on #{base_projects_id[environment_code][business_unit]}" do
expect(data['bindings'][1]['members']).to include(
"serviceAccount:#{base_project_sa[environment_code][business_unit]}"
)
expect(data['bindings'][1]['role']).to eq "roles/editor"
end
end
end

describe command("gcloud compute shared-vpc get-host-project #{restricted_projects_id[environment_code][business_unit]} --format=json") do
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }
Expand Down

0 comments on commit e30fe8c

Please sign in to comment.