mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-10 16:24:49 +00:00
Added tests for signature generation
This commit is contained in:
parent
b13251c67d
commit
a7610ec7be
1 changed files with 15 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ from wagtail.wagtailimages.formats import (
|
|||
|
||||
from wagtail.wagtailimages.backends import get_image_backend
|
||||
from wagtail.wagtailimages.backends.pillow import PillowBackend
|
||||
from wagtail.wagtailimages.utils import parse_filter_spec, InvalidFilterSpecError
|
||||
from wagtail.wagtailimages.utils import parse_filter_spec, InvalidFilterSpecError, generate_signature, verify_signature
|
||||
|
||||
|
||||
def get_test_image_file():
|
||||
|
|
@ -498,3 +498,17 @@ class TestFilterSpecParsing(TestCase):
|
|||
def test_bad(self):
|
||||
for filter_spec in self.bad:
|
||||
self.assertRaises(InvalidFilterSpecError, parse_filter_spec, filter_spec)
|
||||
|
||||
|
||||
class TestSignatureGeneration(TestCase):
|
||||
def test_signature_generation(self):
|
||||
self.assertEqual(generate_signature(100, 'fill-800x600'), b'xnZOzQyUg6pkfciqcfRJRosOrGg=')
|
||||
|
||||
def test_signature_verification(self):
|
||||
self.assertTrue(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x600'))
|
||||
|
||||
def test_signature_changes_on_image_id(self):
|
||||
self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200, 'fill-800x600'))
|
||||
|
||||
def test_signature_changes_on_filter_spec(self):
|
||||
self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x700'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue