|
34 | 34 | end |
35 | 35 | end |
36 | 36 |
|
37 | | - describe "custom_role" do |
| 37 | + describe "project_custom_role" do |
38 | 38 | it "have role" do |
39 | 39 | expect(data["description"]).to include("This is a project level custom role.") |
40 | 40 | expect(data["includedPermissions"]).to include("iam.roles.list") |
|
55 | 55 | end |
56 | 56 | end |
57 | 57 |
|
58 | | - describe "custom_role" do |
| 58 | + describe "organization_custom_role" do |
59 | 59 | it "have role" do |
60 | 60 | expect(data["description"]).to include("This is an organization level custom role.") |
61 | 61 | expect(data["includedPermissions"]).to include("iam.roles.list") |
62 | 62 | expect(data["includedPermissions"]).to include("iam.roles.delete") |
63 | 63 | end |
64 | 64 | end |
65 | 65 | end |
| 66 | + |
| 67 | + describe command ("gcloud projects get-iam-policy #{project_id} --format=json") do |
| 68 | + its(:exit_status) { should eq 0 } |
| 69 | + its(:stderr) { should eq '' } |
| 70 | + |
| 71 | + let!(:data) do |
| 72 | + if subject.exit_status == 0 |
| 73 | + JSON.parse(subject.stdout) |
| 74 | + else |
| 75 | + {} |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + describe "project_custom_role" do |
| 80 | + it "is bound to" do |
| 81 | + transformed_data={} |
| 82 | + data['bindings'].each do |binding| |
| 83 | + transformed_data.store(binding["role"],binding["members"]) |
| 84 | + end |
| 85 | + expect(transformed_data["projects/#{project_id}/roles/#{custom_role_id_project}"]).to include("serviceAccount:custom-role-account-01@#{project_id}.iam.gserviceaccount.com") |
| 86 | + end |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + describe command ("gcloud organizations get-iam-policy #{org_id} --format=json") do |
| 91 | + its(:exit_status) { should eq 0 } |
| 92 | + its(:stderr) { should eq '' } |
| 93 | + |
| 94 | + let!(:data) do |
| 95 | + if subject.exit_status == 0 |
| 96 | + JSON.parse(subject.stdout) |
| 97 | + else |
| 98 | + {} |
| 99 | + end |
| 100 | + end |
| 101 | + |
| 102 | + describe "organization_custom_role" do |
| 103 | + it "is bound to" do |
| 104 | + transformed_data={} |
| 105 | + data['bindings'].each do |binding| |
| 106 | + transformed_data.store(binding["role"],binding["members"]) |
| 107 | + end |
| 108 | + expect(transformed_data["organizations/#{org_id}/roles/#{custom_role_id_org}"]).to include("group:test-gcp-org-admins@test.infra.cft.tips") |
| 109 | + end |
| 110 | + end |
| 111 | + end |
66 | 112 | end |
0 commit comments