##// END OF EJS Templates
testapp: moved login/csrf session methods into TestApp itself....
marcink -
r2374:e331d3e6 default
parent child Browse files
Show More
@@ -42,7 +42,7 b' from rhodecode.model.meta import Session'
42 from rhodecode.model.scm import ScmModel
42 from rhodecode.model.scm import ScmModel
43 from rhodecode.lib.vcs.backends.svn.repository import SubversionRepository
43 from rhodecode.lib.vcs.backends.svn.repository import SubversionRepository
44 from rhodecode.lib.vcs.backends.base import EmptyCommit
44 from rhodecode.lib.vcs.backends.base import EmptyCommit
45
45 from rhodecode.tests import login_user_session
46
46
47 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
48
48
@@ -72,7 +72,7 b' class CustomTestResponse(TestResponse):'
72 no = []
72 no = []
73 if kw:
73 if kw:
74 raise TypeError(
74 raise TypeError(
75 "The only keyword argument allowed is 'no'")
75 "The only keyword argument allowed is 'no' got %s" % kw)
76
76
77 f = self._save_output(str(self))
77 f = self._save_output(str(self))
78
78
@@ -118,9 +118,27 b' class TestRequest(webob.BaseRequest):'
118
118
119 class CustomTestApp(TestApp):
119 class CustomTestApp(TestApp):
120 """
120 """
121 Custom app to make mustcontain more usefull
121 Custom app to make mustcontain more usefull, and extract special methods
122 """
122 """
123 RequestClass = TestRequest
123 RequestClass = TestRequest
124 rc_login_data = {}
125 rc_current_session = None
126
127 def login(self, username=None, password=None):
128 from rhodecode.lib import auth
129
130 if username and password:
131 session = login_user_session(self, username, password)
132 else:
133 session = login_user_session(self)
134
135 self.rc_login_data['csrf_token'] = auth.get_csrf_token(session)
136 self.rc_current_session = session
137 return session['rhodecode_user']
138
139 @property
140 def csrf_token(self):
141 return self.rc_login_data['csrf_token']
124
142
125
143
126 def set_anonymous_access(enabled):
144 def set_anonymous_access(enabled):
General Comments 0
You need to be logged in to leave comments. Login now