Exemplo n.º 1
0
 def _test_get_response(self, method, container='bucket', obj=None,
                        permission=None, skip_check=False,
                        req_klass=S3Request, fake_swift_resp=None):
     path = '/' + container + ('/' + obj if obj else '')
     req = Request.blank(path,
                         environ={'REQUEST_METHOD': method},
                         headers={'Authorization': 'AWS test:tester:hmac',
                                  'Date': self.get_date_header()})
     if issubclass(req_klass, S3AclRequest):
         s3_req = req_klass(
             req.environ, MagicMock(),
             True, self.conf.storage_domain,
             self.conf.location, self.conf.force_swift_request_proxy_log,
             self.conf.dns_compliant_bucket_names,
             self.conf.allow_multipart_uploads, self.conf.allow_no_owner)
     else:
         s3_req = req_klass(
             req.environ, MagicMock(),
             True, self.conf.storage_domain,
             self.conf.location, self.conf.force_swift_request_proxy_log,
             self.conf.dns_compliant_bucket_names,
             self.conf.allow_multipart_uploads, self.conf.allow_no_owner)
     s3_req.set_acl_handler(
         get_acl_handler(s3_req.controller_name)(s3_req, DebugLogger()))
     with patch('swift.common.middleware.s3api.s3request.S3Request.'
                '_get_response') as mock_get_resp, \
             patch('swift.common.middleware.s3api.subresource.ACL.'
                   'check_permission') as m_check_permission:
         mock_get_resp.return_value = fake_swift_resp \
             or FakeResponse(self.conf.s3_acl)
         return mock_get_resp, m_check_permission,\
             s3_req.get_response(self.s3api)
Exemplo n.º 2
0
 def __init__(self, testdir):
     self.logger = mock.MagicMock()
     self.conn_timeout = 1
     self.node_timeout = 2
     self.http_timeout = 3
     self.network_chunk_size = 65536
     self.disk_chunk_size = 4096
     conf = {
         'devices': testdir,
         'mount_check': 'false',
     }
     self._diskfile_mgr = diskfile.DiskFileManager(conf, DebugLogger())