[Checkins] SVN: z3c.password/trunk/src/z3c/password/ Reflect new error handling in tests

Roger Ineichen roger at projekt01.ch
Mon Oct 23 10:52:36 EDT 2006


Log message for revision 70891:
  Reflect new error handling in tests

Changed:
  U   z3c.password/trunk/src/z3c/password/README.txt
  A   z3c.password/trunk/src/z3c/password/testing.py
  U   z3c.password/trunk/src/z3c/password/tests.py

-=-
Modified: z3c.password/trunk/src/z3c/password/README.txt
===================================================================
--- z3c.password/trunk/src/z3c/password/README.txt	2006-10-23 14:32:04 UTC (rev 70890)
+++ z3c.password/trunk/src/z3c/password/README.txt	2006-10-23 14:52:36 UTC (rev 70891)
@@ -64,29 +64,29 @@
   >>> pwd.verify(None)
   Traceback (most recent call last):
   ...
-  InvalidPassword: No new password specified.
+  NoPassword
 
   >>> pwd.verify('')
   Traceback (most recent call last):
   ...
-  InvalidPassword: No new password specified.
+  NoPassword
 
   >>> pwd.verify('', 'other')
   Traceback (most recent call last):
   ...
-  InvalidPassword: No new password specified.
+  NoPassword
 
 - Next, it is verified that the password has the correct length:
 
   >>> pwd.verify('foo')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password is too long or too short.
+  TooShortPassword
 
   >>> pwd.verify('foobar-foobar')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password is too long or too short.
+  TooLongPassword
 
   >>> pwd.verify('fooBar12')
 
@@ -100,7 +100,7 @@
   >>> pwd.verify('fooBar12', 'foobar12')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password too similar to old one.
+  TooSimilarPassword
 
 - The final check ensures that the password does not have too many characters
   of one group. The groups are: lower letters, upper letters, digits,
@@ -109,22 +109,22 @@
   >>> pwd.verify('fooBarBlah')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password contains too many characters of one group.
+  TooManyGroupCharacters
 
   >>> pwd.verify('FOOBARBlah')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password contains too many characters of one group.
+  TooManyGroupCharacters
 
   >>> pwd.verify('12345678')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password contains too many characters of one group.
+  TooManyGroupCharacters
 
   >>> pwd.verify('........')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password contains too many characters of one group.
+  TooManyGroupCharacters
 
 Let's now verify a list of password that were provided by a bank:
 
@@ -169,7 +169,7 @@
   >>> pwdField.validate(u'fooBar')
   Traceback (most recent call last):
   ...
-  InvalidPassword: New password is too long or too short.
+  TooShortPassword
 
 
 The Principal Mix-in
@@ -247,7 +247,7 @@
   >>> user.checkPassword('456456')
   Traceback (most recent call last):
   ...
-  TooManyLoginFailures
+  TooManyLoginFailures: The password was entered incorrectly too often.
 
 As you can see, once the maximum mount of attempts is reached, the system does
 not allow you to log in at all anymore. At this point the password has to be
@@ -270,7 +270,7 @@
   >>> user.checkPassword('456456')
   Traceback (most recent call last):
   ...
-  PasswordExpired
+  PasswordExpired: The password has expired.
 
 Like for the too-many-failures exception above, you can explicitely turn off
 the expiration check:

Added: z3c.password/trunk/src/z3c/password/testing.py
===================================================================
--- z3c.password/trunk/src/z3c/password/testing.py	2006-10-23 14:32:04 UTC (rev 70890)
+++ z3c.password/trunk/src/z3c/password/testing.py	2006-10-23 14:52:36 UTC (rev 70891)
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# Copyright (c) 2006 Lovely Systems and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test Setup
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.component
+from zope.app.authentication import password
+from zope.app.testing import placelesssetup
+
+
+def setUp(test):
+    placelesssetup.setUp(test)
+    zope.component.provideUtility(
+        password.PlainTextPasswordManager(), name='Plain Text')
+
+
+def tearDown(test):
+    placelesssetup.tearDown(test)


Property changes on: z3c.password/trunk/src/z3c/password/testing.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: z3c.password/trunk/src/z3c/password/tests.py
===================================================================
--- z3c.password/trunk/src/z3c/password/tests.py	2006-10-23 14:32:04 UTC (rev 70890)
+++ z3c.password/trunk/src/z3c/password/tests.py	2006-10-23 14:52:36 UTC (rev 70891)
@@ -19,23 +19,15 @@
 
 import doctest
 import unittest
-import zope.component
 from zope.testing.doctestunit import DocFileSuite
-from zope.app.authentication import password
-from zope.app.testing import placelesssetup
 
-def setUp(test):
-    placelesssetup.setUp(test)
-    zope.component.provideUtility(
-        password.PlainTextPasswordManager(), name='Plain Text')
+from z3c.password import testing
 
-def tearDown(test):
-    placelesssetup.tearDown(test)
 
 def test_suite():
     return unittest.TestSuite((
         DocFileSuite('README.txt',
-                     setUp=setUp, tearDown=tearDown,
+                     setUp=testing.setUp, tearDown=testing.tearDown,
                      optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
                      ),
         ))



More information about the Checkins mailing list