예제 #1
0
	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)
예제 #2
0
    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)
예제 #3
0
	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')
예제 #4
0
    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')