コード例 #1
0
ファイル: test_middleware.py プロジェクト: zodman/ZoomFoundry
 def setUp(self):
     self.env = {
         'REQUEST_URI': '/test/route',
         'REQUEST_METHOD': 'POST',
     }
     zoom.system.request = request = Request(self.env)
     request.site = Site(request)
     request.site.db = setup_test()
     request.session = Session(request)
     zoom.forms.form_for('test')  # trigger crsf token creation
     self.request = request
コード例 #2
0
 def setUp(self):
     self.env = {
         'REQUEST_URI': '/test/route',
         'REQUEST_METHOD': 'POST',
     }
     request = Request(self.env)
     request.site = Site(request)
     request.site.db = setup_test()
     request.session = Session(request)
     from zoom.forms import csrf_token
     csrf_token(request.session)  # bind a token
     self.request = request
コード例 #3
0
 def setUp(self):
     self.env = {
         'REQUEST_URI': '/test/route',
         'REQUEST_METHOD': 'POST',
     }
     zoom.system.providers = []
     request = Request(self.env)
     request.site = Site(request)
     request.site.db = setup_test()
     request.session = Session(request)
     reset_csrf_token(request.session)  # bind a token
     self.request = request
コード例 #4
0
ファイル: test_session.py プロジェクト: robinsax/zoom
    def test_unicode_value(self):
        logger = logging.getLogger(__name__)

        db = self.request.site.db

        # create session and and store a unicode value
        session = Session(self.request)
        token = session.token
        logger.debug('created session %r', token)
        self.assertNotEqual(token, 'Session error')
        session.content = 'こんにちは'
        session.save(db)

        try:
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, token)
            self.assertEqual(len(list(q)), 1)

            # Create new session object
            session2 = Session(self.request)

            # Load previously created session
            self.request.session_token = token
            session2.load(db, token)
            self.assertEqual(session2.content, 'こんにちは')

        finally:
            session.destroy()

            logger.debug('attempting to destroy session %r', token)
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, token)
            self.assertEqual(len(list(q)), 0)
コード例 #5
0
ファイル: test_session.py プロジェクト: robinsax/zoom
    def test_session(self):
        logger = logging.getLogger(__name__)

        db = self.request.site.db

        # create session and and store some values
        session = Session(self.request)
        token = session.token
        logger.debug('created session %r', token)
        self.assertNotEqual(token, 'Session error')
        session.MyName = 'Test'
        session.Message = 'This is a test session'
        session.Number = 123

        session.save(db)
        try:
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, token)
            self.assertEqual(len(list(q)), 1)

            # Create new session object
            session2 = Session(self.request)

            # Load previously created session
            self.request.session_token = token
            session2.load(db, token)
            self.assertEqual(session2.Number, 123)
            self.assertEqual(session2.MyName, 'Test')
            self.assertEqual(session2.Message, 'This is a test session')

        finally:
            session.destroy()

            logger.debug('attempting to destroy session %r', token)
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, token)
            self.assertEqual(len(list(q)), 0)
コード例 #6
0
ファイル: test_session.py プロジェクト: sean-hayes/zoom
    def test_session(self):
        db = self.request.site.db

        session = Session(self.request)

        #Create new session
        # id = session.new(db)
        id = session._token
        logger.debug('created session %r', id)
        # logger.debug('session._token is %r', session._token)
        self.assert_(id != 'Session error')
        session.MyName = 'Test'
        session.Message = 'This is a test session'
        session.Number = 123

        session.save(db)
        try:
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 1)

            # Create new session object
            session2 = Session(self.request)

            # Load previously created session
            self.request.session_token = id
            session2.load(db, id)
            self.assertEqual(session2.Number, 123)
            self.assertEqual(session2.MyName, 'Test')
            self.assertEqual(session2.Message, 'This is a test session')

        finally:
            session.destroy()

            logger.debug('attempting to destroy session %r', id)
            cmd = 'select * from sessions where id=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 0)
コード例 #7
0
    def test_session(self):
        system.setup(os.path.expanduser('~'))
        db = system.db

        session = Session(system)

        #Create new session
        id = session.new_session()
        self.assert_(id!='Session error')
        session.MyName = 'Test'
        session.Message = 'This is a test session'
        session.Number = 123

        session.save_session(id)
        try:
            cmd = 'select * from dz_sessions where sesskey=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 1)

            # Create new session object
            session2 = Session(system)

            # Load previously created session
            request.session_token = id
            session2.load_session()
            self.assertEqual(session2.Number,123)
            self.assertEqual(session2.MyName,'Test')
            self.assertEqual(session2.Message,'This is a test session')

        finally:
            session.destroy_session(id)

            cmd = 'select * from dz_sessions where sesskey=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 0)
コード例 #8
0
    def test_session(self):
        system.setup(os.path.expanduser('~'))
        db = system.db

        session = Session(system)

        #Create new session
        id = session.new_session()
        self.assert_(id != 'Session error')
        session.MyName = 'Test'
        session.Message = 'This is a test session'
        session.Number = 123

        session.save_session(id)
        try:
            cmd = 'select * from dz_sessions where sesskey=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 1)

            # Create new session object
            session2 = Session(system)

            # Load previously created session
            request.session_token = id
            session2.load_session()
            self.assertEqual(session2.Number, 123)
            self.assertEqual(session2.MyName, 'Test')
            self.assertEqual(session2.Message, 'This is a test session')

        finally:
            session.destroy_session(id)

            cmd = 'select * from dz_sessions where sesskey=%s'
            q = db(cmd, id)
            self.assertEqual(len(list(q)), 0)