def test_bad_login(self): from webob import Request, Response import lib.chai objstore.insert(type='user', name='test',password='******') lib.chai.req = Request.blank('server/?_method=lib.chai.session.login&user=test&password=111') lib.chai.res = Response() # login ret = session.login(**lib.chai.req.params) self.assertTrue(ret['error']=='Invalid Login') self.assertTrue('message' not in ret)
def test_bad_login(self): from webob import Request, Response import lib.chai objstore.insert(type='user', name='test', password='******') lib.chai.req = Request.blank( 'server/?_method=lib.chai.session.login&user=test&password=111') lib.chai.res = Response() # login ret = session.login(**lib.chai.req.params) self.assertTrue(ret['error'] == 'Invalid Login') self.assertTrue('message' not in ret)
def test_login(self): # make a user from webob import Request, Response import lib.chai objstore.insert(type='user', name='test',password='******') lib.chai.req = Request.blank('server/?_method=lib.chai.session.login&user=test&password=pass') lib.chai.res = Response() # login ret = session.login(**lib.chai.req.params) self.sid = lib.chai.res.headers.get('Set-Cookie').split(';')[0].split('=')[1] self.assertTrue(ret['userobj']['name']=='test') self.assertTrue(ret['message']=='ok') self.assertTrue(db.sql("""select * from session where user='******'""")[0]['user']=='test')
def test_login(self): # make a user from webob import Request, Response import lib.chai objstore.insert(type='user', name='test', password='******') lib.chai.req = Request.blank( 'server/?_method=lib.chai.session.login&user=test&password=pass') lib.chai.res = Response() # login ret = session.login(**lib.chai.req.params) self.sid = lib.chai.res.headers.get('Set-Cookie').split(';')[0].split( '=')[1] self.assertTrue(ret['userobj']['name'] == 'test') self.assertTrue(ret['message'] == 'ok') self.assertTrue( db.sql("""select * from session where user='******'""")[0]['user'] == 'test')