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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
erp5
Commits
64a4ec49
Commit
64a4ec49
authored
Feb 22, 2018
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testbrowser: cookie handling for logged-in user
parent
b7efa170
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
erp5/util/testbrowser/browser.py
erp5/util/testbrowser/browser.py
+17
-6
No files found.
erp5/util/testbrowser/browser.py
View file @
64a4ec49
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
import
logging
import
logging
import
sys
import
sys
import
urllib
import
urllib
import
Cookie
from
urlparse
import
urljoin
from
urlparse
import
urljoin
from
z3c.etestbrowser.browser
import
ExtendedTestBrowser
from
z3c.etestbrowser.browser
import
ExtendedTestBrowser
...
@@ -782,10 +783,25 @@ class MainForm(Form):
...
@@ -782,10 +783,25 @@ class MainForm(Form):
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
def
login
(
form
):
def
login
(
form
):
print
"Login with user-pass: "
+
self
.
browser
.
_username
+
" - "
+
self
.
browser
.
_password
form
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
form
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
form
.
getControl
(
name
=
'__ac_password'
).
value
=
self
.
browser
.
_password
form
.
getControl
(
name
=
'__ac_password'
).
value
=
self
.
browser
.
_password
form
.
submit
()
form
.
submit
()
def
setCookies
():
headers_cookie
=
self
.
browser
.
headers
[
'set-cookie'
]
cookie
=
Cookie
.
SimpleCookie
()
cookie
.
load
(
headers_cookie
)
if
'__ac'
in
cookie
.
keys
():
ac_value
=
cookie
[
'__ac'
].
value
else
:
for
part
in
headers_cookie
.
split
(
","
):
if
'__ac='
in
part
:
for
subpart
in
part
.
split
(
";"
):
if
'__ac='
in
subpart
:
ac_value
=
subpart
.
split
(
"="
)[
1
].
replace
(
'"'
,
''
)
self
.
browser
.
cookies
[
"__ac"
]
=
ac_value
try
:
try
:
login
(
self
)
login
(
self
)
except
LookupError
:
except
LookupError
:
...
@@ -797,12 +813,7 @@ class MainForm(Form):
...
@@ -797,12 +813,7 @@ class MainForm(Form):
(
self
.
browser
.
_erp5_base_url
,
(
self
.
browser
.
_erp5_base_url
,
self
.
browser
.
_username
,
self
.
browser
.
_username
,
self
.
browser
.
_password
))
self
.
browser
.
_password
))
setCookies
()
import
Cookie
cookie
=
Cookie
.
SimpleCookie
()
cookie
.
load
(
self
.
browser
.
headers
[
'set-cookie'
])
ac_value
=
cookie
[
'__ac'
].
value
self
.
browser
.
cookies
[
"__ac"
]
=
ac_value
def
submitSelectFavourite
(
self
,
label
=
None
,
value
=
None
,
**
kw
):
def
submitSelectFavourite
(
self
,
label
=
None
,
value
=
None
,
**
kw
):
"""
"""
...
...
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