Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iam): add a print for visibility #12639

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions iam/cloud-client/snippets/get_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def get_project_policy(project_id: str) -> policy_pb2.Policy:
request.resource = f"projects/{project_id}"

policy = client.get_iam_policy(request)
print(f"Policy retrieved: {policy}")

return policy


Expand Down
13 changes: 8 additions & 5 deletions iam/cloud-client/snippets/test_service_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
import uuid

import backoff
Expand All @@ -32,8 +31,8 @@
PROJECT = google.auth.default()[1]


@pytest.fixture(scope="function")
def service_account(capsys: "pytest.CaptureFixture[str]") -> str:
@pytest.fixture(scope="module")
def service_account() -> str:
name = f"test-{uuid.uuid4().hex[:25]}"
created = False
try:
Expand All @@ -44,8 +43,12 @@ def service_account(capsys: "pytest.CaptureFixture[str]") -> str:
finally:
if created:
delete_service_account(PROJECT, email)
out, _ = capsys.readouterr()
assert re.search(f"Deleted a service account: {email}", out)
try:
get_service_account(PROJECT, email)
except google.api_core.exceptions.NotFound:
pass
else:
pytest.fail(f"The {email} service account was not deleted.")


def test_list_service_accounts(service_account: str) -> None:
Expand Down