Ejemplo n.º 1
0
 def test_create_validate(self):
     """Test token creation."""
     s = EmailConfirmationSerializer()
     t = s.create_token(1, self.extra_data)
     data = s.validate_token(t, expected_data=self.extra_data)
     self.assertEqual(data['id'], 1)
     self.assertEqual(data['data'], dict(email="*****@*****.**"))
Ejemplo n.º 2
0
 def test_expected_data_mismatch(self):
     """Test token validation."""
     s = EmailConfirmationSerializer()
     t = s.create_token(1, self.extra_data)
     self.assertIsNotNone(s.validate_token(t))
     self.assertIsNone(s.validate_token(t, dict(notvalid=1)))
     self.assertIsNone(s.validate_token(t, dict(email='another@email')))
Ejemplo n.º 3
0
 def test_create_validate(self):
     """Test token creation."""
     s = EmailConfirmationSerializer()
     t = s.create_token(1, self.extra_data)
     data = s.validate_token(t, expected_data=self.extra_data)
     self.assertEqual(data['id'], 1)
     self.assertEqual(data['data'], dict(email="*****@*****.**"))
Ejemplo n.º 4
0
 def test_expired(self):
     """Test token expiry."""
     s = EmailConfirmationSerializer(expires_in=-20)
     t = s.create_token(1, self.extra_data)
     self.assertIsNone(s.validate_token(t))
     self.assertIsNone(s.validate_token(t, expected_data=self.extra_data))
     self.assertRaises(SignatureExpired, s.load_token, t)
     self.assertIsNotNone(s.load_token(t, force=True))
Ejemplo n.º 5
0
 def test_expected_data_mismatch(self):
     """Test token validation."""
     s = EmailConfirmationSerializer()
     t = s.create_token(1, self.extra_data)
     self.assertIsNotNone(s.validate_token(t))
     self.assertIsNone(s.validate_token(t, dict(notvalid=1)))
     self.assertIsNone(s.validate_token(t, dict(email='another@email')))
Ejemplo n.º 6
0
 def test_expired(self):
     """Test token expiry."""
     s = EmailConfirmationSerializer(expires_in=-20)
     t = s.create_token(1, self.extra_data)
     self.assertIsNone(s.validate_token(t))
     self.assertIsNone(s.validate_token(t, expected_data=self.extra_data))
     self.assertRaises(SignatureExpired, s.load_token, t)
     self.assertIsNotNone(s.load_token(t, force=True))
Ejemplo n.º 7
0
 def test_creation(self):
     """Ensure that no two tokens are identical."""
     s = EmailConfirmationSerializer()
     t1 = s.create_token(1, self.extra_data)
     t2 = s.create_token(1, self.extra_data)
     self.assertNotEqual(t1, t2)
Ejemplo n.º 8
0
 def test_creation(self):
     """Ensure that no two tokens are identical."""
     s = EmailConfirmationSerializer()
     t1 = s.create_token(1, self.extra_data)
     t2 = s.create_token(1, self.extra_data)
     self.assertNotEqual(t1, t2)