Exemple #1
0
    def test_bad_signature(self):
        signer = util.Signer('s3krit')
        signed = signer.sign(self.sample)

        mangled = signed[:-3]
        with self.assertRaises(util.BadSignature) as cm:
            signer.unsign(mangled)

        self.assertIn(mangled, str(cm.exception))
Exemple #2
0
    def test_bad_data(self):
        signer = util.Signer('s3krit')
        signed = signer.sign(self.sample)

        mangled = signed.split('.')[0]
        with self.assertRaises(util.BadData) as cm:
            signer.unsign(mangled)

        self.assertIn('No separator', str(cm.exception))
        self.assertIn(mangled, str(cm.exception))
Exemple #3
0
    def test_round_trip(self):
        signer = util.Signer('s3krit')
        signed = signer.sign(self.sample)

        b = signer.unsign(signed)
        self.assertEqual(self.sample, b)
Exemple #4
0
    def test_uppercase(self):
        signer = util.Signer('s3krit')
        signed = signer.sign(self.sample)

        b = signer.unsign(signed.upper())
        self.assertEqual(self.sample, b)