Show More
@@ -49,6 +49,7 b' from rhodecode.model.db import User' | |||
|
49 | 49 | from rhodecode.lib import auth |
|
50 | 50 | from rhodecode.lib.helpers import flash, link_to |
|
51 | 51 | from rhodecode.lib.utils2 import safe_unicode, safe_str |
|
52 | from rhodecode.tests.utils import get_session_from_response | |
|
52 | 53 | |
|
53 | 54 | # TODO: johbo: Solve time zone related issues and remove this tweak |
|
54 | 55 | os.environ['TZ'] = 'UTC' |
@@ -186,12 +187,16 b' def login_user_session(' | |||
|
186 | 187 | pytest.fail('could not login using %s %s' % (username, password)) |
|
187 | 188 | |
|
188 | 189 | assert response.status == '302 Found' |
|
189 | ses = response.session['rhodecode_user'] | |
|
190 | assert ses.get('username') == username | |
|
191 | 190 | response = response.follow() |
|
192 | assert ses.get('is_authenticated') | |
|
191 | assert response.status == '200 OK' | |
|
193 | 192 | |
|
194 | return response.session | |
|
193 | session = get_session_from_response(response) | |
|
194 | assert 'rhodecode_user' in session | |
|
195 | rc_user = session['rhodecode_user'] | |
|
196 | assert rc_user.get('username') == username | |
|
197 | assert rc_user.get('is_authenticated') | |
|
198 | ||
|
199 | return session | |
|
195 | 200 | |
|
196 | 201 | |
|
197 | 202 | def logout_user_session(app, csrf_token): |
@@ -270,3 +270,13 b' def is_url_reachable(url):' | |||
|
270 | 270 | except urllib2.URLError: |
|
271 | 271 | return False |
|
272 | 272 | return True |
|
273 | ||
|
274 | ||
|
275 | def get_session_from_response(response): | |
|
276 | """ | |
|
277 | This returns the session from a response object. Pylons has some magic | |
|
278 | to make the session available as `response.session`. But pyramid | |
|
279 | doesn't expose it. | |
|
280 | """ | |
|
281 | # TODO: Try to look up the session key also. | |
|
282 | return response.request.environ['beaker.session'] |
General Comments 0
You need to be logged in to leave comments.
Login now