From bc3d8d683959c0e9282109d4476c0617984cf74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 1 Jan 2018 13:47:42 +0100 Subject: [PATCH 1/2] tests: update redirection checks for django 1.11 (#20936) --- tests/test_backoffice_pages.py | 4 ++-- tests/test_form_pages.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py index 9630ffc2..6fa45f97 100644 --- a/tests/test_backoffice_pages.py +++ b/tests/test_backoffice_pages.py @@ -3882,7 +3882,7 @@ query_string_allowed_vars = foo,bar app = login(get_app(pub)) resp = app.get('/backoffice/submission/test/?session_var_foo=bar') - assert resp.location == 'http://example.net/backoffice/submission/test/' + assert resp.location.endswith('/backoffice/submission/test/') resp = resp.follow() assert '

XbarY

' in resp.body @@ -3893,6 +3893,6 @@ query_string_allowed_vars = foo,bar formdef.store() formdef.data_class().wipe() resp = app.get('/backoffice/submission/test/?session_var_foo=jang') - assert resp.location == 'http://example.net/backoffice/submission/test/' + assert resp.location.endswith('/backoffice/submission/test/') resp = resp.follow() assert '

django

' in resp.body diff --git a/tests/test_form_pages.py b/tests/test_form_pages.py index 5abd0cfc..2f402ebd 100644 --- a/tests/test_form_pages.py +++ b/tests/test_form_pages.py @@ -5,6 +5,7 @@ import os import re import StringIO import time +from urlparse import urlparse import zipfile import base64 from webtest import Upload @@ -1637,7 +1638,7 @@ def test_form_page_query_string_prefill(pub): # check it's not set if it's not whitelisted resp = get_app(pub).get('/?session_var_foo=hello') - assert resp.location == 'http://example.net/' + assert urlparse(resp.location).path == '/' resp = resp.follow() resp = resp.click('test') assert resp.forms[0]['f0'].value == '' @@ -1648,14 +1649,14 @@ query_string_allowed_vars = foo,bar ''') resp = get_app(pub).get('/?session_var_foo=hello') - assert resp.location == 'http://example.net/' + assert urlparse(resp.location).path == '/' resp = resp.follow() resp = resp.click('test') assert resp.forms[0]['f0'].value == 'hello' # check it survives a login resp = get_app(pub).get('/?session_var_foo=hello2') - assert resp.location == 'http://example.net/' + assert urlparse(resp.location).path == '/' resp = resp.follow() resp = resp.click('Login') resp = resp.follow() @@ -1668,14 +1669,15 @@ query_string_allowed_vars = foo,bar # check repeated options are ignored resp = get_app(pub).get('/?session_var_foo=hello&session_var_foo=hello2') - assert resp.location == 'http://example.net/' + assert urlparse(resp.location).path == '/' resp = resp.follow() resp = resp.click('test') assert resp.forms[0]['f0'].value == '' # check extra query string parameters are not lost resp = get_app(pub).get('/?session_var_foo=hello&foo=bar') - assert resp.location == 'http://example.net/?foo=bar' + assert urlparse(resp.location).path == '/' + assert urlparse(resp.location).query == 'foo=bar' os.unlink(os.path.join(pub.app_dir, 'site-options.cfg')) -- 2.15.1