From 0bec4131841c090c7af9f0820856964c522bae1f Mon Sep 17 00:00:00 2001 From: Javier Paniagua Date: Sun, 10 Sep 2023 12:07:32 +0200 Subject: [PATCH] unbotch urls for phone setup and create (fixes #655) --- tests/test_views_phone.py | 10 ++++++++++ two_factor/plugins/phonenumber/urls.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_views_phone.py b/tests/test_views_phone.py index b561aff96..6b527d73a 100644 --- a/tests/test_views_phone.py +++ b/tests/test_views_phone.py @@ -147,6 +147,11 @@ def test_missing_management_data(self): # view should return HTTP 400 Bad Request self.assertEqual(response.status_code, 400) + def test_url_generation(self): + url_name = 'two_factor:phone_create' + expected_url = '/account/two_factor/phone/register/' + self.assertEqual(reverse(url_name), expected_url) + class PhoneDeleteTest(UserMixin, TestCase): def setUp(self): @@ -187,6 +192,11 @@ def test_success_url_as_reverse_lazy(self): view.success_url = reverse_lazy(url_name) self.assertEqual(view.get_success_url(), url) + def test_url_generation(self): + url_name = 'two_factor:phone_delete' + expected_url = '/account/two_factor/phone/unregister/42/' + self.assertEqual(reverse(url_name, args=(42,)), expected_url) + class PhoneDeviceTest(UserMixin, TestCase): def setUp(self): diff --git a/two_factor/plugins/phonenumber/urls.py b/two_factor/plugins/phonenumber/urls.py index f8f15c3f2..cbb0c56dc 100644 --- a/two_factor/plugins/phonenumber/urls.py +++ b/two_factor/plugins/phonenumber/urls.py @@ -4,12 +4,12 @@ urlpatterns = [ path( - 'account/two_factor/backup/phone/register/', + 'register/', PhoneSetupView.as_view(), name='phone_create', ), path( - 'account/two_factor/backup/phone/unregister//', + 'unregister//', PhoneDeleteView.as_view(), name='phone_delete', ),