def test_store_password(self): """Empty docstring""" pa = PasswordAuthentication() pa.username = u'nathansamson' pa.password("mePassword") self.__database.add(pa) self.__database.flush() pa = self.__database.find(PasswordAuthentication, PasswordAuthentication.username\ == u"nathansamson").one() self.assertTrue(pa.testPassword("mePassword"))
def test_reset(self): """Empty docstring""" pa = PasswordAuthentication() pa.username = u'nathan' pa.user = self.__user pa.password("theSuperHardPassword") self.__database.add(pa) hsh = pa.requestReset() pa.reset(hsh, "newPassword") self.assertTrue(pa.testPassword("newPassword"))
def test_change_password(self): """Empty docstring""" pa = PasswordAuthentication() pa.username = u'nathan' pa.user = self.__user pa.password("theSuperHardPassword") self.__database.add(pa) pa.password("theNewPassword") self.assertTrue(pa.testPassword("theNewPassword")) self.assertFalse(pa.testPassword("theSuperHardPassword"))
def clean(self): """Empty docstring""" data = self.cleaned_data print data['password'] db = WebServer.database() user = User(data['firstName'], data['lastName'], data['email']) pa = PasswordAuthentication() pa.username = data['username'] pa.password(data['password']) pa.user = user data['user'] = user data['passwordAuth'] = pa return data
def setUp(self): """Setup functions""" test.testcase.DatabaseTestCase.setUp(self) self.server = MockServer(store=self.store) self.terminal = LoginTerminal(self.server, authenticated_terminal=AuthenticatedTerminal) user1 = User(u"Me", u"Meme", u"*****@*****.**") password1 = PasswordAuthentication() password1.user = user1 password1.username = u"me.meme" password1.password("secure-password") self.store.add(user1) self.store.add(password1) self.user_me = user1
def test_reset_with_wrong_hash(self): """Empty docstring""" pa = PasswordAuthentication() pa.username = u'nathan' pa.user = self.__user pa.password("theSuperHardPassword") self.__database.add(pa) hsh = pa.requestReset() self.assertRaises(Exception, pa.reset, "wrong hash", "newPassword") self.assertFalse(pa.testPassword("newPass"))
def test_store_passwor_authentication(self): """Empty docstring""" pa = PasswordAuthentication() pa.username = u'nathan' pa.user = self.__user pa.password("theSuperHardPassword") self.__database.add(pa) pa = self.__database.find(PasswordAuthentication, PasswordAuthentication.username == u'nathan').one() self.assertTrue(pa.testPassword("theSuperHardPassword")) self.assertFalse(pa.testPassword("theSuperWrongPassword"))
def test_save_password(self): """Empty docstring""" pa = PasswordAuthentication() pa.user = self.__user pa.username = u'nathansamson' pa.password("mePassword") self.__database.add(pa) pa = self.__database.find(PasswordAuthentication, PasswordAuthentication.username\ == u"nathansamson").one() hsh = pa.requestReset() self.__database.flush() pa = self.__database.find(PasswordAuthentication, PasswordAuthentication.username\ == u"nathansamson").one() pa.reset(hsh, "newPassword") self.__database.flush() pa = self.__database.find(PasswordAuthentication, PasswordAuthentication.username\ == u"nathansamson").one() self.assertTrue(pa.testPassword("newPassword"))