changeset 93:8fd53ae8818a

Extend doctests to cover account activation and password reset.
author Daniele Nicolodi <daniele@grinta.net>
date Sun, 21 Aug 2011 18:17:27 +0200
parents 6e9ba2b64d1f
children 65c700a145c9
files src/ltpdarepo/tests/manage-users.txt
diffstat 1 files changed, 51 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/ltpdarepo/tests/manage-users.txt	Sun Aug 21 18:17:27 2011 +0200
+++ b/src/ltpdarepo/tests/manage-users.txt	Sun Aug 21 18:17:27 2011 +0200
@@ -36,8 +36,18 @@
     >>> browser.contents
     '...<div class="flash message">User created. Activation token: <a href="...">...</a></div>...'
 
+Activate the new user::
+
+    >>> browser.getLink(url='?token=').click()
+    >>> browser.url
+    'http://localhost/user/user1/activate?token=...'
+    >>> browser.getControl(name='password').value = 'passwd'
+    >>> browser.getControl(name='confirm').value = 'passwd'
+    >>> browser.getControl(name='submit').click()
+
 View user::
 
+    >>> browser.open('/manage/users/')
     >>> browser.getLink('user1').click()
     >>> browser.url
     'http://localhost/manage/users/user1'
@@ -52,42 +62,59 @@
     >>> browser.url
     'http://localhost/manage/users/user1'
 
-Set password::
-
-    >>> from ltpdarepo.admin import passwd
-    >>> passwd('user1', 'passwd1')
-
 Login as the new user::
 
-    >>> browser.open('/logout')
-    >>> browser.url
-    'http://localhost/login'
-    >>> browser.getControl(name='username').value = 'user1'
-    >>> browser.getControl(name='password').value = 'passwd1'
-    >>> browser.getControl(name='login').click()
+    >>> browser.login('user1', 'passwd')
     >>> browser.url
     'http://localhost/'
 
 Login as administrator user::
 
-    >>> browser.open('/logout')
-    >>> browser.url
-    'http://localhost/login'
-    >>> browser.getControl(name='username').value = USERNAME
-    >>> browser.getControl(name='password').value = PASSWORD
-    >>> browser.getControl(name='login').click()
+    >>> browser.login(USERNAME, PASSWORD)
     >>> browser.url
     'http://localhost/'
 
-Get users management interface::
+Get to the managment interface for the created user::
+
+    >>> browser.open('/manage/users/user1')
+    >>> browser.url
+    'http://localhost/manage/users/user1'
 
-    >>> browser.getLink('Users').click()
+Reset password::
+
+    >>> browser.getLink('Reset password').click()
+    >>> browser.url
+    'http://localhost/manage/users/user1/reset'
+    >>> browser.getControl(name='ok').click()
     >>> browser.url
     'http://localhost/manage/users/'
+    >>> browser.contents
+    '...<div class="flash message">Password reset token: <a href="...">...</a></div>...'
+
+Set the new password::
+
+    >>> browser.getLink(url='?token=').click()
+    >>> browser.url
+    'http://localhost/user/user1/reset?token=...'
+    >>> browser.getControl(name='password').value = 'dwssap'
+    >>> browser.getControl(name='confirm').value = 'dwssap'
+    >>> browser.getControl(name='submit').click()
+
+Login as the new user::
+
+    >>> browser.login('user1', 'dwssap')
+    >>> browser.url
+    'http://localhost/'
+
+Login as administrator again::
+
+    >>> browser.login(USERNAME, PASSWORD)
+    >>> browser.url
+    'http://localhost/'
 
 Drop just created user::
 
-    >>> browser.getLink('user1').click()
+    >>> browser.open('/manage/users/user1')
     >>> browser.url
     'http://localhost/manage/users/user1'
 
@@ -113,6 +140,10 @@
     Traceback (most recent call last):
     HTTPError: HTTP Error 404: NOT FOUND
 
+    >>> browser.open('/manage/users/foo/reset')
+    Traceback (most recent call last):
+    HTTPError: HTTP Error 404: NOT FOUND
+
 It is not possible to create an user with a duplicate username::
 
     >>> browser.open('/manage/users/+')