Back to index

plone3  3.1.7
helpers.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights
00004 # Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this
00008 # distribution.
00009 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00010 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00011 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00012 # FOR A PARTICULAR PURPOSE.
00013 #
00014 ##############################################################################
00015 from Products.PluggableAuthService.tests.test_PluggableAuthService \
00016     import FauxContainer
00017 
00018 class FauxPAS( FauxContainer ):
00019 
00020     def __init__( self ):
00021         self._id = 'acl_users'
00022 
00023     def searchPrincipals( self, **kw ):
00024         id = kw.get( 'id' )
00025         return [ { 'id': id } ]
00026 
00027 class FauxSmartPAS( FauxContainer ):
00028 
00029     def __init__( self ):
00030         self._id = 'acl_users'
00031         self.user_ids = {}
00032 
00033     def searchPrincipals( self, **kw ):
00034         id = kw.get( 'id' )
00035         prin = self.user_ids.get(id, None)
00036         return (prin and [ { 'id': id } ]) or []
00037 
00038 class DummyUser:
00039 
00040     def __init__( self, id, groups=() ):
00041         self._id = id
00042         self._groups = groups
00043 
00044     def getId( self ):
00045         return self._id
00046 
00047     def getGroups( self ):
00048         return self._groups
00049 
00050 
00051 def makeRequestAndResponse():
00052     # the POST checking requires a real HTTPRequest
00053     from cStringIO import StringIO
00054     from ZPublisher.HTTPRequest import HTTPRequest
00055     from ZPublisher.HTTPResponse import HTTPResponse
00056 
00057     res = HTTPResponse()
00058     req = HTTPRequest(StringIO(),
00059                       {'SERVER_NAME': 'localhost',
00060                        'SERVER_PORT': '80'},
00061                       res)
00062     return req, res