本文整理汇总了Python中wafflehaus.try_context.context_filter.filter_factory函数的典型用法代码示例。如果您正苦于以下问题:Python filter_factory函数的具体用法?Python filter_factory怎么用?Python filter_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_factory函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_strategy_unknown_should_500_noop_testing
def test_create_strategy_unknown_should_500_noop_testing(self):
"""The none strategy simply is a noop."""
result = context_filter.filter_factory(self.unknown_testing)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
resp = result.__call__.request('/something', method='HEAD')
self.assertEqual(self.app, resp)
开发者ID:brandonlogan,项目名称:wafflehaus,代码行数:7,代码来源:test_try_context.py
示例2: test_requires_auth_will_fail_without_info
def test_requires_auth_will_fail_without_info(self):
result = context_filter.filter_factory(self.strat_neutron_a)(self.app)
self.assertIsNotNone(result)
headers = {'Content-Type': 'application/json',
'X_ROLES': 'testrole, testrole2', }
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertTrue(isinstance(resp, webob.exc.HTTPForbidden))
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:7,代码来源:test_neutron_context.py
示例3: test_create_strategy_neutron_no_user
def test_create_strategy_neutron_no_user(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
self.assertFalse('neutron.context' in self.req)
headers = {'Content-Type': 'application/json', }
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
开发者ID:quadewarren,项目名称:wafflehaus.neutron,代码行数:8,代码来源:test_neutron_context.py
示例4: test_create_strategy_neutron
def test_create_strategy_neutron(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
headers = {'Content-Type': 'application/json',
'X_USER_ID': 'derp', }
result.__call__.request('/', method='HEAD', headers=headers)
context = result.strat_instance.context
self.assertTrue(context.is_admin)
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:9,代码来源:test_neutron_context.py
示例5: test_advsvc_is_false_when_admin_and_not_advsvc_role
def test_advsvc_is_false_when_admin_and_not_advsvc_role(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
headers = {'Content-Type': 'application/json'}
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
context = result.strat_instance.context
self.assertFalse(context.is_advsvc)
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:9,代码来源:test_neutron_context.py
示例6: test_create_strategy_test_noop_testing
def test_create_strategy_test_noop_testing(self):
"""This is a test strategy to see if this thing works."""
result = context_filter.filter_factory(self.strat_test)(self.app)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
resp = result.__call__.request('/something', method='HEAD')
self.assertEqual(self.app, resp)
self.assertEqual(1, self.context_init.call_count)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
"""Should be 1 because of a new instance."""
self.assertEqual(1, self.context_init.call_count)
开发者ID:brandonlogan,项目名称:wafflehaus,代码行数:10,代码来源:test_try_context.py
示例7: test_advsvc_is_true_when_policy_says_it_is
def test_advsvc_is_true_when_policy_says_it_is(self):
self.adv_svc.return_value = True
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
headers = {'Content-Type': 'application/json'}
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
context = result.strat_instance.context
self.assertTrue(context.is_advsvc)
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:10,代码来源:test_neutron_context.py
示例8: test_create_strategy_neutron_with_no_roles
def test_create_strategy_neutron_with_no_roles(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
self.assertFalse('neutron.context' in self.req)
headers = {'Content-Type': 'application/json',
'X_ROLES': None, }
with patch('neutron.policy.get_admin_roles',
self.get_admin_mock):
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
开发者ID:insequent,项目名称:wafflehaus.neutron,代码行数:11,代码来源:test_neutron_context.py
示例9: test_create_strategy_neutron_with_empty_roles
def test_create_strategy_neutron_with_empty_roles(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
headers = {'Content-Type': 'application/json',
'X_ROLES': '', }
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
context = result.strat_instance.context
self.assertTrue(context.is_admin)
self.assertTrue(hasattr(context, 'roles'))
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:11,代码来源:test_neutron_context.py
示例10: test_override_runtime_enabled
def test_override_runtime_enabled(self):
"""The none strategy simply is a noop."""
self.set_reconfigure()
headers = {'X_WAFFLEHAUS_CONTEXTFILTER_ENABLED': False}
result = context_filter.filter_factory(self.strat_test)(self.app)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
resp = result.__call__.request('/something', method='HEAD',
headers=headers)
self.assertEqual(self.app, resp)
self.assertEqual(0, self.context_init.call_count)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
"""Should be 1 because of a new instance."""
self.assertEqual(0, self.context_init.call_count)
开发者ID:brandonlogan,项目名称:wafflehaus,代码行数:13,代码来源:test_try_context.py
示例11: test_verify_non_duplicate_request_id_admin
def test_verify_non_duplicate_request_id_admin(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertTrue(isinstance(result, context_filter.ContextFilter))
headers = {'Content-Type': 'application/json', }
resp = result.__call__.request('/', method='HEAD', headers=headers)
context = result.strat_instance.context
self.assertTrue(context.is_admin)
self.assertEqual(self.app, resp)
# Generate another call in order to force oslo.context to refresh
# the _request_store, which in turn generates a new request_id
resp = result.__call__.request('/', method='HEAD', headers=headers)
context1 = result.strat_instance.context
self.assertNotEqual(context.request_id, context1.request_id)
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:14,代码来源:test_neutron_context.py
示例12: test_create_strategy_neutron_appends_to_admin_role
def test_create_strategy_neutron_appends_to_admin_role(self):
result = context_filter.filter_factory(self.strat_neutron)(self.app)
self.assertIsNotNone(result)
self.assertFalse('neutron.context' in self.req)
headers = {'Content-Type': 'application/json',
'X_ROLES': 'testrole, testrole2', }
with patch('neutron.policy.get_admin_roles',
self.get_admin_mock):
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
context = result.strat_instance.context
self.assertTrue(hasattr(context, 'roles'))
self.assertTrue('testrole' in context.roles)
self.assertTrue('testrole2' in context.roles)
self.assertTrue('admin' in context.roles)
self.assertEqual(3, len(context.roles))
开发者ID:insequent,项目名称:wafflehaus.neutron,代码行数:16,代码来源:test_neutron_context.py
示例13: test_requires_auth_is_not_admin
def test_requires_auth_is_not_admin(self):
result = context_filter.filter_factory(self.strat_neutron_a)(self.app)
self.assertIsNotNone(result)
headers = {'Content-Type': 'application/json',
'X_TENANT_ID': '123456',
'X_USER_ID': 'foo',
'X_ROLES': 'testrole, testrole2', }
policy_check = self.create_patch('neutron.policy.check_is_admin')
policy_check.return_value = False
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
self.assertEqual(2, policy_check.call_count)
context = result.strat_instance.context
self.assertTrue(hasattr(context, 'roles'))
self.assertTrue('testrole' in context.roles)
self.assertTrue('testrole2' in context.roles)
self.assertFalse(context.is_admin)
self.assertEqual(2, len(context.roles))
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:18,代码来源:test_neutron_context.py
示例14: test_verify_non_duplicate_request_id_non_admin
def test_verify_non_duplicate_request_id_non_admin(self):
result = context_filter.filter_factory(self.strat_neutron_a)(self.app)
self.assertIsNotNone(result)
headers = {'Content-Type': 'application/json',
'X_TENANT_ID': '123456',
'X_USER_ID': 'foo',
'X_ROLES': 'testrole, testrole2', }
policy_check = self.create_patch('neutron.policy.check_is_admin')
policy_check.return_value = False
resp = result.__call__.request('/', method='HEAD', headers=headers)
self.assertEqual(self.app, resp)
self.assertEqual(2, policy_check.call_count)
context = result.strat_instance.context
self.assertTrue(hasattr(context, 'roles'))
self.assertTrue('testrole' in context.roles)
self.assertTrue('testrole2' in context.roles)
self.assertFalse(context.is_admin)
self.assertEqual(2, len(context.roles))
# Generate another call in order to force oslo.context to refresh
# the _request_store, which in turn generates a new request_id
resp = result.__call__.request('/', method='HEAD', headers=headers)
context1 = result.strat_instance.context
self.assertNotEqual(context.request_id, context1.request_id)
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:23,代码来源:test_neutron_context.py
注:本文中的wafflehaus.try_context.context_filter.filter_factory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论