[Zope3-checkins] SVN: Zope3/branches/hdima-password-managers/src/zope/app/ Added AuthenticationPlaselessSetup

Dmitry Vasiliev dima at hlabs.spb.ru
Mon Oct 24 09:09:08 EDT 2005


Log message for revision 39572:
  Added AuthenticationPlaselessSetup
  

Changed:
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/ftests.py
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/groupfolder.txt
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/pau_prefix_and_searching.txt
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/principalfolder.txt
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/special-groups.txt
  A   Zope3/branches/hdima-password-managers/src/zope/app/authentication/placelesssetup.py
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.py
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.txt
  U   Zope3/branches/hdima-password-managers/src/zope/app/authentication/tests.py
  U   Zope3/branches/hdima-password-managers/src/zope/app/testing/placelesssetup.py

-=-
Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/ftests.py
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/ftests.py	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/ftests.py	2005-10-24 13:09:08 UTC (rev 39572)
@@ -31,6 +31,7 @@
 
 from zope.app.exception.interfaces import UserError
 
+
 class FunkTest(functional.BrowserTestCase):
 
     def test_copypaste_duplicated_id_object(self):
@@ -111,6 +112,7 @@
             # test failed !
             self.asserEqual(1, 0)
 
+
 def test_suite():
     return unittest.TestSuite((
         functional.FunctionalDocFileSuite('principalfolder.txt'),

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/groupfolder.txt
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/groupfolder.txt	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/groupfolder.txt	2005-10-24 13:09:08 UTC (rev 39572)
@@ -15,12 +15,6 @@
 
 First, We need to create and register a pluggable authentication utility.
 
-  >>> from zope.app.testing import ztapi
-  >>> from zope.app.authentication.interfaces import IPasswordManager
-  >>> from zope.app.authentication.password import PlainTextPasswordManager
-  >>> manager = PlainTextPasswordManager()
-  >>> ztapi.provideUtility(IPasswordManager, manager, "Plain Text")
-
   >>> print http(r"""
   ... POST /++etc++site/default/@@contents.html HTTP/1.1
   ... Authorization: Basic bWdyOm1ncnB3

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/pau_prefix_and_searching.txt
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/pau_prefix_and_searching.txt	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/pau_prefix_and_searching.txt	2005-10-24 13:09:08 UTC (rev 39572)
@@ -7,12 +7,6 @@
 
 First we'll create a PAU with a prefix of 'pau1_' and and register:
 
-  >>> from zope.app.testing import ztapi
-  >>> from zope.app.authentication.interfaces import IPasswordManager
-  >>> from zope.app.authentication.password import PlainTextPasswordManager
-  >>> manager = PlainTextPasswordManager()
-  >>> ztapi.provideUtility(IPasswordManager, manager, "Plain Text")
-
   >>> print http(r"""
   ... POST /++etc++site/default/+/AddPluggableAuthentication.html%3D HTTP/1.1
   ... Authorization: Basic bWdyOm1ncnB3

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/principalfolder.txt
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/principalfolder.txt	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/principalfolder.txt	2005-10-24 13:09:08 UTC (rev 39572)
@@ -18,14 +18,6 @@
 
 To allow Bob to log in, we'll start by adding a principal folder to PAU:
 
-First we need create a password manager:
-
-  >>> from zope.app.testing import ztapi
-  >>> from zope.app.authentication.interfaces import IPasswordManager
-  >>> from zope.app.authentication.password import PlainTextPasswordManager
-  >>> manager = PlainTextPasswordManager()
-  >>> ztapi.provideUtility(IPasswordManager, manager, "Plain Text")
-
 We need to create and register a pluggable authentication utility.
 
   >>> print http(r"""
@@ -186,7 +178,7 @@
   ... -----------------------------5110544421083023415453147877
   ... Content-Disposition: form-data; name="field.passwordManagerName"
   ... 
-  ... Plain Text
+  ... SHA1
   ... -----------------------------5110544421083023415453147877
   ... Content-Disposition: form-data; name="field.password"
   ... 

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/special-groups.txt
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/special-groups.txt	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/browser/special-groups.txt	2005-10-24 13:09:08 UTC (rev 39572)
@@ -18,12 +18,6 @@
 
 Create pluggable authentication utility and register it.
 
-  >>> from zope.app.testing import ztapi
-  >>> from zope.app.authentication.interfaces import IPasswordManager
-  >>> from zope.app.authentication.password import PlainTextPasswordManager
-  >>> manager = PlainTextPasswordManager()
-  >>> ztapi.provideUtility(IPasswordManager, manager, "Plain Text")
-
   >>> print http(r"""
   ... POST /++etc++site/default/@@contents.html HTTP/1.1
   ... Authorization: Basic bWdyOm1ncnB3

Added: Zope3/branches/hdima-password-managers/src/zope/app/authentication/placelesssetup.py
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/placelesssetup.py	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/placelesssetup.py	2005-10-24 13:09:08 UTC (rev 39572)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation 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.
+#
+##############################################################################
+"""Pluggable Authentication Service Placeless Setup
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.app.testing import ztapi
+from zope.app.authentication.interfaces import IPasswordManager
+from zope.app.authentication.password import PlainTextPasswordManager
+from zope.app.authentication.password import MD5PasswordManager
+from zope.app.authentication.password import SHA1PasswordManager
+
+
+class PlacelessSetup(object):
+
+    def setUp(self):
+        ztapi.provideUtility(IPasswordManager, PlainTextPasswordManager(),
+            "Plain Text")
+        ztapi.provideUtility(IPasswordManager, MD5PasswordManager(), "MD5")
+        ztapi.provideUtility(IPasswordManager, SHA1PasswordManager(), "SHA1")


Property changes on: Zope3/branches/hdima-password-managers/src/zope/app/authentication/placelesssetup.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.py
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.py	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.py	2005-10-24 13:09:08 UTC (rev 39572)
@@ -113,8 +113,8 @@
     def __init__(self, login, password, title, description=u'',
             passwordManagerName="Plain Text"):
         self._login = login
-        self._password = password
         self._passwordManagerName = passwordManagerName
+        self.password = password
         self.title = title
         self.description = description
 

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.txt
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.txt	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/principalfolder.txt	2005-10-24 13:09:08 UTC (rev 39572)
@@ -7,7 +7,8 @@
 class:
 
   >>> from zope.app.authentication.principalfolder import InternalPrincipal
-  >>> p1 = InternalPrincipal('login1', '123', "Principal 1")
+  >>> p1 = InternalPrincipal('login1', '123', "Principal 1",
+  ...     passwordManagerName="SHA1")
   >>> p2 = InternalPrincipal('login2', '456', "The Other One")
 
 and add then in map fashion to a principal folder:
@@ -25,7 +26,7 @@
   >>> from zope.testing.doctestunit import pprint
   >>> principals.authenticateCredentials({'login': 'login1', 'password': '123'})
   PrincipalInfo(u'principal.p1')
-   
+
 We get back a principal id and supplementary information, including the
 principal title and description.  Note that the principal id is a concatenation
 of the principal-folder prefix and the name of the principal-information object

Modified: Zope3/branches/hdima-password-managers/src/zope/app/authentication/tests.py
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/authentication/tests.py	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/authentication/tests.py	2005-10-24 13:09:08 UTC (rev 39572)
@@ -40,10 +40,7 @@
 from zope.publisher import base
 from zope.app.authentication.session import SessionCredentialsPlugin
 
-from zope.app.authentication.interfaces import IPasswordManager
-from zope.app.authentication.password import PlainTextPasswordManager
 
-
 class TestClientId(object):
     implements(IClientId)
     def __new__(cls, request):
@@ -97,12 +94,7 @@
 
         self.assertEqual(plugin.logout(base.TestRequest('/')), False)
 
-def principalFolderSetUp(test):
-    placelesssetup.setUp()
-    ztapi.provideUtility(IPasswordManager,
-        PlainTextPasswordManager(), "Plain Text")
 
-
 def test_suite():
     return unittest.TestSuite((
         doctest.DocTestSuite('zope.app.authentication.interfaces'),
@@ -111,10 +103,10 @@
         doctest.DocTestSuite('zope.app.authentication.httpplugins'),
         doctest.DocTestSuite('zope.app.authentication.ftpplugins'),
         doctest.DocFileSuite('principalfolder.txt',
-                             setUp=principalFolderSetUp,
+                             setUp=placelesssetup.setUp,
                              tearDown=placelesssetup.tearDown),
         doctest.DocTestSuite('zope.app.authentication.principalfolder',
-                             setUp=principalFolderSetUp,
+                             setUp=placelesssetup.setUp,
                              tearDown=placelesssetup.tearDown),
         doctest.DocTestSuite('zope.app.authentication.idpicker'),
         doctest.DocTestSuite('zope.app.authentication.session',

Modified: Zope3/branches/hdima-password-managers/src/zope/app/testing/placelesssetup.py
===================================================================
--- Zope3/branches/hdima-password-managers/src/zope/app/testing/placelesssetup.py	2005-10-24 10:56:11 UTC (rev 39571)
+++ Zope3/branches/hdima-password-managers/src/zope/app/testing/placelesssetup.py	2005-10-24 13:09:08 UTC (rev 39572)
@@ -25,6 +25,8 @@
     import PlacelessSetup as I18nPlacelessSetup
 from zope.app.container.tests.placelesssetup \
     import PlacelessSetup as ContainerPlacelessSetup
+from zope.app.authentication.placelesssetup \
+    import PlacelessSetup as AuthenticationPlacelessSetup
 from zope.app.security._protections import protect
 from zope.app.traversing.browser.interfaces import IAbsoluteURL
 from zope.app.traversing.browser.absoluteurl import AbsoluteURL
@@ -32,7 +34,8 @@
 class PlacelessSetup(CAPlacelessSetup,
                      EventPlacelessSetup,
                      I18nPlacelessSetup,
-                     ContainerPlacelessSetup
+                     ContainerPlacelessSetup,
+                     AuthenticationPlacelessSetup
                      ):
 
     def setUp(self, doctesttest=None):
@@ -40,6 +43,7 @@
         ContainerPlacelessSetup.setUp(self)
         EventPlacelessSetup.setUp(self)
         I18nPlacelessSetup.setUp(self)
+        AuthenticationPlacelessSetup.setUp(self)
         # Register app-specific security declarations
         protect()
 



More information about the Zope3-Checkins mailing list