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
137
Merge Requests
137
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
5dc3a8b0
Commit
5dc3a8b0
authored
4 years ago
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZODB Components: erp5_credential: Migrate Unit Test.
parent
1f661fa1
master
DateTime.equalTo_fix
TMP-2to3
UpdateValidationStateFromConsistency
UserPropertySheet_backward_compatibility
addToDate_implicit_localtime
add_boolean_type
arnau
arnau-RD-ERP5ify-portal_workflow-1-seb-merged-with-recent-master
arnau-RD-ERP5ify-portal_workflow-2-do-not-rename-erp5_workflow-portal_types
arnau-RD-ERP5ify-portal_workflow-BAK
arnau-RD-ERP5ify-portal_workflow-WIP
arnau-RD-ERP5ify-portal_workflow-WITHOUT-MIGRATION
arnau-RD-ERP5ify-portal_workflow-WORKFLOWS-NOT-MIGRATED
arnau-RD-py3-master-TM
arnau-RD-py3-master-TM-BAK
arnau-RD-py3-master-WIP
arnau-RD-py3-master-WIP-BAK
arnau-RD-py3-master-WIP-bt5-and-tests
arnau-RD-zope4py3
arnau-my2to3
arnau-zope4py2
aurel-zope4py2
cache-control-304-response
drop-ZServer
e2e-erp5
erp5-component
erp5-component-bak
erp5-vifib
erp5-vifib-no-Products.DCWorkflowGraph
erp5-vifib-py3
erp5_drone_simulator
feat/coding_style_test
feat/dedup_roles_in_pickles
feat/erp5pt
feat/fsum
feat/improve_rounding_tool
feat/lxml-html-snapshot
feat/mariadb-10.11
feat/mariadb-10.11bis
feat/mariadb-10.11ter
feat/mariadb-10.5
feat/mariadb-10.6
feat/mariadb-11.4bis
feat/mariadb-11.4bis-old
feat/mariadb-11.4ter
feat/notification-message-ignore-missing
feat/python_language_support
feat/reindexlastobjects_log
feat/round_half_up
feat/selenium-unexpected-success
feat/slapos_agent_distributor
feat/subject_set_query
fix/GHSA-g5vw-3h65-2q3v
fix/TALES_hide_error
fix/accounting-fec-no-line
fix/erp5_site_global_id
fix/is_ghost_temp_object
fix/mariadb-1927
fix/measure-optional-variation
fix/monaco-altClick
fix/officejs_support_request_rss_secu
fix/state_var
fix/testnode_proctitle
fix/workflow_info
fix/workflow_method_security
fix_isIndexable
fix_web_illustration
for_testrunner_1
for_testrunner_2
for_testrunner_3
graphic_gadget_js
limit_accelerated_http_cache_manager
lle-bout/metadata-modules
mr1362
notebook_roque
oauth-login-minor-improvement
override_cache_control_header_by_caching_policy_manager
poc/json-forms-study
restore-from-trashbin
revert-192c2000
rfc/activate_default
rjs_listbox_sort_icon
roque_quick
scalability_crash_mariadb
support_legacy_sftp_server
support_relative_url_in_hyperlink_field
test-renderjs-float-field-step
test_cmfactivity_isolation_level
test_dynamic_methods
tomo_testnode_slap_request
translatable_path_master
unify_predicate_edit
without_legacy_workflow
workaround_mroonga_14
zope2
zope2zope4py2
zope4py3
zope4py3-BEFORE-CLEANUP
zope4py3-master-rebase
erp5.util-0.4.77
erp5.util-0.4.76
erp5.util-0.4.75
erp5.util-0.4.74
erp5.util-0.4.73
erp5.util-0.4.72
erp5.util-0.4.71
erp5.util-0.4.69
erp5-vifib-20240326
erp5-vifib-20230331
erp5-vifib-20230201
erp5-vifib-20220526
erp5-vifib-20220302
erp5-vifib-20210707
erp5-vifib-20201229
erp5-vifib-20200129
No related merge requests found
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
...
...
This diff is collapsed.
Click to expand it.
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.'],
...
...
This diff is collapsed.
Click to expand it.
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>
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
bt5/erp5_credential/bt/template_test_id_list
0 → 100644
View file @
5dc3a8b0
test.erp5.testERP5Credential
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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