本文整理汇总了Python中swift.common.utils.get_swift_info函数的典型用法代码示例。如果您正苦于以下问题:Python get_swift_info函数的具体用法?Python get_swift_info怎么用?Python get_swift_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_swift_info函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_registered_nondefaults
def test_registered_nondefaults(self):
domain_remap.filter_factory({'default_reseller_prefix': 'cupcake',
'mangle_client_paths': 'yes'})
swift_info = utils.get_swift_info()
self.assertIn('domain_remap', swift_info)
self.assertEqual(swift_info['domain_remap'], {
'default_reseller_prefix': 'cupcake'})
开发者ID:chenzhongtao,项目名称:swift,代码行数:7,代码来源:test_domain_remap.py
示例2: test_registered_nondefaults
def test_registered_nondefaults(self):
domain_remap.filter_factory({'default_reseller_prefix': 'cupcake'})
swift_info = utils.get_swift_info()
self.assertTrue('domain_remap' in swift_info)
self.assertEqual(
swift_info['domain_remap'].get('default_reseller_prefix'),
'cupcake')
开发者ID:Ahiknsr,项目名称:swift,代码行数:7,代码来源:test_domain_remap.py
示例3: test_registered_defaults
def test_registered_defaults(self):
bulk.filter_factory({})
swift_info = utils.get_swift_info()
self.assertTrue("bulk_upload" in swift_info)
self.assertTrue(isinstance(swift_info["bulk_upload"].get("max_containers_per_extraction"), numbers.Integral))
self.assertTrue(isinstance(swift_info["bulk_upload"].get("max_failed_extractions"), numbers.Integral))
self.assertTrue("bulk_delete" in swift_info)
self.assertTrue(isinstance(swift_info["bulk_delete"].get("max_deletes_per_request"), numbers.Integral))
self.assertTrue(isinstance(swift_info["bulk_delete"].get("max_failed_deletes"), numbers.Integral))
开发者ID:DmitrySot,项目名称:swift,代码行数:10,代码来源:test_bulk.py
示例4: GETorHEAD
def GETorHEAD(self, req):
"""Handler for HTTP GET/HEAD requests."""
"""
Handles requests to /info
Should return a WSGI-style callable (such as swob.Response).
:param req: swob.Request object
"""
if not self.expose_info:
return HTTPForbidden(request=req)
admin_request = False
sig = req.params.get('swiftinfo_sig', '')
expires = req.params.get('swiftinfo_expires', '')
if sig != '' or expires != '':
admin_request = True
if not self.admin_key:
return HTTPForbidden(request=req)
try:
expires = int(expires)
except ValueError:
return HTTPUnauthorized(request=req)
if expires < time():
return HTTPUnauthorized(request=req)
valid_sigs = []
for method in self.allowed_hmac_methods[req.method]:
valid_sigs.append(get_hmac(method,
'/info',
expires,
self.admin_key))
# While it's true that any() will short-circuit, this doesn't
# affect the timing-attack resistance since the only way this will
# short-circuit is when a valid signature is passed in.
is_valid_hmac = any(streq_const_time(valid_sig, sig)
for valid_sig in valid_sigs)
if not is_valid_hmac:
return HTTPUnauthorized(request=req)
headers = {}
if 'Origin' in req.headers:
headers['Access-Control-Allow-Origin'] = req.headers['Origin']
headers['Access-Control-Expose-Headers'] = ', '.join(
['x-trans-id'])
#json.dumps(dict)可以将字典形式的dict对象转换为json格式的对象
info = json.dumps(get_swift_info(
admin=admin_request, disallowed_sections=self.disallowed_sections))
return HTTPOk(request=req,
headers=headers,
body=info,
content_type='application/json; charset=UTF-8')
开发者ID:sunzz679,项目名称:swift-2.4.0--source-read,代码行数:55,代码来源:info.py
示例5: test_registered_defaults
def test_registered_defaults(self):
def check_key_is_absent(key):
try:
swift_info[key]
except KeyError as err:
if key not in str(err):
raise
test_limits = {'account_ratelimit': 1,
'max_sleep_time_seconds': 60,
'container_ratelimit_0': 0,
'container_ratelimit_10': 10,
'container_ratelimit_50': 50,
'container_listing_ratelimit_0': 0,
'container_listing_ratelimit_10': 10,
'container_listing_ratelimit_50': 50}
ratelimit.filter_factory(test_limits)('have to pass in an app')
swift_info = utils.get_swift_info()
self.assertIn('ratelimit', swift_info)
self.assertEqual(swift_info['ratelimit']
['account_ratelimit'], 1.0)
self.assertEqual(swift_info['ratelimit']
['max_sleep_time_seconds'], 60.0)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][0][0], 0)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][0][1], 0.0)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][1][0], 10)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][1][1], 10.0)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][2][0], 50)
self.assertEqual(swift_info['ratelimit']
['container_ratelimits'][2][1], 50.0)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][0][0], 0)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][0][1], 0.0)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][1][0], 10)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][1][1], 10.0)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][2][0], 50)
self.assertEqual(swift_info['ratelimit']
['container_listing_ratelimits'][2][1], 50.0)
# these were left out on purpose
for key in ['log_sleep_time_seconds', 'clock_accuracy',
'rate_buffer_seconds', 'ratelimit_whitelis',
'ratelimit_blacklist']:
check_key_is_absent(key)
开发者ID:mahak,项目名称:swift,代码行数:55,代码来源:test_ratelimit.py
示例6: test_registered_defaults
def test_registered_defaults(self):
filter_factory(CONF)
swift_info = utils.get_swift_info()
self.assertTrue('swift3' in swift_info)
self.assertEqual(swift_info['swift3'].get('max_bucket_listing'),
CONF.max_bucket_listing)
self.assertEqual(swift_info['swift3'].get('max_parts_listing'),
CONF.max_parts_listing)
self.assertEqual(swift_info['swift3'].get('max_upload_part_num'),
CONF.max_upload_part_num)
self.assertEqual(swift_info['swift3'].get('max_multi_delete_objects'),
CONF.max_multi_delete_objects)
开发者ID:sivakrishnan47,项目名称:swift3,代码行数:12,代码来源:test_middleware.py
示例7: test_registered_configured_options
def test_registered_configured_options(self):
conf = {'maximum_length': 512,
'forbidden_chars': '\'\"`',
'forbidden_regexp': "/\./|/\.\./|/\.$"}
name_check.filter_factory(conf)(FakeApp())
swift_info = utils.get_swift_info()
self.assertTrue('name_check' in swift_info)
self.assertEqual(swift_info['name_check'].get('maximum_length'), 512)
self.assertEqual(set(swift_info['name_check'].get('forbidden_chars')),
set('\'\"`'))
self.assertEqual(swift_info['name_check'].get('forbidden_regexp'),
"/\./|/\.\./|/\.$")
开发者ID:chenzhongtao,项目名称:swift,代码行数:12,代码来源:test_name_check.py
示例8: test_registered_defaults
def test_registered_defaults(self):
name_check.filter_factory({})(FakeApp())
swift_info = utils.get_swift_info()
self.assertTrue('name_check' in swift_info)
self.assertTrue(isinstance(
swift_info['name_check'].get('maximum_length'),
numbers.Integral))
self.assertTrue(isinstance(
swift_info['name_check'].get('forbidden_chars'),
str))
self.assertTrue(isinstance(
swift_info['name_check'].get('forbidden_regexp'),
str))
开发者ID:chenzhongtao,项目名称:swift,代码行数:13,代码来源:test_name_check.py
示例9: test_registered_defaults
def test_registered_defaults(self):
def check_key_is_absnet(key):
try:
swift_info[key]
except KeyError as err:
if key not in err:
raise
test_limits = {
"account_ratelimit": 1,
"max_sleep_time_seconds": 60,
"container_ratelimit_0": 0,
"container_ratelimit_10": 10,
"container_ratelimit_50": 50,
"container_listing_ratelimit_0": 0,
"container_listing_ratelimit_10": 10,
"container_listing_ratelimit_50": 50,
}
ratelimit.filter_factory(test_limits)("have to pass in an app")
swift_info = utils.get_swift_info()
self.assertTrue("ratelimit" in swift_info)
self.assertEqual(swift_info["ratelimit"]["account_ratelimit"], 1.0)
self.assertEqual(swift_info["ratelimit"]["max_sleep_time_seconds"], 60.0)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][0][0], 0)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][0][1], 0.0)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][1][0], 10)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][1][1], 10.0)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][2][0], 50)
self.assertEqual(swift_info["ratelimit"]["container_ratelimits"][2][1], 50.0)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][0][0], 0)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][0][1], 0.0)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][1][0], 10)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][1][1], 10.0)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][2][0], 50)
self.assertEqual(swift_info["ratelimit"]["container_listing_ratelimits"][2][1], 50.0)
# these were left out on purpose
for key in [
"log_sleep_time_seconds",
"clock_accuracy",
"rate_buffer_seconds",
"ratelimit_whitelis",
"ratelimit_blacklist",
]:
check_key_is_absnet(key)
开发者ID:notmyname,项目名称:swift,代码行数:46,代码来源:test_ratelimit.py
示例10: test_registered_defaults
def test_registered_defaults(self):
bulk.filter_factory({})
swift_info = utils.get_swift_info()
self.assertTrue('bulk_upload' in swift_info)
self.assertTrue(isinstance(
swift_info['bulk_upload'].get('max_containers_per_extraction'),
numbers.Integral))
self.assertTrue(isinstance(
swift_info['bulk_upload'].get('max_failed_extractions'),
numbers.Integral))
self.assertTrue('bulk_delete' in swift_info)
self.assertTrue(isinstance(
swift_info['bulk_delete'].get('max_deletes_per_request'),
numbers.Integral))
self.assertTrue(isinstance(
swift_info['bulk_delete'].get('max_failed_deletes'),
numbers.Integral))
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:18,代码来源:test_bulk.py
示例11: GETorHEAD
def GETorHEAD(self, req):
"""Handler for HTTP GET/HEAD requests."""
"""
Handles requests to /info
Should return a WSGI-style callable (such as swob.Response).
:param req: swob.Request object
"""
if not self.expose_info:
return HTTPForbidden(request=req)
admin_request = False
sig = req.params.get("swiftinfo_sig", "")
expires = req.params.get("swiftinfo_expires", "")
if sig != "" or expires != "":
admin_request = True
if not self.admin_key:
return HTTPForbidden(request=req)
try:
expires = int(expires)
except ValueError:
return HTTPUnauthorized(request=req)
if expires < time():
return HTTPUnauthorized(request=req)
valid_sigs = []
for method in self.allowed_hmac_methods[req.method]:
valid_sigs.append(get_hmac(method, "/info", expires, self.admin_key))
if sig not in valid_sigs:
return HTTPUnauthorized(request=req)
headers = {}
if "Origin" in req.headers:
headers["Access-Control-Allow-Origin"] = req.headers["Origin"]
headers["Access-Control-Expose-Headers"] = ", ".join(["x-trans-id"])
info = json.dumps(get_swift_info(admin=admin_request, disallowed_sections=self.disallowed_sections))
return HTTPOk(request=req, headers=headers, body=info, content_type="application/json; charset=UTF-8")
开发者ID:jettang,项目名称:icehouse,代码行数:41,代码来源:info.py
示例12: do_test
def do_test(conf, expect_enabled):
fake_app = object()
with mock.patch.dict('swift.common.utils._swift_admin_info',
clear=True):
# we're not expecting utils._swift_info to be modified but mock
# it anyway just in case it is
with mock.patch.dict('swift.common.utils._swift_info',
clear=True):
# Sanity checks...
self.assertNotIn('encryption', utils._swift_admin_info)
self.assertNotIn('encryption',
utils.get_swift_info(admin=True))
self.assertNotIn('encryption',
utils.get_swift_info(admin=True)['admin'])
factory = crypto.filter_factory(conf)
self.assertTrue(callable(factory))
filtered_app = factory(fake_app)
self.assertNotIn('encryption', utils._swift_info)
self.assertNotIn('encryption', utils.get_swift_info())
self.assertNotIn('encryption',
utils.get_swift_info(admin=True))
self.assertIn('encryption', utils._swift_admin_info)
self.assertDictEqual({'enabled': expect_enabled},
utils._swift_admin_info['encryption'])
self.assertIn('encryption',
utils.get_swift_info(admin=True)['admin'])
self.assertDictEqual(
{'enabled': expect_enabled},
utils.get_swift_info(
admin=True)['admin']['encryption'])
self.assertIsInstance(filtered_app, crypto.decrypter.Decrypter)
self.assertIsInstance(filtered_app.app, crypto.encrypter.Encrypter)
self.assertIs(filtered_app.app.app, fake_app)
开发者ID:bebule,项目名称:swift,代码行数:38,代码来源:test_crypto.py
示例13: test_registered_defaults
def test_registered_defaults(self):
domain_remap.filter_factory({})
swift_info = utils.get_swift_info()
self.assertTrue('domain_remap' in swift_info)
self.assertTrue(
swift_info['domain_remap'].get('default_reseller_prefix') is None)
开发者ID:Ahiknsr,项目名称:swift,代码行数:6,代码来源:test_domain_remap.py
示例14: 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
示例15: 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
示例16: 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
示例17: test_registered_defaults
def test_registered_defaults(self):
domain_remap.filter_factory({})
swift_info = utils.get_swift_info()
self.assertIn('domain_remap', swift_info)
self.assertEqual(swift_info['domain_remap'], {
'default_reseller_prefix': None})
开发者ID:chenzhongtao,项目名称:swift,代码行数:6,代码来源:test_domain_remap.py
示例18: test_registered_nondefaults
def test_registered_nondefaults(self):
cname_lookup.filter_factory({'lookup_depth': '2'})
swift_info = utils.get_swift_info()
self.assertIn('cname_lookup', swift_info)
self.assertEqual(swift_info['cname_lookup'].get('lookup_depth'), 2)
开发者ID:clayg,项目名称:swift,代码行数:5,代码来源:test_cname_lookup.py
示例19: 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
注:本文中的swift.common.utils.get_swift_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论