def testRoles(self): user = User(email='*****@*****.**', password=MD5Type.generate('secret')) user.sessions.append(User.Session()) user.store(self.db) self.assertEqual(self.db[user.id][u'email'], u'*****@*****.**') json = make_safe_json(User,user,'mysessions') assert 'password' not in json assert 'token' not in json assert 'email' in json assert 'created_on' in json assert self.db[user.id]['password'] is not None u2 = User.load(self.db, user.id) self.assertTrue(u2.challenge_password(MD5Type.generate('secret')))
def testValidUser(self): user = User(email='*****@*****.**', password=MD5Type.generate('secret')) self.assertTrue(user.challenge_password(MD5Type.generate('secret'))) user.store(self.db) self.assertEqual(self.db[user.id][u'email'], u'*****@*****.**')
def testSetPassword(self): user = User(email='*****@*****.**') user.password = '******' self.assertNotEqual(user.password, MD5Type.generate('pass1')) self.assertTrue(user.challenge_password('pass1'))
def testInvalidUser(self): user = User() user.email = 'invalid@email' self.assertRaises( Exception, user.store, self.db)
def testPasswordSetterWithKeywordOnInitialization(self): user = User(email='*****@*****.**',password='******') self.assertNotEqual(user.password, MD5Type.generate('pass1')) self.assertTrue(user.challenge_password('pass1'))