def test_sign_uses_correct_key(self): "If a key is provided, sign should use it; otherwise, use SECRET_KEY" s = 'This is a string' self.assertEqual(signed.sign(s), s + '.' + signed.base64_hmac(s, settings.SECRET_KEY)) self.assertEqual(signed.sign(s, 'sekrit'), s + '.' + signed.base64_hmac(s, 'sekrit'))
def test_signature_optional_arguments(self): "signature(value, key=..., extra_key=...) should work" self.assertEqual(signed.signature('hello', key='this-is-the-key'), signed.base64_hmac('hello', 'this-is-the-key')) self.assertEqual( signed.signature('hello', key='this-is-the-key', extra_key='X'), signed.base64_hmac('hello', 'this-is-the-keyX')) self.assertEqual( signed.signature('hello', extra_key='X'), signed.base64_hmac('hello', settings.SECRET_KEY + 'X'))
def test_sign_uses_correct_key(self): "If a key is provided, sign should use it; otherwise, use SECRET_KEY" s = 'This is a string' self.assertEqual( signed.sign(s), s + '.' + signed.base64_hmac(s, settings.SECRET_KEY) ) self.assertEqual( signed.sign(s, 'sekrit'), s + '.' + signed.base64_hmac(s, 'sekrit') )
def test_signature_optional_arguments(self): "signature(value, key=..., extra_key=...) should work" self.assertEqual( signed.signature('hello', key='this-is-the-key'), signed.base64_hmac('hello', 'this-is-the-key') ) self.assertEqual( signed.signature('hello', key='this-is-the-key', extra_key='X'), signed.base64_hmac('hello', 'this-is-the-keyX') ) self.assertEqual( signed.signature('hello', extra_key='X'), signed.base64_hmac('hello', settings.SECRET_KEY + 'X') )
def test_signature(self): "signature() function should generate a signature" for s in ( 'hello', '3098247:529:087:', u'\u2019'.encode('utf8'), ): self.assertEqual(signed.signature(s), signed.base64_hmac(s, settings.SECRET_KEY))
def test_signature(self): "signature() function should generate a signature" for s in ( 'hello', '3098247:529:087:', u'\u2019'.encode('utf8'), ): self.assertEqual( signed.signature(s), signed.base64_hmac(s, settings.SECRET_KEY) )