当前位置: 首页>>代码示例>>Python>>正文


Python tempurl.filter_factory函数代码示例

本文整理汇总了Python中swift.common.middleware.tempurl.filter_factory函数的典型用法代码示例。如果您正苦于以下问题:Python filter_factory函数的具体用法?Python filter_factory怎么用?Python filter_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了filter_factory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_removed_outgoing_header

 def test_removed_outgoing_header(self):
     self.tempurl = tempurl.filter_factory({"outgoing_remove_headers": "x-test-header-one-a"})(self.auth)
     method = "GET"
     expires = int(time() + 86400)
     path = "/v1/a/c/o"
     key = "abc"
     hmac_body = "%s\n%s\n%s" % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(
         path, keys=[key], environ={"QUERY_STRING": "temp_url_sig=%s&temp_url_expires=%s" % (sig, expires)}
     )
     resp = req.get_response(self.tempurl)
     self.assertEqual(resp.status_int, 404)
     self.assertTrue("x-test-header-one-a" not in resp.headers)
     self.assertEqual(resp.headers["x-test-header-two-a"], "value2")
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:15,代码来源:test_tempurl.py

示例2: test_removed_incoming_header

 def test_removed_incoming_header(self):
     self.tempurl = tempurl.filter_factory({
         'incoming_remove_headers': 'x-remove-this'})(self.auth)
     method = 'GET'
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     hmac_body = '%s\n%s\n%s' % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(path, headers={'x-remove-this': 'value'},
         environ={'QUERY_STRING':
                    'temp_url_sig=%s&temp_url_expires=%s' % (sig, expires)})
     req.environ['swift.cache'].set('temp-url-key/a', key)
     resp = req.get_response(self.tempurl)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('x-remove-this' not in self.app.request.headers)
开发者ID:hughsaunders,项目名称:swift-openstack,代码行数:16,代码来源:test_tempurl.py

示例3: test_removed_outgoing_header

 def test_removed_outgoing_header(self):
     self.tempurl = tempurl.filter_factory({
         'outgoing_remove_headers': 'x-test-header-one-a'})(self.auth)
     method = 'GET'
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     hmac_body = '%s\n%s\n%s' % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(path, keys=[key],
         environ={'QUERY_STRING':
                    'temp_url_sig=%s&temp_url_expires=%s' % (sig, expires)})
     resp = req.get_response(self.tempurl)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('x-test-header-one-a' not in resp.headers)
     self.assertEquals(resp.headers['x-test-header-two-a'], 'value2')
开发者ID:Awingu,项目名称:swift,代码行数:16,代码来源:test_tempurl.py

示例4: test_removed_incoming_header

 def test_removed_incoming_header(self):
     self.tempurl = tempurl.filter_factory({"incoming_remove_headers": "x-remove-this"})(self.auth)
     method = "GET"
     expires = int(time() + 86400)
     path = "/v1/a/c/o"
     key = "abc"
     hmac_body = "%s\n%s\n%s" % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(
         path,
         keys=[key],
         headers={"x-remove-this": "value"},
         environ={"QUERY_STRING": "temp_url_sig=%s&temp_url_expires=%s" % (sig, expires)},
     )
     resp = req.get_response(self.tempurl)
     self.assertEqual(resp.status_int, 404)
     self.assertTrue("x-remove-this" not in self.app.request.headers)
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:17,代码来源:test_tempurl.py

示例5: test_allow_trumps_incoming_header_startswith_conflict

 def test_allow_trumps_incoming_header_startswith_conflict(self):
     self.tempurl = tempurl.filter_factory({
         'incoming_remove_headers': 'x-conflict-header-*',
         'incoming_allow_headers': 'x-conflict-header-*'})(self.auth)
     method = 'GET'
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     hmac_body = '%s\n%s\n%s' % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(
         path, keys=[key],
         headers={'x-conflict-header-test': 'value'},
         environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
             sig, expires)})
     resp = req.get_response(self.tempurl)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('x-conflict-header-test' in self.app.request.headers)
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:18,代码来源:test_tempurl.py

示例6: test_disallowed_header_object_manifest

 def test_disallowed_header_object_manifest(self):
     self.tempurl = tempurl.filter_factory({})(self.auth)
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     for method in ('PUT', 'POST'):
         hmac_body = '%s\n%s\n%s' % (method, expires, path)
         sig = hmac.new(key, hmac_body, sha1).hexdigest()
         req = self._make_request(
             path, method=method, keys=[key],
             headers={'x-object-manifest': 'private/secret'},
             environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s'
                                      % (sig, expires)})
         resp = req.get_response(self.tempurl)
         self.assertEquals(resp.status_int, 400)
         self.assertTrue('header' in resp.body)
         self.assertTrue('not allowed' in resp.body)
         self.assertTrue('X-Object-Manifest' in resp.body)
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:18,代码来源:test_tempurl.py

示例7: test_removed_incoming_headers_match

 def test_removed_incoming_headers_match(self):
     self.tempurl = tempurl.filter_factory({
         'incoming_remove_headers': 'x-remove-this-*',
         'incoming_allow_headers': 'x-remove-this-except-this'})(self.auth)
     method = 'GET'
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     hmac_body = '%s\n%s\n%s' % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(path, keys=[key],
         headers={'x-remove-this-one': 'value1',
                  'x-remove-this-except-this': 'value2'},
         environ={'QUERY_STRING':
                    'temp_url_sig=%s&temp_url_expires=%s' % (sig, expires)})
     resp = req.get_response(self.tempurl)
     self.assertEquals(resp.status_int, 404)
     self.assertTrue('x-remove-this-one' not in self.app.request.headers)
     self.assertEquals(
         self.app.request.headers['x-remove-this-except-this'], 'value2')
