Commit cf1b13a8 authored by 's avatar

- converted interface to z3 interface.

parent b446f040
class IStandardUserFolder:
def getUser(self, name):
"""
Returns the user object specified by name. If there is no
user named 'name' in the user folder, return None.
"""
def getUsers(self):
"""
Returns a sequence of all user objects which reside in the user
folder.
"""
def getUserNames(self):
"""
Returns a sequence of names of the users which reside in the user
folder.
"""
...@@ -7,30 +7,36 @@ ...@@ -7,30 +7,36 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
"""Access control package""" """Access control package.
__version__='$Revision: 1.182 $'[11:-2] $Id$
"""
import os import os
import re
import socket
from base64 import decodestring
import Globals, socket, SpecialUsers,re import Globals
from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping
from App.Management import Navigation, Tabs
from Acquisition import Implicit from Acquisition import Implicit
from App.Management import Navigation, Tabs
from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from base64 import decodestring
from App.ImageFile import ImageFile
from Role import RoleManager, DEFAULTMAXLISTUSERS
from PermissionRole import _what_not_even_god_should_do, rolesForPermissionOn
import AuthEncoding
from AccessControl import getSecurityManager
from zExceptions import Unauthorized, BadRequest from zExceptions import Unauthorized, BadRequest
from AccessControl.SecurityManagement import newSecurityManager from zope.interface import implements
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.ZopeSecurityPolicy import _noroles import AuthEncoding
import SpecialUsers
from interfaces import IStandardUserFolder
from PermissionRole import _what_not_even_god_should_do, rolesForPermissionOn
from Role import RoleManager, DEFAULTMAXLISTUSERS
from SecurityManagement import getSecurityManager
from SecurityManagement import newSecurityManager
from SecurityManagement import noSecurityManager
from ZopeSecurityPolicy import _noroles
_marker=[] _marker=[]
...@@ -978,7 +984,7 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -978,7 +984,7 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
def _setId(self, id): def _setId(self, id):
if id != self.id: if id != self.id:
raise Globals.MessageDialog( raise MessageDialog(
title='Invalid Id', title='Invalid Id',
message='Cannot change the id of a UserFolder', message='Cannot change the id of a UserFolder',
action ='./manage_main',) action ='./manage_main',)
...@@ -1001,7 +1007,9 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -1001,7 +1007,9 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
""" returns true if domain auth mode is set to true""" """ returns true if domain auth mode is set to true"""
return getattr(self, '_domain_auth_mode', None) return getattr(self, '_domain_auth_mode', None)
class UserFolder(BasicUserFolder): class UserFolder(BasicUserFolder):
"""Standard UserFolder object """Standard UserFolder object
A UserFolder holds User objects which contain information A UserFolder holds User objects which contain information
...@@ -1009,6 +1017,8 @@ class UserFolder(BasicUserFolder): ...@@ -1009,6 +1017,8 @@ class UserFolder(BasicUserFolder):
UserFolders function chiefly to control access by authenticating UserFolders function chiefly to control access by authenticating
users and binding them to a collection of roles.""" users and binding them to a collection of roles."""
implements(IStandardUserFolder)
meta_type='User Folder' meta_type='User Folder'
id ='acl_users' id ='acl_users'
title ='User Folder' title ='User Folder'
...@@ -1090,10 +1100,6 @@ class UserFolder(BasicUserFolder): ...@@ -1090,10 +1100,6 @@ class UserFolder(BasicUserFolder):
Globals.default__class_init__(UserFolder) Globals.default__class_init__(UserFolder)
def manage_addUserFolder(self,dtself=None,REQUEST=None,**ignored): def manage_addUserFolder(self,dtself=None,REQUEST=None,**ignored):
""" """ """ """
f=UserFolder() f=UserFolder()
...@@ -1122,7 +1128,6 @@ addr_match=re.compile(r'((\d{1,3}\.){1,3}\*)|((\d{1,3}\.){3}\d{1,3})').match ...@@ -1122,7 +1128,6 @@ addr_match=re.compile(r'((\d{1,3}\.){1,3}\*)|((\d{1,3}\.){3}\d{1,3})').match
host_match=re.compile(r'(([\_0-9a-zA-Z\-]*\.)*[0-9a-zA-Z\-]*)').match host_match=re.compile(r'(([\_0-9a-zA-Z\-]*\.)*[0-9a-zA-Z\-]*)').match
def domainSpecMatch(spec, request): def domainSpecMatch(spec, request):
host='' host=''
addr='' addr=''
......
...@@ -263,3 +263,20 @@ class IRoleManager(IPermissionMappingSupport): ...@@ -263,3 +263,20 @@ class IRoleManager(IPermissionMappingSupport):
def possible_permissions(): def possible_permissions():
""" """
""" """
class IStandardUserFolder(Interface):
def getUser(name):
"""Get the user object specified by name.
If there is no user named 'name' in the user folder, return None.
"""
def getUsers():
"""Get a sequence of all user objects which reside in the user folder.
"""
def getUserNames():
"""Get a sequence of names of the users which reside in the user folder.
"""
...@@ -7,23 +7,23 @@ ...@@ -7,23 +7,23 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
"""User folder tests """User folder tests.
"""
__rcs_id__='$Id$' $Id$
__version__='$Revision: 1.10 $'[11:-2] """
import os, sys, base64, unittest import unittest
import Testing
import Zope2
Zope2.startup()
from Testing.makerequest import makerequest import os, sys, base64
import transaction import transaction
from Testing.makerequest import makerequest
import Zope2
Zope2.startup()
from AccessControl import Unauthorized from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -65,6 +65,13 @@ class UserFolderTests(unittest.TestCase): ...@@ -65,6 +65,13 @@ class UserFolderTests(unittest.TestCase):
user = user.__of__(self.uf) user = user.__of__(self.uf)
newSecurityManager(None, user) newSecurityManager(None, user)
def test_z3interfaces(self):
from AccessControl.interfaces import IStandardUserFolder
from AccessControl.User import UserFolder
from zope.interface.verify import verifyClass
verifyClass(IStandardUserFolder, UserFolder)
def testGetUser(self): def testGetUser(self):
self.failIfEqual(self.uf.getUser('user1'), None) self.failIfEqual(self.uf.getUser('user1'), None)
...@@ -239,6 +246,7 @@ class UserFolderTests(unittest.TestCase): ...@@ -239,6 +246,7 @@ class UserFolderTests(unittest.TestCase):
self.failUnless(uf._isPasswordEncrypted(user.__)) self.failUnless(uf._isPasswordEncrypted(user.__))
self.failUnless(pw_validate(user.__, PASSWORD)) self.failUnless(pw_validate(user.__, PASSWORD))
class UserTests(unittest.TestCase): class UserTests(unittest.TestCase):
def testGetUserName(self): def testGetUserName(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment