'Test for cache middleware skip processing when request
context has not \'download_image\' role.'

def test_process_request_without_download_image_policy(self):

    def fake_get_v1_image_metadata(*args, **kwargs):
        return {'status': 'active', 'properties': {}}
    image_id = 'test1'
    request = webob.Request.blank(('/v1/images/%s' % image_id))
    request.context = context.RequestContext()
    cache_filter = ProcessRequestTestCacheFilter()
    cache_filter._get_v1_image_metadata = fake_get_v1_image_metadata
    enforcer = self._enforcer_from_rules({'download_image': '!'})
    cache_filter.policy = enforcer
    self.assertRaises(webob.exc.HTTPForbidden, cache_filter.process_request, request)
