Projet

Général

Profil

0001-tests-update-redirection-checks-for-django-1.11-2093.patch

Frédéric Péters, 01 janvier 2018 13:49

Télécharger (3,37 ko)

Voir les différences:

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(-)
tests/test_backoffice_pages.py
3882 3882
    app = login(get_app(pub))
3883 3883

  
3884 3884
    resp = app.get('/backoffice/submission/test/?session_var_foo=bar')
3885
    assert resp.location == 'http://example.net/backoffice/submission/test/'
3885
    assert resp.location.endswith('/backoffice/submission/test/')
3886 3886
    resp = resp.follow()
3887 3887
    assert '<p class="comment-field ">XbarY</p>' in resp.body
3888 3888

  
......
3893 3893
    formdef.store()
3894 3894
    formdef.data_class().wipe()
3895 3895
    resp = app.get('/backoffice/submission/test/?session_var_foo=jang')
3896
    assert resp.location == 'http://example.net/backoffice/submission/test/'
3896
    assert resp.location.endswith('/backoffice/submission/test/')
3897 3897
    resp = resp.follow()
3898 3898
    assert '<p class="comment-field ">django</p>' in resp.body
tests/test_form_pages.py
5 5
import re
6 6
import StringIO
7 7
import time
8
from urlparse import urlparse
8 9
import zipfile
9 10
import base64
10 11
from webtest import Upload
......
1637 1638

  
1638 1639
    # check it's not set if it's not whitelisted
1639 1640
    resp = get_app(pub).get('/?session_var_foo=hello')
1640
    assert resp.location == 'http://example.net/'
1641
    assert urlparse(resp.location).path == '/'
1641 1642
    resp = resp.follow()
1642 1643
    resp = resp.click('test')
1643 1644
    assert resp.forms[0]['f0'].value == ''
......
1648 1649
''')
1649 1650

  
1650 1651
    resp = get_app(pub).get('/?session_var_foo=hello')
1651
    assert resp.location == 'http://example.net/'
1652
    assert urlparse(resp.location).path == '/'
1652 1653
    resp = resp.follow()
1653 1654
    resp = resp.click('test')
1654 1655
    assert resp.forms[0]['f0'].value == 'hello'
1655 1656

  
1656 1657
    # check it survives a login
1657 1658
    resp = get_app(pub).get('/?session_var_foo=hello2')
1658
    assert resp.location == 'http://example.net/'
1659
    assert urlparse(resp.location).path == '/'
1659 1660
    resp = resp.follow()
1660 1661
    resp = resp.click('Login')
1661 1662
    resp = resp.follow()
......
1668 1669

  
1669 1670
    # check repeated options are ignored
1670 1671
    resp = get_app(pub).get('/?session_var_foo=hello&session_var_foo=hello2')
1671
    assert resp.location == 'http://example.net/'
1672
    assert urlparse(resp.location).path == '/'
1672 1673
    resp = resp.follow()
1673 1674
    resp = resp.click('test')
1674 1675
    assert resp.forms[0]['f0'].value == ''
1675 1676

  
1676 1677
    # check extra query string parameters are not lost
1677 1678
    resp = get_app(pub).get('/?session_var_foo=hello&foo=bar')
1678
    assert resp.location == 'http://example.net/?foo=bar'
1679
    assert urlparse(resp.location).path == '/'
1680
    assert urlparse(resp.location).query == 'foo=bar'
1679 1681

  
1680 1682
    os.unlink(os.path.join(pub.app_dir, 'site-options.cfg'))
1681 1683

  
1682
-