def test_login(self): request = testing.DummyRequest( userdb=self.rundb.userdb, method="POST", params={ "username": "******", "password": "******" }, ) response = login(request) self.assertTrue( "Invalid password" in request.session.pop_flash("error")) # Correct password, but still blocked from logging in request.params["password"] = "******" login(request) self.assertTrue("Blocked" in request.session.pop_flash("error")) # Unblock, then user can log in successfully user = self.rundb.userdb.get_user("JoeUser") user["blocked"] = False self.rundb.userdb.save_user(user) response = login(request) self.assertEqual(response.code, 302) self.assertTrue("The resource was found at" in str(response))
def test_logins(self): with testing.testConfig() as config: config.add_route('login', '/login') r = login(self.request) self.assertFalse('found' in str(r)) self.params['password'] = '******' r = login(self.request) self.assertTrue('found' in str(r))
def test_logins(self): with testing.testConfig() as config: config.add_route('login', '/login') r= login(self.request) self.assertFalse('found' in str(r)) self.params['password'] = '******' r= login(self.request) # Still blocked: self.assertFalse('found' in str(r)) # Unblock: user = self.request.userdb.get_user('JoeUser') user['blocked'] = False self.request.userdb.save_user(user) r= login(self.request) self.assertTrue('found' in str(r))
def test_logins(self): with testing.testConfig() as config: config.add_route('login', '/login') r = login(self.request) self.assertFalse('found' in str(r)) self.params['password'] = '******' r = login(self.request) # Still blocked: self.assertFalse('found' in str(r)) # Unblock: user = self.request.userdb.get_user('JoeUser') user['blocked'] = False self.request.userdb.save_user(user) r = login(self.request) self.assertTrue('found' in str(r))
def test_login(self): request = testing.DummyRequest(userdb=self.rundb.userdb, method='POST', params={ 'username': '******', 'password': '******' }) response = login(request) self.assertTrue( 'Invalid password' in request.session.pop_flash('error')) # Correct password, but still blocked from logging in request.params['password'] = '******' login(request) self.assertTrue('Blocked' in request.session.pop_flash('error')) # Unblock, then user can log in successfully user = self.rundb.userdb.get_user('JoeUser') user['blocked'] = False self.rundb.userdb.save_user(user) response = login(request) self.assertEqual(response.code, 302) self.assertTrue('The resource was found at' in str(response))