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
a38c7926
Commit
a38c7926
authored
May 16, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for SpecialUser, UnrestrictedUser, and NullUnrestrictedUser.
parent
d7a937b4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
0 deletions
+113
-0
src/AccessControl/tests/testUser.py
src/AccessControl/tests/testUser.py
+113
-0
No files found.
src/AccessControl/tests/testUser.py
View file @
a38c7926
...
...
@@ -96,6 +96,116 @@ class SimpleUserTests(unittest.TestCase):
self
.
assertEqual
(
simple
.
getRoles
(),
(
'Authenticated'
,))
class
SpecialUserTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
AccessControl.User
import
SpecialUser
return
SpecialUser
def
_makeOne
(
self
,
name
=
'admin'
,
password
=
'123'
,
roles
=
None
,
domains
=
None
):
if
roles
is
None
:
roles
=
[
'Manager'
]
if
domains
is
None
:
domains
=
[]
return
self
.
_getTargetClass
()(
name
,
password
,
roles
,
domains
)
def
test_overrides
(
self
):
simple
=
self
.
_makeOne
()
self
.
assertEqual
(
simple
.
getUserName
(),
'admin'
)
self
.
assertEqual
(
simple
.
getId
(),
None
)
self
.
assertEqual
(
simple
.
_getPassword
(),
'123'
)
self
.
assertEqual
(
simple
.
getDomains
(),
())
class
UnrestrictedUserTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
AccessControl.User
import
UnrestrictedUser
return
UnrestrictedUser
def
_makeOne
(
self
,
name
=
'admin'
,
password
=
'123'
,
roles
=
None
,
domains
=
None
):
if
roles
is
None
:
roles
=
[
'Manager'
]
if
domains
is
None
:
domains
=
[]
return
self
.
_getTargetClass
()(
name
,
password
,
roles
,
domains
)
def
test_allowed__what_not_even_god_should_do
(
self
):
from
AccessControl.PermissionRole
import
_what_not_even_god_should_do
unrestricted
=
self
.
_makeOne
()
self
.
failIf
(
unrestricted
.
allowed
(
self
,
_what_not_even_god_should_do
))
def
test_allowed_empty
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
allowed
(
self
,
()))
def
test_allowed_other
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
allowed
(
self
,
(
'Manager'
,)))
def
test_has_role_empty_no_object
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
has_role
(()))
def
test_has_role_empty_w_object
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
has_role
((),
self
))
def
test_has_role_other_no_object
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
has_role
((
'Manager'
,)))
def
test_has_role_other_w_object
(
self
):
unrestricted
=
self
.
_makeOne
()
self
.
failUnless
(
unrestricted
.
has_role
((
'Manager'
,),
self
))
class
NullUnrestrictedUserTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
AccessControl.User
import
NullUnrestrictedUser
return
NullUnrestrictedUser
def
_makeOne
(
self
):
return
self
.
_getTargetClass
()()
def
test_overrides
(
self
):
simple
=
self
.
_makeOne
()
self
.
assertEqual
(
simple
.
getUserName
(),
(
None
,
None
))
self
.
assertEqual
(
simple
.
getId
(),
None
)
self
.
assertEqual
(
simple
.
_getPassword
(),
(
None
,
None
))
self
.
assertEqual
(
simple
.
getRoles
(),
())
self
.
assertEqual
(
simple
.
getDomains
(),
())
def
test_getRolesInContext
(
self
):
null
=
self
.
_makeOne
()
self
.
assertEqual
(
null
.
getRolesInContext
(
self
),
())
def
test_authenticate
(
self
):
null
=
self
.
_makeOne
()
self
.
failIf
(
null
.
authenticate
(
'password'
,
{}))
def
test_allowed
(
self
):
null
=
self
.
_makeOne
()
self
.
failIf
(
null
.
allowed
(
self
,
()))
def
test_has_role
(
self
):
null
=
self
.
_makeOne
()
self
.
failIf
(
null
.
has_role
(
'Authenticated'
))
def
test_has_role_w_object
(
self
):
null
=
self
.
_makeOne
()
self
.
failIf
(
null
.
has_role
(
'Authenticated'
,
self
))
def
test_has_permission
(
self
):
null
=
self
.
_makeOne
()
self
.
failIf
(
null
.
has_permission
(
'View'
,
self
))
def
test___repr__
(
self
):
null
=
self
.
_makeOne
()
self
.
assertEqual
(
repr
(
null
),
"<NullUnrestrictedUser (None, None)>"
)
class
UserTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
...
...
@@ -415,6 +525,9 @@ def test_suite():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
BasicUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
SimpleUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
SpecialUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UnrestrictedUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
NullUnrestrictedUserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UserTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
UserFolderTests
))
return
suite
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