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
Léo-Paul Géneau
erp5
Commits
6f400ae6
Commit
6f400ae6
authored
Jul 01, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oauth_google_login: test the case of existing user
parent
d45bf6ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
...mplateItem/portal_components/test.erp5.testGoogleLogin.py
+43
-0
No files found.
bt5/erp5_oauth_google_login/TestTemplateItem/portal_components/test.erp5.testGoogleLogin.py
View file @
6f400ae6
...
...
@@ -136,6 +136,49 @@ class TestGoogleLogin(ERP5TypeTestCase):
self
.
assertNotIn
(
"secret_key="
,
location
)
self
.
assertIn
(
"ERP5Site_receiveGoogleCallback"
,
location
)
def
test_existing_user
(
self
):
self
.
login
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
)
person
.
newContent
(
portal_type
=
'Google Login'
,
reference
=
getUserId
(
None
)
).
validate
()
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
self
.
tic
()
self
.
logout
()
request
=
self
.
portal
.
REQUEST
response
=
request
.
RESPONSE
with
mock
.
patch
(
'erp5.component.extension.GoogleLoginUtility.getAccessTokenFromCode'
,
side_effect
=
getAccessTokenFromCode
,
)
as
getAccessTokenFromCode_mock
,
\
mock
.
patch
(
'erp5.component.extension.GoogleLoginUtility.getUserEntry'
,
side_effect
=
getUserEntry
)
as
getUserEntry_mock
:
getAccessTokenFromCode_mock
.
func_code
=
getAccessTokenFromCode
.
func_code
getUserEntry_mock
.
func_code
=
getUserEntry
.
func_code
self
.
portal
.
ERP5Site_receiveGoogleCallback
(
code
=
CODE
)
getAccessTokenFromCode_mock
.
assert_called_once
()
getUserEntry_mock
.
assert_called_once
()
request
[
"__ac_google_hash"
]
=
response
.
cookies
[
"__ac_google_hash"
][
"value"
]
credentials
=
self
.
portal
.
acl_users
.
erp5_google_extraction
.
extractCredentials
(
request
)
self
.
assertEqual
(
'Google Login'
,
credentials
[
'login_portal_type'
])
self
.
assertEqual
(
getUserId
(
None
),
credentials
[
'external_login'
])
user_id
,
login
=
self
.
portal
.
acl_users
.
erp5_login_users
.
authenticateCredentials
(
credentials
)
self
.
assertEqual
(
person
.
getUserId
(),
user_id
)
self
.
assertEqual
(
getUserId
(
None
),
login
)
def
test_auth_cookie
(
self
):
request
=
self
.
portal
.
REQUEST
response
=
request
.
RESPONSE
...
...
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