Skip to content

Commit

Permalink
Update ResourceManager::Policy
Browse files Browse the repository at this point in the history
Add de-duplication of role members.

[refs googleapis#2091]
  • Loading branch information
quartzmo committed May 21, 2018
1 parent b921114 commit 3b8fa01
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def to_gapi
next if roles[role_name].empty?
API::Binding.new(
role: role_name,
members: roles[role_name]
members: roles[role_name].uniq
)
end
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@
role.frozen?.must_equal false
end

describe :to_gapi do
it "creates a Google::Apis::CloudresourcemanagerV1::Policy object with the equivalent de-duped roles" do
# Add a duplicate entry.
existing_role, existing_members = policy.roles.first
policy.add(existing_role, existing_members.first)

gapi_policy = policy.to_gapi

gapi_policy.class.must_equal Google::Apis::CloudresourcemanagerV1::Policy
gapi_policy.bindings.size.must_equal policy.roles.size
gapi_policy.bindings.each do |binding|
binding.members.sort.must_equal policy.roles[binding.role].uniq.sort
end
end
end

describe :from_gapi do
it "creates from a typical Google::Apis::CloudresourcemanagerV1::Policy object" do
gapi = Google::Apis::CloudresourcemanagerV1::Policy.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
end

describe :to_gapi do
it "creates a Google::Apis::StorageV1::Policy object with the equivalent deduped roles" do
it "creates a Google::Apis::StorageV1::Policy object with the equivalent de-duped roles" do
# Add a duplicate entry.
existing_role, existing_members = policy.roles.first
policy.add(existing_role, existing_members.first)
Expand Down

0 comments on commit 3b8fa01

Please sign in to comment.