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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
5dc3a8b0
Commit
5dc3a8b0
authored
Sep 02, 2020
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZODB Components: erp5_credential: Migrate Unit Test.
parent
1f661fa1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
20 deletions
+139
-20
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.py
...p5_credential/CredentialRequest_checkLoginAvailability.py
+2
-0
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.py
...ateItem/portal_components/test.erp5.testERP5Credential.py
+18
-18
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.xml
...teItem/portal_components/test.erp5.testERP5Credential.xml
+110
-0
bt5/erp5_credential/bt/template_document_id_list
bt5/erp5_credential/bt/template_document_id_list
+2
-2
bt5/erp5_credential/bt/template_test_id_list
bt5/erp5_credential/bt/template_test_id_list
+1
-0
bt5/erp5_credential/bt/test_dependency_list
bt5/erp5_credential/bt/test_dependency_list
+6
-0
No files found.
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.py
View file @
5dc3a8b0
...
...
@@ -7,6 +7,8 @@ portal = context.getPortalObject()
if
value
:
# Same tag is used as in ERP5 Login _setReference, in order to protect against
# concurrency between Credential Request and ERP5 Login object too
#
# XXX: value.encode('hex') may exceed 'tag' column length (255)...
if
context
.
getPortalObject
().
portal_activities
.
countMessageWithTag
(
'set_login_'
+
value
.
encode
(
'hex'
)):
return
False
...
...
product/ERP5/tests/
testERP5Credential.py
→
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.
testERP5Credential.py
View file @
5dc3a8b0
...
...
@@ -165,7 +165,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self
.
_enablePreference
()
# Copied from bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
def
decode_email
(
self
,
file
):
def
decode_email
(
self
,
file
_
):
# Prepare result
theMail
=
{
'attachment_list'
:
[],
...
...
@@ -174,9 +174,9 @@ class TestERP5Credential(ERP5TypeTestCase):
'headers'
:
{}
}
# Get Message
msg
=
email
.
message_from_string
(
file
)
msg
=
email
.
message_from_string
(
file
_
)
# Back up original file
theMail
[
'__original__'
]
=
file
theMail
[
'__original__'
]
=
file
_
# Recode headers to UTF-8 if needed
for
key
,
value
in
msg
.
items
():
decoded_value_list
=
decode_header
(
value
)
...
...
@@ -252,7 +252,9 @@ class TestERP5Credential(ERP5TypeTestCase):
self
.
tic
()
self
.
logout
()
def
stepSetCredentialAssignmentPropertyList
(
self
,
sequence
=
{}):
def
stepSetCredentialAssignmentPropertyList
(
self
,
sequence
=
None
):
if
sequence
is
None
:
sequence
=
{}
category_list
=
sequence
.
get
(
"category_list"
,
[
"role/internal"
,
"function/member"
])
self
.
login
()
...
...
@@ -321,8 +323,7 @@ class TestERP5Credential(ERP5TypeTestCase):
from
Products.PluggableAuthService.interfaces.plugins
import
\
IAuthenticationPlugin
uf
=
self
.
getUserFolder
()
for
plugin_name
,
plugin
in
uf
.
_getOb
(
'plugins'
).
listPlugins
(
IAuthenticationPlugin
):
for
_
,
plugin
in
uf
.
_getOb
(
'plugins'
).
listPlugins
(
IAuthenticationPlugin
):
if
plugin
.
authenticateCredentials
(
{
'login'
:
login
,
'password'
:
password
})
is
not
None
:
break
...
...
@@ -450,7 +451,6 @@ class TestERP5Credential(ERP5TypeTestCase):
self
.
_assertUserDoesNotExists
(
'homie'
,
'secret'
)
# check that informations on the person object have been updated
person_module
=
self
.
portal
.
getDefaultModule
(
'Person'
)
related_login_result
=
self
.
portal
.
portal_catalog
(
portal_type
=
'ERP5 Login'
,
reference
=
'homie'
)
self
.
assertEqual
(
len
(
related_login_result
),
1
)
related_person
=
related_login_result
[
0
].
getParentValue
()
...
...
@@ -742,7 +742,7 @@ class TestERP5Credential(ERP5TypeTestCase):
Check an email containing the usernames list as been sent
'''
person_list
=
sequence
.
get
(
'person_list'
)
email
=
sequence
.
get
(
'default_email_text'
)
email
_text
=
sequence
.
get
(
'default_email_text'
)
# after accept, only one email is send containing the reset link
previous_message
=
self
.
portal
.
MailHost
.
_previous_message
last_message
=
self
.
portal
.
MailHost
.
_last_message
...
...
@@ -760,7 +760,7 @@ class TestERP5Credential(ERP5TypeTestCase):
# check the mail is sent to the requester :
send_to
=
decoded_message
[
'headers'
][
'to'
]
self
.
assertEqual
(
email
,
send_to
)
self
.
assertEqual
(
email
_text
,
send_to
)
def
stepCheckPasswordChange
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
...
...
@@ -782,7 +782,7 @@ class TestERP5Credential(ERP5TypeTestCase):
url
=
line
[
line
.
find
(
'http:'
):]
url
=
url
.
strip
()
self
.
assertNotEquals
(
url
,
None
)
response
=
self
.
publish
(
url
)
self
.
publish
(
url
)
parameters
=
cgi
.
parse_qs
(
urlparse
.
urlparse
(
url
)[
4
])
self
.
assertTrue
(
'reset_key'
in
parameters
)
key
=
parameters
[
'reset_key'
][
0
]
...
...
@@ -1070,8 +1070,8 @@ class TestERP5Credential(ERP5TypeTestCase):
mfrom
,
mto
,
message_text
=
last_message
self
.
assertEqual
(
mfrom
,
'Portal Administrator <postmaster@localhost>'
)
self
.
assertEqual
([
'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
(
r
"Subject\
:.*Welcome
", message_text), None)
self.assertNotEquals(re.search(
r
"
Hello
\
Vifib
\
Test
\
,
", 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(),
...
...
@@ -1178,7 +1178,7 @@ class TestERP5Credential(ERP5TypeTestCase):
sequence = dict(automatic_call=True)
self.stepSetCredentialRequestAutomaticApprovalPreferences(sequence)
self.stepSetCredentialAssignmentPropertyList()
reference = self.
id()
reference = self.
_testMethodName
self.logout()
response = self.portal.ERP5Site_newCredentialRequest(reference=reference,
default_email_text='some@one.com',)
...
...
@@ -1238,7 +1238,7 @@ class TestERP5Credential(ERP5TypeTestCase):
def test_no_reset_assignment_ERP5Site_newCredentialUpdate(self):
"""Checks that assignments are left intact after credential update"""
reference = self.
id()
reference = self.
_testMethodName
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference,
role='internal')
...
...
@@ -1300,7 +1300,7 @@ class TestERP5Credential(ERP5TypeTestCase):
sequence_list.play(self)
def _prepareContractAndPreference(self):
self.contract_reference = self.
id()
self.contract_reference = self.
_testMethodName
self.contract_content = 'My contract %s.' % self.contract_reference
preference = self._getPreference()
preference.edit(
...
...
@@ -1389,13 +1389,13 @@ class TestERP5Credential(ERP5TypeTestCase):
assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference=self.
id()
,
reference=self.
_testMethodName
,
password='secret',
)
login.validate()
self.tic()
ret = self.portal.ERP5Site_newCredentialRecovery(reference=self.
id()
)
ret = self.portal.ERP5Site_newCredentialRecovery(reference=self.
_testMethodName
)
self.assertEqual(
urlparse.parse_qs(urlparse.urlparse(ret).query)['portal_status_message'],
['We have sent you an email to enable you to reset your password. Please check your inbox and your junk/spam mail for this email and follow the link to reset your password.'],
...
...
bt5/erp5_credential/TestTemplateItem/portal_components/test.erp5.testERP5Credential.xml
0 → 100644
View file @
5dc3a8b0
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testERP5Credential
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<string>
Products.ERP5.tests.testERP5Credential
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testERP5Credential
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_credential/bt/template_document_id_list
View file @
5dc3a8b0
document.erp5.CredentialRequest
document.erp5.CredentialRecovery
document.erp5.CredentialRequest
\ No newline at end of file
bt5/erp5_credential/bt/template_test_id_list
0 → 100644
View file @
5dc3a8b0
test.erp5.testERP5Credential
\ No newline at end of file
bt5/erp5_credential/bt/test_dependency_list
0 → 100644
View file @
5dc3a8b0
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_jquery
erp5_ingestion_mysql_innodb_catalog
erp5_ingestion
erp5_administration
\ 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