Exemple #1
0
 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')))
Exemple #2
0
 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'*****@*****.**')
Exemple #3
0
 def testSetPassword(self):
     user = User(email='*****@*****.**')
     user.password = '******'
     self.assertNotEqual(user.password, MD5Type.generate('pass1'))
     self.assertTrue(user.challenge_password('pass1'))
Exemple #4
0
 def testInvalidUser(self):
     user = User()
     user.email = 'invalid@email'
     self.assertRaises( Exception, user.store, self.db)
Exemple #5
0
 def testPasswordSetterWithKeywordOnInitialization(self):
     user = User(email='*****@*****.**',password='******')
     self.assertNotEqual(user.password, MD5Type.generate('pass1'))
     self.assertTrue(user.challenge_password('pass1'))