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
6499f127
Commit
6499f127
authored
Mar 21, 2013
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to provoke LP #1123420.
parent
ae8ab6db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
src/OFS/tests/testObjectManager.py
src/OFS/tests/testObjectManager.py
+81
-0
No files found.
src/OFS/tests/testObjectManager.py
View file @
6499f127
...
...
@@ -21,6 +21,7 @@ from OFS.SimpleItem import SimpleItem
logger
=
getLogger
(
'OFS.subscribers'
)
class
FauxRoot
(
Implicit
):
id
=
'/'
...
...
@@ -31,6 +32,7 @@ class FauxRoot( Implicit ):
def
getPhysicalPath
(
self
):
return
()
class
FauxUser
(
Implicit
):
def
__init__
(
self
,
id
,
login
):
...
...
@@ -45,6 +47,7 @@ class FauxUser( Implicit ):
class
DeleteFailed
(
Exception
):
pass
class
ItemForDeletion
(
SimpleItem
):
def
__init__
(
self
,
fail_on_delete
=
False
):
...
...
@@ -491,7 +494,85 @@ class ObjectManagerTests(PlacelessSetup, unittest.TestCase):
self
.
assertTrue
(
filename
.
endswith
(
'.zexp'
)
or
filename
.
endswith
(
'.xml'
))
_marker
=
object
()
class
Test_checkValidId
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
container
,
id
,
allow_dup
=
_marker
):
from
OFS.ObjectManager
import
checkValidId
if
allow_dup
is
_marker
:
return
checkValidId
(
container
,
id
)
return
checkValidId
(
container
,
id
,
allow_dup
)
def
_makeContainer
(
self
):
return
object
()
def
assertBadRequest
(
self
,
id
,
allow_dup
=
_marker
):
from
zExceptions
import
BadRequest
try
:
if
allow_dup
is
not
_marker
:
self
.
_callFUT
(
self
.
_makeContainer
(),
id
,
allow_dup
)
else
:
self
.
_callFUT
(
self
.
_makeContainer
(),
id
)
except
BadRequest
as
e
:
return
e
self
.
fail
(
"Didn't raise"
)
def
test_empty_string
(
self
):
e
=
self
.
assertBadRequest
(
''
)
self
.
assertEqual
(
str
(
e
),
"('Empty or invalid id specified', '')"
)
def
test_unicode
(
self
):
e
=
self
.
assertBadRequest
(
u'abc'
)
self
.
assertEqual
(
str
(
e
),
"('Empty or invalid id specified', u'abc')"
)
def
test_unicode_escaped
(
self
):
e
=
self
.
assertBadRequest
(
u'<abc>&def'
)
self
.
assertEqual
(
str
(
e
),
"('Empty or invalid id specified', "
"u'<abc>&def')"
)
def
test_badid_XSS
(
self
):
e
=
self
.
assertBadRequest
(
'<abc>&def'
)
self
.
assertEqual
(
str
(
e
),
'The id "<abc>&def" contains characters '
'illegal in URLs.'
)
def
test_one_dot
(
self
):
e
=
self
.
assertBadRequest
(
'.'
)
self
.
assertEqual
(
str
(
e
),
'The id "." is invalid because it is not '
'traversable.'
)
def
test_two_dots
(
self
):
e
=
self
.
assertBadRequest
(
'..'
)
self
.
assertEqual
(
str
(
e
),
'The id ".." is invalid because it is not '
'traversable.'
)
def
test_underscore
(
self
):
e
=
self
.
assertBadRequest
(
'_abc'
)
self
.
assertEqual
(
str
(
e
),
'The id "_abc" is invalid because it begins with '
'an underscore.'
)
def
test_aq_
(
self
):
e
=
self
.
assertBadRequest
(
'aq_abc'
)
self
.
assertEqual
(
str
(
e
),
'The id "aq_abc" is invalid because it begins with '
'"aq_".'
)
def
test_dunder_suffix
(
self
):
e
=
self
.
assertBadRequest
(
'abc__'
)
self
.
assertEqual
(
str
(
e
),
'The id "abc__" is invalid because it ends with '
'two underscores.'
)
def
test_suite
():
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
ObjectManagerTests
),
unittest
.
makeSuite
(
Test_checkValidId
),
))
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