Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
c4111aea
Commit
c4111aea
authored
Feb 21, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: use xpath when checking for HTML
parent
492e9ac9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
bt5/erp5_ui_test/TestTemplateItem/portal_components/test.erp5.testGUIwithSecurity.py
...teItem/portal_components/test.erp5.testGUIwithSecurity.py
+21
-11
No files found.
bt5/erp5_ui_test/TestTemplateItem/portal_components/test.erp5.testGUIwithSecurity.py
View file @
c4111aea
...
@@ -27,12 +27,13 @@
...
@@ -27,12 +27,13 @@
#
#
##############################################################################
##############################################################################
import
lxml.html
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.Sequence
import
SequenceList
class
TestGUISecurity
(
ERP5TypeTestCase
):
class
TestGUISecurity
(
ERP5TypeTestCase
):
"""
"""
"""
"""
...
@@ -82,9 +83,10 @@ class TestGUISecurity(ERP5TypeTestCase):
...
@@ -82,9 +83,10 @@ class TestGUISecurity(ERP5TypeTestCase):
Try to view the Foo_view form, make sure our category name is displayed
Try to view the Foo_view form, make sure our category name is displayed
"""
"""
self
.
loginAs
()
self
.
loginAs
()
self
.
assertIn
(
self
.
assertTrue
(
self
.
category_field_markup
,
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_view
())
self
.
portal
.
foo_module
.
foo
.
Foo_view
()
).
xpath
(
self
.
category_field_xpath
))
self
.
login
()
self
.
login
()
def
stepAccessFooDoesNotDisplayCategoryName
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepAccessFooDoesNotDisplayCategoryName
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
@@ -92,9 +94,10 @@ class TestGUISecurity(ERP5TypeTestCase):
...
@@ -92,9 +94,10 @@ class TestGUISecurity(ERP5TypeTestCase):
Try to view the Foo_view form, make sure our category name is not displayed
Try to view the Foo_view form, make sure our category name is not displayed
"""
"""
self
.
loginAs
()
self
.
loginAs
()
self
.
assertNotIn
(
self
.
assertFalse
(
self
.
category_field_markup
,
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_view
())
self
.
portal
.
foo_module
.
foo
.
Foo_view
()
).
xpath
(
self
.
category_field_xpath
))
self
.
login
()
self
.
login
()
def
stepChangeCategorySecurity
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepChangeCategorySecurity
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
@@ -127,7 +130,7 @@ class TestGUISecurity(ERP5TypeTestCase):
...
@@ -127,7 +130,7 @@ class TestGUISecurity(ERP5TypeTestCase):
An attempt to view the document form would raise Unauthorized.
An attempt to view the document form would raise Unauthorized.
"""
"""
# this really depends on the generated markup
# this really depends on the generated markup
self
.
category_field_
markup
=
'<input name="field_my_foo_category_title" value="a" type="text"
'
self
.
category_field_
xpath
=
'//input[@name="field_my_foo_category_title" and @type="text" and @value="a"]
'
sequence_list
=
SequenceList
()
sequence_list
=
SequenceList
()
sequence_string
=
'
\
sequence_string
=
'
\
...
@@ -156,11 +159,18 @@ class TestGUISecurity(ERP5TypeTestCase):
...
@@ -156,11 +159,18 @@ class TestGUISecurity(ERP5TypeTestCase):
self
.
stepCreateObjects
()
self
.
stepCreateObjects
()
self
.
stepCreateTestFoo
()
self
.
stepCreateTestFoo
()
protected_property_markup
=
'<input name="field_my_protected_property" value="Protected Property" type="text"'
protected_property_xpath
=
'//input[@name="field_my_protected_property" and @type="text" and @value="Protected Property"]'
self
.
assertIn
(
protected_property_markup
,
self
.
portal
.
foo_module
.
foo
.
Foo_viewSecurity
())
self
.
assertTrue
(
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_viewSecurity
()
).
xpath
(
protected_property_xpath
))
self
.
loginAs
()
# user without permission to access protected property
self
.
loginAs
()
# user without permission to access protected property
self
.
assertNotIn
(
protected_property_markup
,
self
.
portal
.
foo_module
.
foo
.
Foo_viewSecurity
())
self
.
assertFalse
(
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_viewSecurity
()
).
xpath
(
protected_property_xpath
))
def
test_translated_state_title_lookup
(
self
):
def
test_translated_state_title_lookup
(
self
):
"""
"""
...
...
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