0001-include-query-string-in-password-change-uri-20750.patch
mandayejs/mandaye/views.py | ||
---|---|---|
17 | 17 |
from __future__ import absolute_import |
18 | 18 | |
19 | 19 |
import logging |
20 |
from urlparse import urlparse
|
|
20 |
from urlparse import urlsplit, urlunsplit
|
|
21 | 21 | |
22 | 22 |
from django.contrib.auth.models import User |
23 | 23 |
from django.contrib.auth.decorators import login_required |
... | ... | |
172 | 172 |
messages.error(request, _('invalid response from server')) |
173 | 173 |
url = resolve_url('associate') |
174 | 174 |
elif result.get('result') == 'redirect': |
175 |
url = urlparse(result.get('url', '/'))
|
|
176 |
url = url.path
|
|
175 |
url = urlsplit(result.get('url', '/'))
|
|
176 |
url = urlunsplit((None, None, url.path, url.query, url.fragment))
|
|
177 | 177 |
else: |
178 | 178 |
credentials.linked = True |
179 | 179 |
credentials.save() |
tests/test_mandayejs.py | ||
---|---|---|
333 | 333 |
assert cred.locators['birth_date'] == '1995-06-11' |
334 | 334 | |
335 | 335 | |
336 |
@pytest.fixture(params=[ |
|
337 |
{'url1': 'http://mydomain.com/update_password.aspx'}, |
|
338 |
{'url2': 'http://mydomain.com/index?path=change_pass'}]) |
|
339 |
def redirect_url(request): |
|
340 |
return request.param |
|
341 | ||
342 | ||
336 | 343 |
@mock.patch('mandayejs.mandaye.utils.subprocess.Popen') |
337 | 344 |
@mock.patch('mandayejs.applications.Test.SITE_LOCATORS', MOCKED_SITE_LOCATORS) |
338 |
def test_post_login_do(mocked_popen, user_john): |
|
345 |
def test_post_login_do(mocked_popen, user_john, redirect_url):
|
|
339 | 346 |
expected_output = { |
340 | 347 |
"result": "redirect", |
341 | 348 |
"reason": "password change required", |
342 |
"url": "http://mydomain.com/update_password.aspx"
|
|
349 |
"url": redirect_url.get('url1') or redirect_url.get('url2')
|
|
343 | 350 |
} |
344 | 351 |
expected_output = '<mandayejs>%s</mandayejs>' % json.dumps(expected_output) |
345 | 352 |
mocked_popen.return_value = MockedPopen(expected_output=(expected_output, None)) |
... | ... | |
353 | 360 |
request = request.get(reverse('post-login-do')) |
354 | 361 |
request.user = user_john |
355 | 362 |
response = post_login_do(request) |
356 |
assert 'window.top.location = "/update_password.aspx"' in response.content |
|
363 |
if 'url1' in redirect_url: |
|
364 |
assert 'window.top.location = "/update_password.aspx"' in response.content |
|
365 |
else: |
|
366 |
assert 'window.top.location = "/index?path=change_pass"' in response.content |
|
357 | 367 | |
358 | 368 | |
359 | 369 |
@mock.patch('mandayejs.mandaye.utils.subprocess.Popen') |
360 |
- |