@@ -1928,7 +1928,7 @@ def test_get_iam_policy(self):
19281928 BLOB_NAME = "blob-name"
19291929 PATH = "/b/name/o/%s" % (BLOB_NAME ,)
19301930 ETAG = "DEADBEEF"
1931- VERSION = 17
1931+ VERSION = 1
19321932 OWNER1 = "user:phred@example.com"
19331933 OWNER2 = "group:cloud-logs@google.com"
19341934 EDITOR1 = "domain:google.com"
@@ -1973,14 +1973,53 @@ def test_get_iam_policy(self):
19731973 },
19741974 )
19751975
1976+ def test_get_iam_policy_w_requested_policy_version (self ):
1977+ from google .cloud .storage .iam import STORAGE_OWNER_ROLE
1978+ from google .api_core .iam import Policy
1979+
1980+ BLOB_NAME = "blob-name"
1981+ PATH = "/b/name/o/%s" % (BLOB_NAME ,)
1982+ ETAG = "DEADBEEF"
1983+ VERSION = 3
1984+ OWNER1 = "user:phred@example.com"
1985+ OWNER2 = "group:cloud-logs@google.com"
1986+ RETURNED = {
1987+ "resourceId" : PATH ,
1988+ "etag" : ETAG ,
1989+ "version" : VERSION ,
1990+ "bindings" : [{"role" : STORAGE_OWNER_ROLE , "members" : [OWNER1 , OWNER2 ]}],
1991+ }
1992+ after = ({"status" : http_client .OK }, RETURNED )
1993+ EXPECTED = {
1994+ binding ["role" ]: set (binding ["members" ]) for binding in RETURNED ["bindings" ]
1995+ }
1996+ connection = _Connection (after )
1997+ client = _Client (connection )
1998+ bucket = _Bucket (client = client )
1999+ blob = self ._make_one (BLOB_NAME , bucket = bucket )
2000+
2001+ policy = blob .get_iam_policy ()
2002+
2003+ kw = connection ._requested
2004+ self .assertEqual (len (kw ), 1 )
2005+ self .assertEqual (
2006+ kw [0 ],
2007+ {
2008+ "method" : "GET" ,
2009+ "path" : "%s/iam" % (PATH ,),
2010+ "query_params" : {"optionsRequestedPolicyVersion" : 3 },
2011+ "_target_object" : None ,
2012+ },
2013+ )
2014+
19762015 def test_get_iam_policy_w_user_project (self ):
19772016 from google .api_core .iam import Policy
19782017
19792018 BLOB_NAME = "blob-name"
19802019 USER_PROJECT = "user-project-123"
19812020 PATH = "/b/name/o/%s" % (BLOB_NAME ,)
19822021 ETAG = "DEADBEEF"
1983- VERSION = 17
2022+ VERSION = 1
19842023 RETURNED = {
19852024 "resourceId" : PATH ,
19862025 "etag" : ETAG ,
@@ -2023,7 +2062,7 @@ def test_set_iam_policy(self):
20232062 BLOB_NAME = "blob-name"
20242063 PATH = "/b/name/o/%s" % (BLOB_NAME ,)
20252064 ETAG = "DEADBEEF"
2026- VERSION = 17
2065+ VERSION = 1
20272066 OWNER1 = "user:phred@example.com"
20282067 OWNER2 = "group:cloud-logs@google.com"
20292068 EDITOR1 = "domain:google.com"
@@ -2074,7 +2113,7 @@ def test_set_iam_policy_w_user_project(self):
20742113 USER_PROJECT = "user-project-123"
20752114 PATH = "/b/name/o/%s" % (BLOB_NAME ,)
20762115 ETAG = "DEADBEEF"
2077- VERSION = 17
2116+ VERSION = 1
20782117 BINDINGS = []
20792118 RETURNED = {"etag" : ETAG , "version" : VERSION , "bindings" : BINDINGS }
20802119 after = ({"status" : http_client .OK }, RETURNED )
0 commit comments