devtools/testlib.py
changeset 9039 488255d1cf3b
parent 9031 6ff29f2879da
child 9042 6cc13a0a9145
equal deleted inserted replaced
9038:1b972d81eda4 9039:488255d1cf3b
   766         else:
   766         else:
   767             self.config.anonymous_credential = (anonuser, anonuser)
   767             self.config.anonymous_credential = (anonuser, anonuser)
   768 
   768 
   769     def init_authentication(self, authmode, anonuser=None):
   769     def init_authentication(self, authmode, anonuser=None):
   770         self.set_auth_mode(authmode, anonuser)
   770         self.set_auth_mode(authmode, anonuser)
   771         req = self.request(url='login')
   771         req = self.requestcls(self.vreg, url='login')
   772         origsession = req.session
       
   773         req.session = req.cnx = None
       
   774         del req.execute # get back to class implementation
       
   775         sh = self.app.session_handler
   772         sh = self.app.session_handler
   776         authm = sh.session_manager.authmanager
   773         authm = sh.session_manager.authmanager
   777         authm.anoninfo = self.vreg.config.anonymous_user()
   774         authm.anoninfo = self.vreg.config.anonymous_user()
   778         authm.anoninfo = authm.anoninfo[0], {'password': authm.anoninfo[1]}
   775         authm.anoninfo = authm.anoninfo[0], {'password': authm.anoninfo[1]}
   779         # not properly cleaned between tests
   776         # not properly cleaned between tests
   780         self.open_sessions = sh.session_manager._sessions = {}
   777         self.open_sessions = sh.session_manager._sessions = {}
   781         return req, origsession
   778         return req, self.websession
   782 
   779 
   783     def assertAuthSuccess(self, req, origsession, nbsessions=1):
   780     def assertAuthSuccess(self, req, origsession, nbsessions=1):
   784         sh = self.app.session_handler
   781         sh = self.app.session_handler
   785         session = self.app.get_session(req)
   782         session = self.app.get_session(req)
   786         req.set_session(session)
   783         req.set_session(session)