예제 #1
0
    def get(self, request, signature, image_id, filter_spec, filename=None):
        if not verify_signature(signature.encode(), image_id, filter_spec, key=self.key):
            raise PermissionDenied

        image = get_object_or_404(self.model, id=image_id)

        # Get/generate the rendition
        try:
            rendition = image.get_rendition(filter_spec)
        except SourceImageIOError:
            return HttpResponse("Source image file not found", content_type='text/plain', status=410)
        except InvalidFilterSpecError:
            return HttpResponse("Invalid filter spec: " + filter_spec, content_type='text/plain', status=400)

        return getattr(self, self.action)(rendition)
예제 #2
0
파일: tests.py 프로젝트: jams2/wagtail
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(
         verify_signature("xnZOzQyUg6pkfciqcfRJRosOrGg=", 100,
                          "fill-800x700"))
예제 #3
0
파일: tests.py 프로젝트: jams2/wagtail
 def test_signature_changes_on_image_id(self):
     self.assertFalse(
         verify_signature("xnZOzQyUg6pkfciqcfRJRosOrGg=", 200,
                          "fill-800x600"))
예제 #4
0
파일: tests.py 프로젝트: jams2/wagtail
 def test_signature_verification(self):
     self.assertTrue(
         verify_signature("xnZOzQyUg6pkfciqcfRJRosOrGg=", 100,
                          "fill-800x600"))
예제 #5
0
 def test_signature_verification(self):
     self.assertTrue(verify_signature('xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x600'))