Merge lp:~allenap/maas/accounts-view-patterns into lp:~maas-committers/maas/trunk

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 1451
Proposed branch: lp:~allenap/maas/accounts-view-patterns
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 35 lines (+10/-3)
2 files modified
src/maasserver/tests/test_views_settings.py (+7/-0)
src/maasserver/urls.py (+3/-3)
To merge this branch: bzr merge lp:~allenap/maas/accounts-view-patterns
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+152185@code.launchpad.net

Commit message

Ensure that all account views are routable by a full range of possible usernames.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Thanks for the fix!

[0]

s/charaters/characters/

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/tests/test_views_settings.py'
2--- src/maasserver/tests/test_views_settings.py 2012-11-13 10:44:22 +0000
3+++ src/maasserver/tests/test_views_settings.py 2013-03-07 15:07:21 +0000
4@@ -374,3 +374,10 @@
5 content_text = doc.cssselect('#content')[0].text_content()
6 self.assertIn(user.username, content_text)
7 self.assertIn(user.email, content_text)
8+
9+ def test_account_views_are_routable_for_full_range_of_usernames(self):
10+ # Usernames can include characters in the regex [\w.@+-].
11+ user = factory.make_user(username="abc-123@example.com")
12+ for view in "edit", "view", "del":
13+ path = reverse("accounts-%s" % view, args=[user.username])
14+ self.assertIsInstance(path, (str, unicode))
15
16=== modified file 'src/maasserver/urls.py'
17--- src/maasserver/urls.py 2013-02-08 18:26:41 +0000
18+++ src/maasserver/urls.py 2013-03-07 15:07:21 +0000
19@@ -162,13 +162,13 @@
20 adminurl(r'^settings/$', settings, name='settings'),
21 adminurl(r'^accounts/add/$', AccountsAdd.as_view(), name='accounts-add'),
22 adminurl(
23- r'^accounts/(?P<username>\w+)/edit/$', AccountsEdit.as_view(),
24+ r'^accounts/(?P<username>[^/]+)/edit/$', AccountsEdit.as_view(),
25 name='accounts-edit'),
26 adminurl(
27- r'^accounts/(?P<username>\w+)/view/$', AccountsView.as_view(),
28+ r'^accounts/(?P<username>[^/]+)/view/$', AccountsView.as_view(),
29 name='accounts-view'),
30 adminurl(
31- r'^accounts/(?P<username>\w+)/del/$', AccountsDelete.as_view(),
32+ r'^accounts/(?P<username>[^/]+)/del/$', AccountsDelete.as_view(),
33 name='accounts-del'),
34 adminurl(
35 r'^commissioning-scripts/(?P<id>[\w\-]+)/delete/$',