diff --git a/userena/tests/tests_urls.py b/userena/tests/tests_urls.py new file mode 100644 index 00000000..4feacfd7 --- /dev/null +++ b/userena/tests/tests_urls.py @@ -0,0 +1,25 @@ +from django.test import TestCase +from django.core.urlresolvers import reverse, NoReverseMatch + + +class UserenaUrlsTests(TestCase): + """ Test url resolve """ + + def test_resolve_email_with_plus_url(self): + username = 'foo+bar@example.com' + test_urls = [ + 'userena_signup_complete', + 'userena_email_change', + 'userena_email_change_complete', + 'userena_email_confirm_complete', + 'userena_disabled', + 'userena_password_change', + 'userena_password_change_complete', + 'userena_profile_edit', + 'userena_profile_detail', + ] + for url_name in test_urls: + try: + reverse(url_name, kwargs={'username': username}) + except NoReverseMatch as ex: + self.failed(ex) diff --git a/userena/urls.py b/userena/urls.py index b752ce73..37bd0545 100644 --- a/userena/urls.py +++ b/userena/urls.py @@ -48,7 +48,7 @@ def merged_dict(dict_a, dict_b): name='userena_password_reset_complete'), # Signup - url(r'^(?P[\@\.\w-]+)/signup/complete/$', + url(r'^(?P[\@\.\+\w-]+)/signup/complete/$', userena_views.direct_to_user_template, {'template_name': 'userena/signup_complete.html', 'extra_context': {'userena_activation_required': userena_settings.USERENA_ACTIVATION_REQUIRED, @@ -66,14 +66,14 @@ def merged_dict(dict_a, dict_b): name='userena_activate_retry'), # Change email and confirm it - url(r'^(?P[\@\.\w-]+)/email/$', + url(r'^(?P[\@\.\+\w-]+)/email/$', userena_views.email_change, name='userena_email_change'), - url(r'^(?P[\@\.\w-]+)/email/complete/$', + url(r'^(?P[\@\.\+\w-]+)/email/complete/$', userena_views.direct_to_user_template, {'template_name': 'userena/email_change_complete.html'}, name='userena_email_change_complete'), - url(r'^(?P[\@\.\w-]+)/confirm-email/complete/$', + url(r'^(?P[\@\.\+\w-]+)/confirm-email/complete/$', userena_views.direct_to_user_template, {'template_name': 'userena/email_confirm_complete.html'}, name='userena_email_confirm_complete'), @@ -82,27 +82,27 @@ def merged_dict(dict_a, dict_b): name='userena_email_confirm'), # Disabled account - url(r'^(?P[\@\.\w-]+)/disabled/$', + url(r'^(?P[\@\.\+\w-]+)/disabled/$', userena_views.disabled_account, {'template_name': 'userena/disabled.html'}, name='userena_disabled'), # Change password - url(r'^(?P[\@\.\w-]+)/password/$', + url(r'^(?P[\@\.\+\w-]+)/password/$', userena_views.password_change, name='userena_password_change'), - url(r'^(?P[\@\.\w-]+)/password/complete/$', + url(r'^(?P[\@\.\+\w-]+)/password/complete/$', userena_views.direct_to_user_template, {'template_name': 'userena/password_complete.html'}, name='userena_password_change_complete'), # Edit profile - url(r'^(?P[\@\.\w-]+)/edit/$', + url(r'^(?P[\@\.\+\w-]+)/edit/$', userena_views.profile_edit, name='userena_profile_edit'), # View profiles - url(r'^(?P(?!(signout|signup|signin)/)[\@\.\w-]+)/$', + url(r'^(?P(?!(signout|signup|signin)/)[\@\.\+\w-]+)/$', userena_views.profile_detail, name='userena_profile_detail'), url(r'^page/(?P[0-9]+)/$',