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="*****@*****.**"))
 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')))
Exemple #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="*****@*****.**"))
 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))
Exemple #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')))
Exemple #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))
 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)
Exemple #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)