Merge "Init policy in pecan after hook as well"
This commit is contained in:
commit
5cf17dd8ec
@ -163,6 +163,7 @@ class PolicyHook(hooks.PecanHook):
|
||||
return
|
||||
if not data or (resource not in data and collection not in data):
|
||||
return
|
||||
policy.init()
|
||||
is_single = resource in data
|
||||
action_type = pecan_constants.ACTION_MAP[state.request.method]
|
||||
if action_type == 'get':
|
||||
|
@ -221,6 +221,17 @@ class TestPolicyEnforcementHook(test_functional.PecanFunctionalTest):
|
||||
json_response = jsonutils.loads(response.body)
|
||||
self.assertNotIn('restricted_attr', json_response['mehs'][0])
|
||||
|
||||
def test_after_inits_policy(self):
|
||||
self.mock_plugin.get_mehs.return_value = [{
|
||||
'id': 'xxx',
|
||||
'attr': 'meh',
|
||||
'restricted_attr': '',
|
||||
'tenant_id': 'tenid'}]
|
||||
policy.reset()
|
||||
response = self.app.get('/v2.0/mehs',
|
||||
headers={'X-Project-Id': 'tenid'})
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
|
||||
class TestMetricsNotifierHook(test_functional.PecanFunctionalTest):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user