• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python subresource.encode_acl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python s3_test_client.Connection类代码示例发布时间:2022-05-27
下一篇:
Python middleware.filter_factory函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap