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
a79318a5
Commit
a79318a5
authored
Jun 22, 2020
by
Jérome Perrin
Committed by
Gabriel Monnerat
Aug 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oauth_google_login: test integration with ERP5JS
parent
0a46a28c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
...mplateItem/portal_components/test.erp5.testGoogleLogin.py
+33
-2
bt5/erp5_oauth_google_login/bt/test_dependency_list
bt5/erp5_oauth_google_login/bt/test_dependency_list
+2
-1
No files found.
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
View file @
a79318a5
...
@@ -27,6 +27,9 @@
...
@@ -27,6 +27,9 @@
import
uuid
import
uuid
import
mock
import
mock
import
lxml
import
urlparse
import
httplib
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
...
@@ -89,8 +92,7 @@ def getUserEntry(access_token):
...
@@ -89,8 +92,7 @@ def getUserEntry(access_token):
}
}
class
TestGoogleLogin
(
ERP5TypeTestCase
):
class
GoogleLoginTestCase
(
ERP5TypeTestCase
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
"""
"""
This is ran before anything, used to set the environment
This is ran before anything, used to set the environment
...
@@ -123,6 +125,8 @@ class TestGoogleLogin(ERP5TypeTestCase):
...
@@ -123,6 +125,8 @@ class TestGoogleLogin(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
self
.
logout
()
self
.
logout
()
class
TestGoogleLogin
(
GoogleLoginTestCase
):
def
test_redirect
(
self
):
def
test_redirect
(
self
):
"""
"""
Check URL generate to redirect to Google
Check URL generate to redirect to Google
...
@@ -301,3 +305,30 @@ return credential_request
...
@@ -301,3 +305,30 @@ return credential_request
person
=
credential_request
.
getDestinationDecisionValue
()
person
=
credential_request
.
getDestinationDecisionValue
()
google_login
=
person
.
objectValues
(
portal_types
=
"Google Login"
)[
0
]
google_login
=
person
.
objectValues
(
portal_types
=
"Google Login"
)[
0
]
self
.
assertEqual
(
getUserId
(
None
),
google_login
.
getReference
())
self
.
assertEqual
(
getUserId
(
None
),
google_login
.
getReference
())
def
test_logout
(
self
):
resp
=
self
.
publish
(
self
.
portal
.
getId
()
+
'/logout'
)
self
.
assertEqual
(
resp
.
getCookie
(
"__ac_google_hash"
)[
'value'
],
'deleted'
)
class
TestERP5JSGoogleLogin
(
GoogleLoginTestCase
):
def
_getWebSite
(
self
):
return
self
.
portal
.
web_site_module
.
renderjs_runner
def
test_login_form
(
self
):
resp
=
self
.
publish
(
self
.
_getWebSite
().
getPath
()
+
'/login_form'
)
tree
=
lxml
.
etree
.
fromstring
(
resp
.
getBody
(),
parser
=
lxml
.
etree
.
HTMLParser
())
google_login_link
,
=
[
img
.
getparent
().
attrib
[
'href'
]
for
img
in
tree
.
findall
(
'.//a/img'
)
if
img
.
attrib
[
'alt'
]
==
'Sign in with Google'
]
self
.
assertIn
(
'/ERP5Site_redirectToGoogleLoginPage'
,
google_login_link
)
resp
=
self
.
publish
(
urlparse
.
urlparse
(
google_login_link
).
path
)
# this request redirects to google
self
.
assertEqual
(
resp
.
getStatus
(),
httplib
.
FOUND
)
self
.
assertIn
(
'google.com'
,
resp
.
getHeader
(
'Location'
))
def
test_logout
(
self
):
resp
=
self
.
publish
(
self
.
_getWebSite
().
getPath
()
+
'/WebSite_logout'
)
self
.
assertEqual
(
resp
.
getCookie
(
"__ac_google_hash"
)[
'value'
],
'deleted'
)
bt5/erp5_oauth_google_login/bt/test_dependency_list
View file @
a79318a5
erp5_full_text_myisam_catalog
erp5_full_text_myisam_catalog
erp5_credential
erp5_credential
\ No newline at end of file
erp5_web_renderjs_ui
\ No newline at end of file
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