Merge "s3api: Make grentee types case insensitive"
This commit is contained in:
commit
7d57539e91
@ -182,18 +182,19 @@ class Grantee(object):
|
|||||||
"""
|
"""
|
||||||
Convert a grantee string in the HTTP header to an Grantee instance.
|
Convert a grantee string in the HTTP header to an Grantee instance.
|
||||||
"""
|
"""
|
||||||
type, value = grantee.split('=', 1)
|
grantee_type, value = grantee.split('=', 1)
|
||||||
|
grantee_type = grantee_type.lower()
|
||||||
value = value.strip('"\'')
|
value = value.strip('"\'')
|
||||||
if type == 'id':
|
if grantee_type == 'id':
|
||||||
return User(value)
|
return User(value)
|
||||||
elif type == 'emailAddress':
|
elif grantee_type == 'emailaddress':
|
||||||
raise S3NotImplemented()
|
raise S3NotImplemented()
|
||||||
elif type == 'uri':
|
elif grantee_type == 'uri':
|
||||||
# return a subclass instance of Group class
|
# return a subclass instance of Group class
|
||||||
subclass = get_group_subclass_from_uri(value)
|
subclass = get_group_subclass_from_uri(value)
|
||||||
return subclass()
|
return subclass()
|
||||||
else:
|
else:
|
||||||
raise InvalidArgument(type, value,
|
raise InvalidArgument(grantee_type, value,
|
||||||
'Argument format not recognized')
|
'Argument format not recognized')
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,6 +379,17 @@ class TestS3ApiS3Acl(S3ApiTestCase):
|
|||||||
status, headers, body = self.call_s3api(req)
|
status, headers, body = self.call_s3api(req)
|
||||||
self.assertEqual(status.split()[0], '200')
|
self.assertEqual(status.split()[0], '200')
|
||||||
|
|
||||||
|
def test_grant_all_users_with_uppercase_type(self):
|
||||||
|
req = Request.blank('/bucket/object?acl',
|
||||||
|
environ={'REQUEST_METHOD': 'PUT'},
|
||||||
|
headers={'Authorization': 'AWS test:tester:hmac',
|
||||||
|
'Date': self.get_date_header(),
|
||||||
|
'x-amz-grant-read':
|
||||||
|
'URI="http://acs.amazonaws.com/groups/'
|
||||||
|
'global/AllUsers"'})
|
||||||
|
status, headers, body = self.call_s3api(req)
|
||||||
|
self.assertEqual(status.split()[0], '200')
|
||||||
|
|
||||||
def test_grant_invalid_uri(self):
|
def test_grant_invalid_uri(self):
|
||||||
req = Request.blank('/bucket/object?acl',
|
req = Request.blank('/bucket/object?acl',
|
||||||
environ={'REQUEST_METHOD': 'PUT'},
|
environ={'REQUEST_METHOD': 'PUT'},
|
||||||
|
Loading…
Reference in New Issue
Block a user