def test_signs_request_when_private_key_is_unicode(self): # test to ensure we handle private key properly no matter what kind of character # encoding the private key is given as: # http://bugs.python.org/issue4329 (not a bug, but this is the situation and explanation) signer = Signer(six.text_type(self.private_key)) signature = signer.create_signature('http://www.example.com/accounts/user/add/') expected_signature = '5KUwEjFvjc2T_IxJX_uL00nRC1HJrk_LOs1sXu1DrHY=' self.assertEqual(expected_signature, signature)
def test_requires_private_key(self): with self.assertRaises(Exception) as context: Signer(None) self.assertEqual(str(context.exception), 'Private key is required.')
def setUp(self): self.private_key = 'CoVTr95Xv2Xlu4ZjPo2bWl7u4SnnAMAD7EFFBMS4Dy4=' self.signature_param = "signature" self.signer = Signer(self.private_key)