Skip to content

Commit

Permalink
refactor IAM test for loose match
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathkkb committed Jan 21, 2022
1 parent 5f17672 commit 0dccbb7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/integration/workload_metadata_config/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@
its(:exit_status) { should eq 0 }
its(:stderr) { should eq '' }

let!(:iam) do
let(:bindings) do
if subject.exit_status == 0
JSON.parse(subject.stdout)
JSON.parse(subject.stdout, symbolize_names: true)[:bindings]
else
{}
[]
end
end
it "has expected registry roles" do
expect(iam['bindings']).to include(
{"members" => ["serviceAccount:#{service_account}"], "role" => "roles/storage.objectViewer"},
{"members" => ["serviceAccount:#{service_account}"], "role" => "roles/artifactregistry.reader"}
expect(bindings).to include(
members: including("serviceAccount:#{service_account}"),
role: "roles/storage.objectViewer",
)
expect(bindings).to include(
members: including("serviceAccount:#{service_account}"),
role: "roles/artifactregistry.reader",
)
end
end
Expand Down

0 comments on commit 0dccbb7

Please sign in to comment.