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
01462aa2
Commit
01462aa2
authored
Apr 12, 2002
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit test
parent
2827ad89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
lib/python/AccessControl/tests/testClassSecurityInfo.py
lib/python/AccessControl/tests/testClassSecurityInfo.py
+67
-0
No files found.
lib/python/AccessControl/tests/testClassSecurityInfo.py
0 → 100644
View file @
01462aa2
##############################################################################
#
# Copyright (c) 2001 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
#
##############################################################################
""" """
import
os
,
sys
,
unittest
,
ZODB
,
Globals
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
OFS.Folder
import
Folder
class
ClassSecurityInfoTests
(
unittest
.
TestCase
):
def
testSetPermissionDefault
(
self
):
"""Test setting default roles for permissions."""
# Setup a test class with default role -> permission decls.
class
Test
(
Folder
):
"""Test class"""
__ac_roles__
=
(
'Role A'
,
'Role B'
,
'Role C'
)
meta_type
=
"Test"
security
=
ClassSecurityInfo
()
security
.
setPermissionDefault
(
'Test permission'
,
(
'Manager'
,
'Role A'
,
'Role B'
,
'Role C'
)
)
security
.
declareProtected
(
'Test permission'
,
'foo'
)
def
foo
(
self
,
REQUEST
=
None
):
""" """
pass
# Do class initialization.
Globals
.
InitializeClass
(
Test
)
# Now check the resulting class to see if the mapping was made
# correctly. Note that this uses carnal knowledge of the internal
# structures used to store this information!
object
=
Test
()
imPermissionRole
=
object
.
foo__roles__
self
.
failUnless
(
len
(
imPermissionRole
)
==
4
)
for
item
in
(
'Manager'
,
'Role A'
,
'Role B'
,
'Role C'
):
self
.
failUnless
(
item
in
imPermissionRole
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
ClassSecurityInfoTests
))
return
suite
def
main
():
unittest
.
TextTestRunner
().
run
(
test_suite
())
if
__name__
==
'__main__'
:
main
()
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