本文整理汇总了Python中swift3.subresource.encode_acl函数的典型用法代码示例。如果您正苦于以下问题:Python encode_acl函数的具体用法?Python encode_acl怎么用?Python encode_acl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode_acl函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _test_set_container_permission
def _test_set_container_permission(self, account, permission):
grants = [Grant(User(account), permission)]
headers = \
encode_acl('container',
ACL(Owner('test:tester', 'test:tester'), grants))
self.swift.register('HEAD', '/v1/AUTH_test/bucket',
swob.HTTPNoContent, headers, None)
开发者ID:sivakrishnan47,项目名称:swift3,代码行数:7,代码来源:test_obj.py
示例2: _gen_test_acl_header
def _gen_test_acl_header(owner, permission=None, grantee=None,
resource='container'):
if permission is None:
return ACL(owner, [])
if grantee is None:
grantee = User('test:tester')
return encode_acl(resource, ACL(owner, [Grant(grantee, permission)]))
开发者ID:notmyname,项目名称:swift3,代码行数:8,代码来源:test_request.py
示例3: test_encode_acl_object
def test_encode_acl_object(self):
acl = ACLPrivate(Owner(id='test:tester',
name='test:tester'))
acp = encode_acl('object', acl)
header_value = json.loads(acp[sysmeta_header('object', 'acl')])
self.assertTrue('Owner' in header_value)
self.assertTrue('Grant' in header_value)
self.assertEqual('test:tester', header_value['Owner'])
self.assertEqual(len(header_value['Grant']), 1)
开发者ID:tipabu,项目名称:swift3,代码行数:10,代码来源:test_subresource.py
示例4: _test_object_PUT_copy_self
def _test_object_PUT_copy_self(self, head_resp, put_header={}):
account = 'test:tester'
grants = [Grant(User(account), 'FULL_CONTROL')]
head_headers = \
encode_acl('object',
ACL(Owner(account, account), grants))
head_headers.update({'last-modified': self.last_modified})
self.swift.register('HEAD', '/v1/AUTH_test/bucket/object',
head_resp, head_headers, None)
return self._call_object_copy('/bucket/object', put_header)
开发者ID:tipabu,项目名称:swift3,代码行数:10,代码来源:test_obj.py
示例5: test_object_PUT_copy_without_dst_obj_permission
def test_object_PUT_copy_without_dst_obj_permission(self):
account = 'test:other'
grants = [Grant(User(account), 'WRITE')]
headers = encode_acl('container',
ACL(Owner(account, account), grants))
self.swift.register('HEAD', '/v1/AUTH_test/bucket',
swob.HTTPNoContent, headers, None)
status, headers, body = \
self._test_object_copy_for_s3acl(account, 'READ')
self.assertEquals(status.split()[0], '403')
开发者ID:yinyinbigdata,项目名称:swift3-stackforge,代码行数:10,代码来源:test_obj.py
示例6: PUT
def PUT(self, app):
if not self.obj:
# Initiate Multipart Uploads (put +segment container)
resp = self._handle_acl(app, 'HEAD')
req_acl = ACL.from_headers(self.req.headers,
resp.bucket_acl.owner,
Owner(self.user_id, self.user_id))
acl_headers = encode_acl('object', req_acl)
self.req.headers[sysmeta_header('object', 'tmpacl')] = \
acl_headers[sysmeta_header('object', 'acl')]
开发者ID:tipabu,项目名称:swift3,代码行数:10,代码来源:acl_handlers.py
示例7: _test_object_PUT_copy
def _test_object_PUT_copy(self, head_resp, put_header=None,
src_path='/some/source', timestamp=None):
account = 'test:tester'
grants = [Grant(User(account), 'FULL_CONTROL')]
head_headers = \
encode_acl('object',
ACL(Owner(account, account), grants))
head_headers.update({'last-modified': self.last_modified})
self.swift.register('HEAD', '/v1/AUTH_test/some/source',
head_resp, head_headers, None)
put_header = put_header or {}
return self._call_object_copy(src_path, put_header, timestamp)
开发者ID:swiftstack,项目名称:swift3-stackforge,代码行数:12,代码来源:test_obj.py
示例8: _test_object_copy_for_s3acl
def _test_object_copy_for_s3acl(self, account, src_permission=None, src_path="/src_bucket/src_obj"):
owner = "test:tester"
grants = [Grant(User(account), src_permission)] if src_permission else [Grant(User(owner), "FULL_CONTROL")]
src_o_headers = encode_acl("object", ACL(Owner(owner, owner), grants))
src_o_headers.update({"last-modified": self.last_modified})
self.swift.register("HEAD", join("/v1/AUTH_test", src_path.lstrip("/")), swob.HTTPOk, src_o_headers, None)
req = Request.blank(
"/bucket/object",
environ={"REQUEST_METHOD": "PUT"},
headers={"Authorization": "AWS %s:hmac" % account, "X-Amz-Copy-Source": src_path},
)
return self.call_swift3(req)
开发者ID:MahatiC,项目名称:swift3,代码行数:14,代码来源:test_obj.py
示例9: _test_object_PUT_copy
def _test_object_PUT_copy(self, head_resp, put_header={}):
account = "test:tester"
grants = [Grant(User(account), "FULL_CONTROL")]
head_headers = encode_acl("object", ACL(Owner(account, account), grants))
head_headers.update({"last-modified": self.last_modified})
self.swift.register("HEAD", "/v1/AUTH_test/some/source", head_resp, head_headers, None)
put_headers = {"Authorization": "AWS test:tester:hmac", "X-Amz-Copy-Source": "/some/source"}
put_headers.update(put_header)
req = Request.blank("/bucket/object", environ={"REQUEST_METHOD": "PUT"}, headers=put_headers)
req.date = datetime.now()
req.content_type = "text/plain"
return self.call_swift3(req)
开发者ID:MahatiC,项目名称:swift3,代码行数:15,代码来源:test_obj.py
示例10: test_bucket_PUT_with_canned_s3acl
def test_bucket_PUT_with_canned_s3acl(self):
account = 'test:tester'
acl = \
encode_acl('container', ACLPublicRead(Owner(account, account)))
req = Request.blank('/bucket',
environ={'REQUEST_METHOD': 'PUT'},
headers={'Authorization': 'AWS test:tester:hmac',
'X-Amz-Acl': 'public-read'})
status, headers, body = self.call_swift3(req)
self.assertEquals(status.split()[0], '200')
_, _, headers = self.swift.calls_with_headers[-1]
self.assertTrue('X-Container-Read' not in headers)
self.assertTrue('X-Container-Sysmeta-Swift3-Acl' in headers)
self.assertEquals(headers.get('X-Container-Sysmeta-Swift3-Acl'),
acl['x-container-sysmeta-swift3-acl'])
开发者ID:thiagodasilva,项目名称:swift3,代码行数:15,代码来源:test_bucket.py
示例11: test_encode_acl_many_grant
def test_encode_acl_many_grant(self):
headers = {}
users = []
for i in range(0, 99):
users.append('id=test:tester%s' % str(i))
users = ','.join(users)
headers['x-amz-grant-read'] = users
acl = ACL.from_headers(headers, Owner('test:tester', 'test:tester'))
acp = encode_acl('container', acl)
header_value = acp[sysmeta_header('container', 'acl')]
header_value = json.loads(header_value)
self.assertTrue('Owner' in header_value)
self.assertTrue('Grant' in header_value)
self.assertEqual('test:tester', header_value['Owner'])
self.assertEqual(len(header_value['Grant']), 99)
开发者ID:tipabu,项目名称:swift3,代码行数:17,代码来源:test_subresource.py
示例12: _test_object_copy_for_s3acl
def _test_object_copy_for_s3acl(self, account, src_permission=None,
src_path='/src_bucket/src_obj'):
owner = 'test:tester'
grants = [Grant(User(account), src_permission)] \
if src_permission else [Grant(User(owner), 'FULL_CONTROL')]
src_o_headers = \
encode_acl('object', ACL(Owner(owner, owner), grants))
self.swift.register(
'HEAD', join('/v1/AUTH_test', src_path.lstrip('/')),
swob.HTTPOk, src_o_headers, None)
req = Request.blank(
'/bucket/object',
environ={'REQUEST_METHOD': 'PUT'},
headers={'Authorization': 'AWS %s:hmac' % account,
'X-Amz-Copy-Source': src_path})
return self.call_swift3(req)
开发者ID:yinyinbigdata,项目名称:swift3-stackforge,代码行数:18,代码来源:test_obj.py
示例13: test_service_GET_without_owner_bucket
def test_service_GET_without_owner_bucket(self):
bucket_list = []
for var in range(0, 10):
user_id = 'test:other'
bucket = 'bucket%s' % var
owner = Owner(user_id, user_id)
headers = encode_acl('container', ACL(owner, []))
self.swift.register('HEAD', '/v1/AUTH_test/%s' % bucket,
swob.HTTPNoContent, headers, None)
bucket_list.append((bucket, var, 300 + var))
status, headers, body = \
self._test_service_GET_for_check_bucket_owner(bucket_list)
self.assertEquals(status.split()[0], '200')
elem = fromstring(body, 'ListAllMyBucketsResult')
resp_buckets = elem.find('./Buckets')
buckets = resp_buckets.iterchildren('Bucket')
self.assertEquals(len(list(buckets)), 0)
开发者ID:KoreaCloudObjectStorage,项目名称:swift3,代码行数:20,代码来源:test_service.py
示例14: test_service_GET_bucekt_list
def test_service_GET_bucekt_list(self):
bucket_list = []
for var in range(0, 10):
if var % 3 == 0:
user_id = 'test:tester'
else:
user_id = 'test:other'
bucket = 'bucket%s' % var
owner = Owner(user_id, user_id)
headers = encode_acl('container', ACL(owner, []))
# set register to get owner of buckets
if var % 3 == 2:
self.swift.register('HEAD', '/v1/AUTH_test/%s' % bucket,
swob.HTTPNotFound, {}, None)
else:
self.swift.register('HEAD', '/v1/AUTH_test/%s' % bucket,
swob.HTTPNoContent, headers, None)
bucket_list.append((bucket, var, 300 + var))
status, headers, body = \
self._test_service_GET_for_check_bucket_owner(bucket_list)
self.assertEquals(status.split()[0], '200')
elem = fromstring(body, 'ListAllMyBucketsResult')
resp_buckets = elem.find('./Buckets')
buckets = resp_buckets.iterchildren('Bucket')
listing = list(list(buckets)[0])
self.assertEquals(len(listing), 2)
names = []
for b in resp_buckets.iterchildren('Bucket'):
names.append(b.find('./Name').text)
# Check whether getting bucket only locate in multiples of 3 in
# bucket_list which mean requested user is owner.
expected_buckets = [b for i, b in enumerate(bucket_list)
if i % 3 == 0]
self.assertEquals(len(names), len(expected_buckets))
for i in expected_buckets:
self.assertTrue(i[0] in names)
self.assertEquals(len(self.swift.calls_with_headers), 11)
开发者ID:KoreaCloudObjectStorage,项目名称:swift3,代码行数:41,代码来源:test_service.py
示例15: _test_object_PUT_copy
def _test_object_PUT_copy(self, head_resp, put_header={}):
account = 'test:tester'
grants = [Grant(User(account), 'FULL_CONTROL')]
head_headers = \
encode_acl('object',
ACL(Owner(account, account), grants))
head_headers.update({'last-modified': self.last_modified})
self.swift.register('HEAD', '/v1/AUTH_test/some/source',
head_resp, head_headers, None)
put_headers = {'Authorization': 'AWS test:tester:hmac',
'X-Amz-Copy-Source': '/some/source'}
put_headers.update(put_header)
req = Request.blank('/bucket/object',
environ={'REQUEST_METHOD': 'PUT'},
headers=put_headers)
req.date = datetime.now()
req.content_type = 'text/plain'
return self.call_swift3(req)
开发者ID:erwasambo,项目名称:swift3,代码行数:21,代码来源:test_obj.py
示例16: _gen_test_headers
def _gen_test_headers(owner, grants=[], resource='container'):
if not grants:
grants = [Grant(User('test:tester'), 'FULL_CONTROL')]
return encode_acl(resource, ACL(owner, grants))
开发者ID:sivakrishnan47,项目名称:swift3,代码行数:4,代码来源:test_s3_acl.py
示例17: setter
def setter(self, value):
self.headers.update(encode_acl(resource, value))
setattr(self, '_%s' % resource, value)
开发者ID:yinyinbigdata,项目名称:swift3-stackforge,代码行数:3,代码来源:request.py
示例18: _test_set_container_permission
def _test_set_container_permission(self, account, permission):
grants = [Grant(User(account), permission)]
headers = encode_acl("container", ACL(Owner("test:tester", "test:tester"), grants))
self.swift.register("HEAD", "/v1/AUTH_test/bucket", swob.HTTPNoContent, headers, None)
开发者ID:MahatiC,项目名称:swift3,代码行数:4,代码来源:test_obj.py
注:本文中的swift3.subresource.encode_acl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论