예제 #1
0
    def test_generate_hmac(self):
        hmac_key = "secrete"
        data = "my data"

        h = hmac.new(utils.binary_encode(hmac_key), digestmod=hashlib.sha1)
        h.update(utils.binary_encode(data))

        self.assertEqual(h.hexdigest(), utils.generate_hmac(data, hmac_key))
예제 #2
0
    def test_signed_unpack_invalid_json(self):
        hmac = "secret"
        data = base64.urlsafe_b64encode(utils.binary_encode("not_a_json"))
        hmac_data = utils.generate_hmac(data, hmac)

        self.assertIsNone(utils.signed_unpack(data, hmac_data, hmac))