From 0aa85f9f7072ca7fd42160d21c47b7f668a5664b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 10 Apr 2019 12:15:10 +0200 Subject: [PATCH 5/5] manager: replace $UUID pattern in next parameter of UserAddView (fixes #32140) --- src/authentic2/manager/user_views.py | 5 ++++- tests/test_manager.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/authentic2/manager/user_views.py b/src/authentic2/manager/user_views.py index 76398afa..711b1ea6 100644 --- a/src/authentic2/manager/user_views.py +++ b/src/authentic2/manager/user_views.py @@ -140,7 +140,10 @@ class UserAddView(BaseAddView): return select_next_url( self.request, default=reverse('a2-manager-user-detail', kwargs={'pk': self.object.pk}), - include_post=True) + include_post=True, + replace={ + '$UUID': self.object.uuid, + }) def get_context_data(self, **kwargs): context = super(UserAddView, self).get_context_data(**kwargs) diff --git a/tests/test_manager.py b/tests/test_manager.py index 399e2728..60cefb44 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -746,7 +746,7 @@ def test_manager_create_user_next(superuser_or_admin, app, ou1): assert response.pyquery.remove_namespaces()('a.cancel').attr('href') == '../..' assert response.pyquery.remove_namespaces()('input[name="next"]').attr('value') == next_url - next_url = u'/example.nowhere.null/' + next_url = u'/example.nowhere.null/$UUID/' cancel_url = u'/example.nowhere.cancel/' url = u'/manage/users/%s/add/?next=%s&cancel=%s' % (ou1.pk, next_url, cancel_url) response = app.get(url) @@ -760,7 +760,9 @@ def test_manager_create_user_next(superuser_or_admin, app, ou1): form.set('email', 'john.doe@gmail.com') form.set('password1', 'ABcd1234') form.set('password2', 'ABcd1234') - assert urlparse(form.submit().location).path == next_url + response = form.submit() + user = User.objects.latest('id') + assert urlparse(response.location).path == next_url.replace('$UUID', str(user.uuid)) def test_manager_create_user_next_form_error(superuser_or_admin, app, ou1): -- 2.20.1