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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xueyun Qian
erp5
Commits
1a19ea70
Commit
1a19ea70
authored
Aug 31, 2011
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test case for recovery of usernames
also fix check of email content in subscription message
parent
931bc41d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
4 deletions
+91
-4
product/ERP5/tests/testERP5Credential.py
product/ERP5/tests/testERP5Credential.py
+91
-4
No files found.
product/ERP5/tests/testERP5Credential.py
View file @
1a19ea70
...
...
@@ -555,6 +555,31 @@ class TestERP5Credential(ERP5TypeTestCase):
assignment
.
open
()
sequence
.
edit
(
person_reference
=
person
.
getReference
())
def
stepCreateSameEmailPersonList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
Create a list of person with same email
"""
default_email_text
=
"bart@duff.com"
person_list
=
[]
for
reference
in
[
'userX'
,
'bart'
,
'homer'
]:
portal
=
self
.
getPortalObject
()
# create a person with 'secret' as password
self
.
login
()
person_module
=
portal
.
getDefaultModule
(
'Person'
)
person
=
person_module
.
newContent
(
title
=
reference
,
reference
=
reference
,
password
=
'secret'
,
default_email_text
=
default_email_text
)
# create an assignment
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
function
=
'member'
)
assignment
.
open
()
person_list
.
append
(
person
)
sequence
.
edit
(
person_list
=
person_list
,
default_email_text
=
default_email_text
)
def
stepCreateCredentialRecovery
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
'''
...
...
@@ -582,6 +607,29 @@ class TestERP5Credential(ERP5TypeTestCase):
credential_recovery
.
setReference
(
person
.
getReference
())
sequence
.
edit
(
credential_recovery
=
credential_recovery
)
def
stepCreateCredentialRecoveryForUsername
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
'''
Create a credential recovery for username case
'''
portal
=
self
.
getPortalObject
()
default_email_text
=
sequence
.
get
(
"default_email_text"
)
query_kw
=
{
"email.url_string"
:
default_email_text
}
result
=
portal
.
portal_catalog
(
portal_type
=
"Email"
,
parent_portal_type
=
"Person"
,
**
query_kw
)
person_list
=
[
x
.
getObject
().
getParentValue
()
for
x
in
result
]
self
.
assertEqual
(
len
(
person_list
),
3
)
sequence
.
edit
(
person_list
=
person_list
)
# create a credential recovery
credential_recovery_module
=
portal
.
getDefaultModule
(
'Credential Recovery'
)
credential_recovery
=
credential_recovery_module
.
newContent
(
portal_type
=
\
'Credential Recovery'
)
# associate it with barney
credential_recovery
.
setDestinationDecisionValueList
(
person_list
)
credential_recovery
.
setDefaultEmailText
(
default_email_text
)
sequence
.
edit
(
credential_recovery
=
credential_recovery
)
def
stepRequestCredentialRecoveryWithERP5Site_newCredentialRecovery
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
person_reference
=
sequence
[
"person_reference"
]
...
...
@@ -668,6 +716,28 @@ class TestERP5Credential(ERP5TypeTestCase):
send_to
=
decoded_message
[
'headers'
][
'to'
]
self
.
assertEqual
(
barney
.
getDefaultEmailText
(),
send_to
)
def
stepCheckEmailIsSentForUsername
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
'''
Check an email containing the usernames list as been sent
'''
person_list
=
sequence
.
get
(
'person_list'
)
email
=
sequence
.
get
(
'default_email_text'
)
# after accept, an email is send containing the reset link
last_message
=
self
.
portal
.
MailHost
.
_last_message
decoded_message
=
self
.
decode_email
(
last_message
[
2
])
body_message
=
decoded_message
[
'body'
]
for
person
in
person_list
:
match_obj
=
None
reference
=
person
.
getReference
()
match_obj
=
re
.
search
(
reference
,
body_message
)
# check the reset password link is in the mail
self
.
assertNotEquals
(
match_obj
,
None
)
# check the mail is sent to the requester :
send_to
=
decoded_message
[
'headers'
][
'to'
]
self
.
assertEqual
(
email
,
send_to
)
def
stepCheckPasswordChange
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
check it's possible to change the user password using the link in the
...
...
@@ -814,10 +884,10 @@ class TestERP5Credential(ERP5TypeTestCase):
sequence_list
.
play
(
self
)
def
test_03_simpleCredentialUpdate
(
self
):
'''
"""
Check it's possible to update credential informations using credential
update
'''
"""
sequence_list
=
SequenceList
()
sequence_string
=
'SetCredentialAssignmentPropertyList '
\
'CreateSimpleSubscriptionRequest '
\
...
...
@@ -916,6 +986,21 @@ class TestERP5Credential(ERP5TypeTestCase):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_09_usernameRecovery
(
self
):
'''
check that a user that forget his username(s) is able to
get an email containing them
'''
sequence_list
=
SequenceList
()
sequence_string
=
'CreateSameEmailPersonList Tic '
\
'CreateCredentialRecoveryForUsername Tic '
\
'SubmitCredentialRecovery Tic '
\
'AcceptCredentialRecovery Tic '
\
'CheckEmailIsSentForUsername'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
testMailMessagePosted
(
self
):
""" Test if the Mail Message was posted correctly """
sequence_list
=
SequenceList
()
...
...
@@ -950,8 +1035,10 @@ class TestERP5Credential(ERP5TypeTestCase):
self
.
assertEquals
([
'Vifib Test <barney@duff.com>'
],
mto
)
self
.
assertNotEquals
(
re
.
search
(
"Subject
\
:.*Welcome
"
, message_text), None)
self.assertNotEquals(re.search("
Hello
\
Vifib
\
Test
\
,
", message_text), None)
self.assertNotEquals(re.search("
key
\
=
..
%
s
" % mail_message.getReference(),
message_text), None)
decoded_message = self.decode_email(last_message[2])
body_message = decoded_message['body']
self.assertNotEquals(re.search("
key
=%
s
" % mail_message.getReference(),
body_message), None)
def testAssignmentCreationUsingSystemPreferenceProperty(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