开发者ID:Awingu,项目名称:swift,代码行数:20,代码来源:test_tempurl.py

示例8: test_disallowed_header_object_manifest

 def test_disallowed_header_object_manifest(self):
     self.tempurl = tempurl.filter_factory({})(self.auth)
     expires = int(time() + 86400)
     path = "/v1/a/c/o"
     key = "abc"
     for method in ("PUT", "POST"):
         hmac_body = "%s\n%s\n%s" % (method, expires, path)
         sig = hmac.new(key, hmac_body, sha1).hexdigest()
         req = self._make_request(
             path,
             method=method,
             keys=[key],
             headers={"x-object-manifest": "private/secret"},
             environ={"QUERY_STRING": "temp_url_sig=%s&temp_url_expires=%s" % (sig, expires)},
         )
         resp = req.get_response(self.tempurl)
         self.assertEqual(resp.status_int, 400)
         self.assertTrue("header" in resp.body)
         self.assertTrue("not allowed" in resp.body)
         self.assertTrue("X-Object-Manifest" in resp.body)
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:20,代码来源:test_tempurl.py

示例9: test_allow_trumps_outgoing_header_conflict

 def test_allow_trumps_outgoing_header_conflict(self):
     self.tempurl = tempurl.filter_factory({
         'outgoing_remove_headers': 'x-conflict-header',
         'outgoing_allow_headers': 'x-conflict-header'})(self.auth)
     method = 'GET'
     expires = int(time() + 86400)
     path = '/v1/a/c/o'
     key = 'abc'
     hmac_body = '%s\n%s\n%s' % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(
         path, keys=[key],
         headers={},
         environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
             sig, expires)})
     self.tempurl.app = FakeApp(iter([('200 Ok', {
         'X-Conflict-Header': 'value'}, '123')]))
     resp = req.get_response(self.tempurl)
     self.assertEquals(resp.status_int, 200)
     self.assertTrue('x-conflict-header' in resp.headers)
     self.assertEqual(resp.headers['x-conflict-header'], 'value')
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:21,代码来源:test_tempurl.py

示例10: test_allow_trumps_outgoing_header_startswith_conflict

 def test_allow_trumps_outgoing_header_startswith_conflict(self):
     self.tempurl = tempurl.filter_factory(
         {"outgoing_remove_headers": "x-conflict-header-*", "outgoing_allow_headers": "x-conflict-header-*"}
     )(self.auth)
     method = "GET"
     expires = int(time() + 86400)
     path = "/v1/a/c/o"
     key = "abc"
     hmac_body = "%s\n%s\n%s" % (method, expires, path)
     sig = hmac.new(key, hmac_body, sha1).hexdigest()
     req = self._make_request(
         path,
         keys=[key],
         headers={},
         environ={"QUERY_STRING": "temp_url_sig=%s&temp_url_expires=%s" % (sig, expires)},
     )
     self.tempurl.app = FakeApp(iter([("200 Ok", {"X-Conflict-Header-Test": "value"}, "123")]))
     resp = req.get_response(self.tempurl)
     self.assertEqual(resp.status_int, 200)
     self.assertTrue("x-conflict-header-test" in resp.headers)
     self.assertEqual(resp.headers["x-conflict-header-test"], "value")
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:21,代码来源:test_tempurl.py

示例11: setUp

 def setUp(self):
     self.app = FakeApp()
     self.auth = tempauth.filter_factory({})(self.app)
     self.tempurl = tempurl.filter_factory({})(self.auth)
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:4,代码来源:test_tempurl.py

示例12: test_non_default_methods

 def test_non_default_methods(self):
     tempurl.filter_factory({'methods': 'GET HEAD PUT DELETE BREW'})
     swift_info = utils.get_swift_info()
     self.assertTrue('tempurl' in swift_info)
     self.assertEqual(set(swift_info['tempurl']['methods']),
                      set(('GET', 'HEAD', 'PUT', 'DELETE', 'BREW')))
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:6,代码来源:test_tempurl.py

示例13: test_registered_defaults

 def test_registered_defaults(self):
     tempurl.filter_factory({})
     swift_info = utils.get_swift_info()
     self.assertTrue('tempurl' in swift_info)
     self.assertEqual(set(swift_info['tempurl']['methods']),
                      set(('GET', 'HEAD', 'PUT', 'POST', 'DELETE')))
开发者ID:heemanshu,项目名称:swift_liberty,代码行数:6,代码来源:test_tempurl.py

示例14: test_registered_defaults

 def test_registered_defaults(self):
     tempurl.filter_factory({})
     swift_info = utils.get_swift_info()
     self.assertTrue("tempurl" in swift_info)
     self.assertEqual(set(swift_info["tempurl"]["methods"]), set(("GET", "HEAD", "PUT", "POST", "DELETE")))
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:5,代码来源:test_tempurl.py

示例15: test_non_default_methods

 def test_non_default_methods(self):
     tempurl.filter_factory({"methods": "GET HEAD PUT DELETE BREW"})
     swift_info = utils.get_swift_info()
     self.assertTrue("tempurl" in swift_info)
     self.assertEqual(set(swift_info["tempurl"]["methods"]), set(("GET", "HEAD", "PUT", "DELETE", "BREW")))
开发者ID:nguyenducnhaty,项目名称:swift,代码行数:5,代码来源:test_tempurl.py


注:本文中的swift.common.middleware.tempurl.filter_factory函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。