def test_get_email_token(self): email = '*****@*****.**' salt = 'salt' secret = 'secret' token = utils.get_email_token(email, salt, secret) self.assertEquals('ImFAYS5jb20i', token[0:12]) decoded = utils.get_email_from_token(token, salt, secret) self.assertEquals(email, decoded) time.sleep(2) with self.assertRaises(Exception) as context: decoded = utils.get_email_from_token(token, salt, secret, max_age=1) self.assertTrue('Signature age 2 > 1 seconds' in context.exception)
def get_email_verification_token(self, salt, secret): """ :rtype string :return the email verification token stored in the database """ return utils.get_email_token(self.email, salt, secret)