Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
128c6215
Commit
128c6215
authored
Jun 19, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out ZMI related parts of user folders and move it to OFS
parent
bb0df0df
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
560 additions
and
467 deletions
+560
-467
src/AccessControl/User.py
src/AccessControl/User.py
+9
-3
src/AccessControl/interfaces.py
src/AccessControl/interfaces.py
+2
-0
src/AccessControl/tests/testOwned.py
src/AccessControl/tests/testOwned.py
+1
-1
src/AccessControl/tests/testZopeSecurityPolicy.py
src/AccessControl/tests/testZopeSecurityPolicy.py
+6
-6
src/AccessControl/tests/test_userfolder.py
src/AccessControl/tests/test_userfolder.py
+176
-0
src/AccessControl/userfolder.py
src/AccessControl/userfolder.py
+8
-333
src/OFS/Application.py
src/OFS/Application.py
+1
-1
src/OFS/dtml/addUser.dtml
src/OFS/dtml/addUser.dtml
+0
-0
src/OFS/dtml/editUser.dtml
src/OFS/dtml/editUser.dtml
+0
-0
src/OFS/dtml/mainUser.dtml
src/OFS/dtml/mainUser.dtml
+0
-0
src/OFS/dtml/userFolderProps.dtml
src/OFS/dtml/userFolderProps.dtml
+0
-0
src/OFS/role.py
src/OFS/role.py
+2
-1
src/OFS/tests/test_userfolder.py
src/OFS/tests/test_userfolder.py
+2
-115
src/OFS/userfolder.py
src/OFS/userfolder.py
+346
-0
src/Products/OFSP/__init__.py
src/Products/OFSP/__init__.py
+4
-4
src/Testing/ZopeTestCase/ZopeTestCase.py
src/Testing/ZopeTestCase/ZopeTestCase.py
+1
-1
src/Testing/ZopeTestCase/testPortalTestCase.py
src/Testing/ZopeTestCase/testPortalTestCase.py
+1
-1
src/Testing/ZopeTestCase/testZopeTestCase.py
src/Testing/ZopeTestCase/testZopeTestCase.py
+1
-1
No files found.
src/AccessControl/User.py
View file @
128c6215
...
...
@@ -34,6 +34,12 @@ from .users import absattr
from
.users
import
reqattr
from
.users
import
UnrestrictedUser
as
Super
from
.userfolder
import
BasicUserFolder
from
.userfolder
import
UserFolder
from
.userfolder
import
manage_addUserFolder
from
zope.deferredimport
import
deprecated
deprecated
(
"User folders are no longer part of AccessControl, please depend "
"on Zope2 and import from OFS.userfolder or use the new minimal "
"user folder classes from AccessControl.userfolder."
,
BasicUserFolder
=
'OFS.userfolder:BasicUserFolder'
,
manage_addUserFolder
=
'OFS.userfolder:manage_addUserFolder'
,
UserFolder
=
'OFS.userfolder:UserFolder'
,
)
src/AccessControl/interfaces.py
View file @
128c6215
...
...
@@ -197,6 +197,7 @@ class IRoleManager(IPermissionMappingSupport):
'disallowed_permissions' -> all other permissions
"""
class
IStandardUserFolder
(
Interface
):
def
getUser
(
name
):
...
...
@@ -213,6 +214,7 @@ class IStandardUserFolder(Interface):
"""Get a sequence of names of the users which reside in the user folder.
"""
class
ISecurityPolicy
(
Interface
):
"""Plug-in policy for checking access to objects within untrusted code.
"""
...
...
src/AccessControl/tests/testOwned.py
View file @
128c6215
...
...
@@ -197,7 +197,7 @@ class OwnershipChangeTests(unittest.TestCase):
def
setUp
(
self
):
from
AccessControl.owner
import
UnownableOwner
from
AccessControl.
Us
er
import
UserFolder
from
AccessControl.
userfold
er
import
UserFolder
super
(
OwnershipChangeTests
,
self
).
setUp
()
self
.
root
=
FauxRoot
()
...
...
src/AccessControl/tests/testZopeSecurityPolicy.py
View file @
128c6215
...
...
@@ -167,8 +167,8 @@ class ZopeSecurityPolicyTestBase(unittest.TestCase):
uf
=
UserFolder
()
a
.
acl_users
=
uf
self
.
uf
=
a
.
acl_users
uf
.
_
addUser
(
'joe'
,
'password
'
,
'password'
,
user_roles
,
())
uf
.
_
addUser
(
'theowner'
,
'password
'
,
'password'
,
eo_roles
,
())
uf
.
_
doAddUser
(
'joe
'
,
'password'
,
user_roles
,
())
uf
.
_
doAddUser
(
'theowner
'
,
'password'
,
eo_roles
,
())
user
=
uf
.
getUserById
(
'joe'
)
self
.
user
=
user
context
=
SecurityContext
(
user
)
...
...
@@ -307,8 +307,8 @@ class ZopeSecurityPolicyTestBase(unittest.TestCase):
self
.
a
.
subobject
=
ImplictAcqObject
()
subobject
=
self
.
a
.
subobject
subobject
.
acl_users
=
UserFolder
()
subobject
.
acl_users
.
_
addUser
(
'theowner'
,
'password
'
,
'password'
,
eo_roles
+
sysadmin_roles
,
())
subobject
.
acl_users
.
_
doAddUser
(
'theowner
'
,
'password'
,
eo_roles
+
sysadmin_roles
,
())
subobject
.
r_item
=
RestrictedSimpleItem
()
r_subitem
=
subobject
.
r_item
r_subitem
.
owned_setuid_m
=
OwnedSetuidMethod
()
...
...
@@ -353,8 +353,8 @@ class ZopeSecurityPolicyTestBase(unittest.TestCase):
self
.
a
.
subobject
=
ImplictAcqObject
()
subobject
=
self
.
a
.
subobject
subobject
.
acl_users
=
UserFolder
()
subobject
.
acl_users
.
_
addUser
(
'theowner'
,
'password'
,
'password'
,
eo_roles
+
sysadmin_roles
,
())
subobject
.
acl_users
.
_
doAddUser
(
'theowner'
,
'password'
,
eo_roles
+
sysadmin_roles
,
())
subobject
.
item
=
UnprotectedSimpleItem
()
subitem
=
subobject
.
item
subitem
.
owned_setuid_m
=
OwnedSetuidMethod
()
...
...
src/AccessControl/tests/test_userfolder.py
0 → 100644
View file @
128c6215
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# 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.
#
##############################################################################
""" Unit tests for AccessControl.User
"""
import
unittest
# TODO class Test_readUserAccessFile(unittest.TestCase)
# TODO class BasicUserFoldertests(unittest.TestCase)
class
UserFolderTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
import
transaction
transaction
.
begin
()
def
tearDown
(
self
):
import
transaction
from
AccessControl.SecurityManagement
import
noSecurityManager
noSecurityManager
()
transaction
.
abort
()
def
_getTargetClass
(
self
):
from
AccessControl.userfolder
import
UserFolder
return
UserFolder
def
_makeOne
(
self
):
uf
=
self
.
_getTargetClass
()()
uf
.
_doAddUser
(
'user1'
,
'secret'
,
[
'role1'
],
[])
return
uf
def
_makeBasicAuthToken
(
self
,
creds
=
'user1:secret'
):
import
base64
return
'Basic %s'
%
base64
.
encodestring
(
creds
)
def
_login
(
self
,
uf
,
name
):
from
AccessControl.SecurityManagement
import
newSecurityManager
user
=
uf
.
getUserById
(
name
)
user
=
user
.
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
def
test_class_conforms_to_IStandardUserFolder
(
self
):
from
AccessControl.interfaces
import
IStandardUserFolder
from
zope.interface.verify
import
verifyClass
verifyClass
(
IStandardUserFolder
,
self
.
_getTargetClass
())
def
testGetUser
(
self
):
uf
=
self
.
_makeOne
()
self
.
failIfEqual
(
uf
.
getUser
(
'user1'
),
None
)
def
testGetBadUser
(
self
):
uf
=
self
.
_makeOne
()
self
.
assertEqual
(
uf
.
getUser
(
'user2'
),
None
)
def
testGetUserById
(
self
):
uf
=
self
.
_makeOne
()
self
.
failIfEqual
(
uf
.
getUserById
(
'user1'
),
None
)
def
testGetBadUserById
(
self
):
uf
=
self
.
_makeOne
()
self
.
assertEqual
(
uf
.
getUserById
(
'user2'
),
None
)
def
testGetUsers
(
self
):
uf
=
self
.
_makeOne
()
users
=
uf
.
getUsers
()
self
.
failUnless
(
users
)
self
.
assertEqual
(
users
[
0
].
getUserName
(),
'user1'
)
def
testGetUserNames
(
self
):
uf
=
self
.
_makeOne
()
names
=
uf
.
getUserNames
()
self
.
failUnless
(
names
)
self
.
assertEqual
(
names
[
0
],
'user1'
)
def
testIdentify
(
self
):
uf
=
self
.
_makeOne
()
name
,
password
=
uf
.
identify
(
self
.
_makeBasicAuthToken
())
self
.
assertEqual
(
name
,
'user1'
)
self
.
assertEqual
(
password
,
'secret'
)
def
testGetRoles
(
self
):
uf
=
self
.
_makeOne
()
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
'role1'
in
user
.
getRoles
())
def
testMaxListUsers
(
self
):
# create a folder-ish thing which contains a roleManager,
# then put an acl_users object into the folde-ish thing
from
AccessControl.userfolder
import
BasicUserFolder
class
Folderish
(
BasicUserFolder
):
def
__init__
(
self
,
size
,
count
):
self
.
maxlistusers
=
size
self
.
users
=
[]
self
.
acl_users
=
self
self
.
__allow_groups__
=
self
for
i
in
xrange
(
count
):
self
.
users
.
append
(
"Nobody"
)
def
getUsers
(
self
):
return
self
.
users
def
user_names
(
self
):
return
self
.
getUsers
()
tinyFolderOver
=
Folderish
(
15
,
20
)
tinyFolderUnder
=
Folderish
(
15
,
10
)
assert
tinyFolderOver
.
maxlistusers
==
15
assert
tinyFolderUnder
.
maxlistusers
==
15
assert
len
(
tinyFolderOver
.
user_names
())
==
20
assert
len
(
tinyFolderUnder
.
user_names
())
==
10
try
:
list
=
tinyFolderOver
.
get_valid_userids
()
assert
0
,
"Did not raise overflow error"
except
OverflowError
:
pass
try
:
list
=
tinyFolderUnder
.
get_valid_userids
()
pass
except
OverflowError
:
assert
0
,
"Raised overflow error erroneously"
def
test__doAddUser_with_not_yet_encrypted_passwords
(
self
):
# See collector #1869 && #1926
from
AccessControl.AuthEncoding
import
pw_validate
USER_ID
=
'not_yet_encrypted'
PASSWORD
=
'password'
uf
=
self
.
_makeOne
()
uf
.
encrypt_passwords
=
True
self
.
failIf
(
uf
.
_isPasswordEncrypted
(
PASSWORD
))
uf
.
_doAddUser
(
USER_ID
,
PASSWORD
,
[],
[])
user
=
uf
.
getUserById
(
USER_ID
)
self
.
failUnless
(
uf
.
_isPasswordEncrypted
(
user
.
__
))
self
.
failUnless
(
pw_validate
(
user
.
__
,
PASSWORD
))
def
test__doAddUser_with_preencrypted_passwords
(
self
):
# See collector #1869 && #1926
from
AccessControl.AuthEncoding
import
pw_validate
USER_ID
=
'already_encrypted'
PASSWORD
=
'password'
uf
=
self
.
_makeOne
()
uf
.
encrypt_passwords
=
True
ENCRYPTED
=
uf
.
_encryptPassword
(
PASSWORD
)
uf
.
_doAddUser
(
USER_ID
,
ENCRYPTED
,
[],
[])
user
=
uf
.
getUserById
(
USER_ID
)
self
.
assertEqual
(
user
.
__
,
ENCRYPTED
)
self
.
failUnless
(
uf
.
_isPasswordEncrypted
(
user
.
__
))
self
.
failUnless
(
pw_validate
(
user
.
__
,
PASSWORD
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
UserFolderTests
))
return
suite
src/AccessControl/userfolder.py
View file @
128c6215
This diff is collapsed.
Click to expand it.
src/OFS/Application.py
View file @
128c6215
...
...
@@ -27,13 +27,13 @@ import transaction
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.Permission
import
ApplicationDefaultPermissions
from
AccessControl.User
import
UserFolder
from
Acquisition
import
aq_base
from
App.ApplicationManager
import
ApplicationManager
from
App.config
import
getConfiguration
from
App.Product
import
doInstall
from
DateTime
import
DateTime
from
HelpSys.HelpSys
import
HelpSys
from
OFS.userfolder
import
UserFolder
from
Persistence
import
Persistent
from
webdav.NullResource
import
NullResource
from
zExceptions
import
Redirect
as
RedirectException
,
Forbidden
...
...
src/
AccessControl
/dtml/addUser.dtml
→
src/
OFS
/dtml/addUser.dtml
View file @
128c6215
File moved
src/
AccessControl
/dtml/editUser.dtml
→
src/
OFS
/dtml/editUser.dtml
View file @
128c6215
File moved
src/
AccessControl
/dtml/mainUser.dtml
→
src/
OFS
/dtml/mainUser.dtml
View file @
128c6215
File moved
src/
AccessControl
/dtml/userFolderProps.dtml
→
src/
OFS
/dtml/userFolderProps.dtml
View file @
128c6215
File moved
src/OFS/role.py
View file @
128c6215
...
...
@@ -10,8 +10,9 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Access control support
"""
Role manager
"""
from
cgi
import
escape
from
App.Dialogs
import
MessageDialog
...
...
src/OFS/tests/test
UserF
older.py
→
src/OFS/tests/test
_userf
older.py
View file @
128c6215
...
...
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Unit tests for
AccessControl.Us
er
""" Unit tests for
OFS.userfold
er
"""
import
unittest
...
...
@@ -33,7 +33,7 @@ class UserFolderTests(unittest.TestCase):
transaction
.
abort
()
def
_getTargetClass
(
self
):
from
AccessControl.Us
er
import
UserFolder
from
OFS.userfold
er
import
UserFolder
return
UserFolder
def
_makeOne
(
self
,
app
=
None
):
...
...
@@ -74,45 +74,6 @@ class UserFolderTests(unittest.TestCase):
from
zope.interface.verify
import
verifyClass
verifyClass
(
IStandardUserFolder
,
self
.
_getTargetClass
())
def
testGetUser
(
self
):
uf
=
self
.
_makeOne
()
self
.
failIfEqual
(
uf
.
getUser
(
'user1'
),
None
)
def
testGetBadUser
(
self
):
uf
=
self
.
_makeOne
()
self
.
assertEqual
(
uf
.
getUser
(
'user2'
),
None
)
def
testGetUserById
(
self
):
uf
=
self
.
_makeOne
()
self
.
failIfEqual
(
uf
.
getUserById
(
'user1'
),
None
)
def
testGetBadUserById
(
self
):
uf
=
self
.
_makeOne
()
self
.
assertEqual
(
uf
.
getUserById
(
'user2'
),
None
)
def
testGetUsers
(
self
):
uf
=
self
.
_makeOne
()
users
=
uf
.
getUsers
()
self
.
failUnless
(
users
)
self
.
assertEqual
(
users
[
0
].
getUserName
(),
'user1'
)
def
testGetUserNames
(
self
):
uf
=
self
.
_makeOne
()
names
=
uf
.
getUserNames
()
self
.
failUnless
(
names
)
self
.
assertEqual
(
names
[
0
],
'user1'
)
def
testIdentify
(
self
):
uf
=
self
.
_makeOne
()
name
,
password
=
uf
.
identify
(
self
.
_makeBasicAuthToken
())
self
.
assertEqual
(
name
,
'user1'
)
self
.
assertEqual
(
password
,
'secret'
)
def
testGetRoles
(
self
):
uf
=
self
.
_makeOne
()
user
=
uf
.
getUser
(
'user1'
)
self
.
failUnless
(
'role1'
in
user
.
getRoles
())
def
testGetRolesInContext
(
self
):
app
=
self
.
_makeApp
()
uf
=
self
.
_makeOne
(
app
)
...
...
@@ -208,80 +169,6 @@ class UserFolderTests(unittest.TestCase):
app
=
self
.
_makeApp
()
self
.
assertRaises
(
Unauthorized
,
app
.
restrictedTraverse
,
'doc'
)
def
testMaxListUsers
(
self
):
# create a folder-ish thing which contains a roleManager,
# then put an acl_users object into the folde-ish thing
from
AccessControl.User
import
BasicUserFolder
class
Folderish
(
BasicUserFolder
):
def
__init__
(
self
,
size
,
count
):
self
.
maxlistusers
=
size
self
.
users
=
[]
self
.
acl_users
=
self
self
.
__allow_groups__
=
self
for
i
in
xrange
(
count
):
self
.
users
.
append
(
"Nobody"
)
def
getUsers
(
self
):
return
self
.
users
def
user_names
(
self
):
return
self
.
getUsers
()
tinyFolderOver
=
Folderish
(
15
,
20
)
tinyFolderUnder
=
Folderish
(
15
,
10
)
assert
tinyFolderOver
.
maxlistusers
==
15
assert
tinyFolderUnder
.
maxlistusers
==
15
assert
len
(
tinyFolderOver
.
user_names
())
==
20
assert
len
(
tinyFolderUnder
.
user_names
())
==
10
try
:
list
=
tinyFolderOver
.
get_valid_userids
()
assert
0
,
"Did not raise overflow error"
except
OverflowError
:
pass
try
:
list
=
tinyFolderUnder
.
get_valid_userids
()
pass
except
OverflowError
:
assert
0
,
"Raised overflow error erroneously"
def
test__doAddUser_with_not_yet_encrypted_passwords
(
self
):
# See collector #1869 && #1926
from
AccessControl.AuthEncoding
import
pw_validate
USER_ID
=
'not_yet_encrypted'
PASSWORD
=
'password'
uf
=
self
.
_makeOne
()
uf
.
encrypt_passwords
=
True
self
.
failIf
(
uf
.
_isPasswordEncrypted
(
PASSWORD
))
uf
.
_doAddUser
(
USER_ID
,
PASSWORD
,
[],
[])
user
=
uf
.
getUserById
(
USER_ID
)
self
.
failUnless
(
uf
.
_isPasswordEncrypted
(
user
.
__
))
self
.
failUnless
(
pw_validate
(
user
.
__
,
PASSWORD
))
def
test__doAddUser_with_preencrypted_passwords
(
self
):
# See collector #1869 && #1926
from
AccessControl.AuthEncoding
import
pw_validate
USER_ID
=
'already_encrypted'
PASSWORD
=
'password'
uf
=
self
.
_makeOne
()
uf
.
encrypt_passwords
=
True
ENCRYPTED
=
uf
.
_encryptPassword
(
PASSWORD
)
uf
.
_doAddUser
(
USER_ID
,
ENCRYPTED
,
[],
[])
user
=
uf
.
getUserById
(
USER_ID
)
self
.
assertEqual
(
user
.
__
,
ENCRYPTED
)
self
.
failUnless
(
uf
.
_isPasswordEncrypted
(
user
.
__
))
self
.
failUnless
(
pw_validate
(
user
.
__
,
PASSWORD
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
src/OFS/userfolder.py
0 → 100644
View file @
128c6215
This diff is collapsed.
Click to expand it.
src/Products/OFSP/__init__.py
View file @
128c6215
...
...
@@ -14,7 +14,7 @@ __doc__='''Object system core
$Id$'''
__version__
=
'$Revision: 1.38 $'
[
11
:
-
2
]
import
OFS.Image
,
OFS
.
Folder
,
AccessControl
.
Us
er
import
OFS.Image
,
OFS
.
Folder
,
OFS
.
userfold
er
import
OFS.DTMLMethod
,
OFS
.
DTMLDocument
,
OFS
.
PropertySheets
import
OFS.OrderedFolder
...
...
@@ -79,10 +79,10 @@ def initialize(context):
)
context
.
registerClass
(
AccessControl
.
Us
er
.
UserFolder
,
constructors
=
(
AccessControl
.
Us
er
.
manage_addUserFolder
,),
OFS
.
userfold
er
.
UserFolder
,
constructors
=
(
OFS
.
userfold
er
.
manage_addUserFolder
,),
icon
=
'images/UserFolder_icon.gif'
,
legacy
=
(
AccessControl
.
Us
er
.
manage_addUserFolder
,),
legacy
=
(
OFS
.
userfold
er
.
manage_addUserFolder
,),
)
context
.
registerHelp
()
...
...
src/Testing/ZopeTestCase/ZopeTestCase.py
View file @
128c6215
...
...
@@ -71,7 +71,7 @@ class ZopeTestCase(base.TestCase):
def
_setupUserFolder
(
self
):
'''Creates the user folder.'''
from
AccessControl.Us
er
import
manage_addUserFolder
from
OFS.userfold
er
import
manage_addUserFolder
manage_addUserFolder
(
self
.
folder
)
def
_setupUser
(
self
):
...
...
src/Testing/ZopeTestCase/testPortalTestCase.py
View file @
128c6215
...
...
@@ -406,7 +406,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
self
.
assertEqual
(
lhs
,
rhs
)
from
AccessControl.Us
er
import
UserFolder
from
OFS.userfold
er
import
UserFolder
class
WrappingUserFolder
(
UserFolder
):
'''User folder returning wrapped user objects'''
...
...
src/Testing/ZopeTestCase/testZopeTestCase.py
View file @
128c6215
...
...
@@ -349,7 +349,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
self
.
assertEqual
(
lhs
,
rhs
)
from
AccessControl.Us
er
import
UserFolder
from
OFS.userfold
er
import
UserFolder
from
Acquisition
import
aq_inner
,
aq_parent
,
aq_chain
class
WrappingUserFolder
(
UserFolder
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment