[Zope3-checkins] CVS: Zope3/src/zope/app/services/pluggableauth/tests - authsetup.py:1.1 test_pluggableauth.py:1.9

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:53:58 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/services/pluggableauth/tests
In directory cvs.zope.org:/tmp/cvs-serv22283/src/zope/app/services/pluggableauth/tests

Modified Files:
	test_pluggableauth.py 
Added Files:
	authsetup.py 
Log Message:


Removed zope.app.services.auth. It was deprecated since a long time. Jim said
I should have run into some problems with functional tests, but that was not
the case. As far as I can tell, everything works fine. Of course, all tests
pass.




=== Added File Zope3/src/zope/app/services/pluggableauth/tests/authsetup.py ===
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Setup local Pluggable Authentication Service for tests

This setup class can be used, if a set of local principals are required for a
test.

$Id: authsetup.py,v 1.1 2004/03/08 12:53:27 srichter Exp $
"""
import base64
from zope.publisher.browser import TestRequest as Request

from zope.app.tests import ztapi, setup
from zope.app.services.tests import placefulsetup
from zope.publisher.interfaces.http import IHTTPCredentials
from zope.app.security.interfaces import ILoginPassword
from zope.app.security.basicauthadapter import BasicAuthAdapter
from zope.app.services.pluggableauth import \
     PrincipalAuthenticationView, PluggableAuthenticationService, \
     BTreePrincipalSource, SimplePrincipal
from zope.app.interfaces.services.pluggableauth import IPrincipalSource

class AuthSetup(placefulsetup.PlacefulSetup):

    def setUp(self):
        sm = placefulsetup.PlacefulSetup.setUp(self, site=True)
        ztapi.provideAdapter(IHTTPCredentials, ILoginPassword, BasicAuthAdapter)

        ztapi.browserView(IPrincipalSource, "login",
                          (PrincipalAuthenticationView,))

        auth = setup.addService(sm, "PluggableAuthService",
                                PluggableAuthenticationService())

        one = BTreePrincipalSource()
        two = BTreePrincipalSource()
        self._one = one
        self._two = two

        auth.addPrincipalSource('one', one)
        auth.addPrincipalSource('two', two)
        self._auth = auth
        self.createUsers()

    def createUsers(self):

        self._srichter = SimplePrincipal('srichter', 'hello',
                                         'Stephan', 'Richter')
        self._srichter.id = 'srichter'
        self._jim = SimplePrincipal('jim', 'hello2',
                                    'Jim', 'Fulton')
        self._jim.id = 'jim'
        self._stevea = SimplePrincipal('stevea', 'hello3',
                                       'Steve', 'Alenxander')
        self._stevea.id = 'stevea'
        self._one['srichter'] = self._srichter
        self._one['jim'] = self._jim
        self._two['stevea'] = self._stevea

    def getRequest(self, uid=None, passwd=None):
        if uid is None:
            return Request()
        if passwd is None:
            passwd = ''
        dict =  {
            'HTTP_AUTHORIZATION':
            "Basic %s" % base64.encodestring('%s:%s' % (uid, passwd))
         }
        return Request(**dict)


=== Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py:1.8	Mon Mar  8 07:06:21 2004
+++ Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py	Mon Mar  8 07:53:27 2004
@@ -21,7 +21,6 @@
 
 from zope.app import zapi
 from zope.app.tests import ztapi
-from zope.app.services.auth import User
 from zope.app.services.tests import placefulsetup
 
 from zope.exceptions import NotFoundError




More information about the Zope3-Checkins mailing list