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
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
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
Hide 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 @@
#
##############################################################################
import
lxml.html
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
AccessControl.SecurityManagement
import
newSecurityManager
from
Products.ERP5Type.tests.Sequence
import
SequenceList
class
TestGUISecurity
(
ERP5TypeTestCase
):
"""
"""
...
...
@@ -82,9 +83,10 @@ class TestGUISecurity(ERP5TypeTestCase):
Try to view the Foo_view form, make sure our category name is displayed
"""
self
.
loginAs
()
self
.
assertIn
(
self
.
category_field_markup
,
self
.
portal
.
foo_module
.
foo
.
Foo_view
())
self
.
assertTrue
(
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_view
()
).
xpath
(
self
.
category_field_xpath
))
self
.
login
()
def
stepAccessFooDoesNotDisplayCategoryName
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -92,9 +94,10 @@ class TestGUISecurity(ERP5TypeTestCase):
Try to view the Foo_view form, make sure our category name is not displayed
"""
self
.
loginAs
()
self
.
assertNotIn
(
self
.
category_field_markup
,
self
.
portal
.
foo_module
.
foo
.
Foo_view
())
self
.
assertFalse
(
lxml
.
html
.
fromstring
(
self
.
portal
.
foo_module
.
foo
.
Foo_view
()
).
xpath
(
self
.
category_field_xpath
))
self
.
login
()
def
stepChangeCategorySecurity
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -127,7 +130,7 @@ class TestGUISecurity(ERP5TypeTestCase):
An attempt to view the document form would raise Unauthorized.
"""
# 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_string
=
'
\
...
...
@@ -156,11 +159,18 @@ class TestGUISecurity(ERP5TypeTestCase):
self
.
stepCreateObjects
()
self
.
stepCreateTestFoo
()
protected_property_markup
=
'<input name="field_my_protected_property" value="Protected Property" type="text"'
self
.
assertIn
(
protected_property_markup
,
self
.
portal
.
foo_module
.
foo
.
Foo_viewSecurity
())
protected_property_xpath
=
'//input[@name="field_my_protected_property" and @type="text" and @value="Protected Property"]'
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
.
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
):
"""
...
...
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