File tree 1 file changed +8
-5
lines changed
iam/cloud-client/snippets
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 16
16
import re
17
17
import uuid
18
18
19
+ from google .api_core .exceptions import PermissionDenied
19
20
import google .auth
20
21
from google .cloud import iam_v2
21
22
from google .cloud .iam_admin_v1 import IAMClient , ListRolesRequest
34
35
@pytest .fixture
35
36
def deny_policy (capsys : "pytest.CaptureFixture[str]" ) -> None :
36
37
policy_id = f"test-deny-policy-{ uuid .uuid4 ()} "
38
+ try :
39
+ # Delete any existing policies. Otherwise it might throw quota issue.
40
+ delete_existing_deny_policies (PROJECT , "test-deny-policy" )
37
41
38
- # Delete any existing policies. Otherwise it might throw quota issue.
39
- delete_existing_deny_policies (PROJECT , "test-deny-policy" )
40
-
41
- # Create the Deny policy.
42
- create_deny_policy (PROJECT , policy_id )
42
+ # Create the Deny policy.
43
+ create_deny_policy (PROJECT , policy_id )
44
+ except PermissionDenied :
45
+ pytest .skip ("Don't have permissions to run this test." )
43
46
44
47
yield policy_id
45
48
You can’t perform that action at this time.
0 commit comments