FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: save empty IAM policy bindings by busunkim96 · Pull Request #155 · googleapis/python-api-core · GitHub

This repository was archived by the owner on Feb 23, 2026. It is now read-only.
/ python-api-core Public archive

fix: save empty IAM policy bindings - #155

Merged
busunkim96 merged 2 commits into
masterfrom
fix-154
Mar 23, 2021
Merged

fix: save empty IAM policy bindings#155
busunkim96 merged 2 commits into
masterfrom
fix-154

Conversation

busunkim96 commented Mar 22, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #154

__getitem__ currently returns an empty set() for items not in the bindings. If someone adds to the set returned by __getitem__ the changes will not be reflected on the actual policy object.

busunkim96 requested a review from a team March 22, 2021 21:52
google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 22, 2021
Comment thread tests/unit/test_iam.py
Comment on lines +35 to +36
assert len(policy) == 0
assert dict(policy) == {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Accessing policy.owners, policy.editors results in __getitem__ being called, which adds empty entries to the dictionary. I moved these empty dict asserts up as a result.

An alternative is to keep them in their previous location and check that the three roles with empty bindings were added

busunkim96 requested review from frankyn and parthea March 22, 2021 21:56
busunkim96 merged commit 536c2ca into master Mar 23, 2021
busunkim96 deleted the fix-154 branch March 23, 2021 19:16
gcf-merge-on-green Bot pushed a commit that referenced this pull request Mar 25, 2021
Exclude empty policy bindings (bindings with no members) in
`Policy.__iter__()` and `Policy.__len__()`

Follow up to #155
This was referenced May 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings

2 participants


Back | FazBrowse Home | New Git URL