Commit d1f189fc authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_credential: Migrate Unit Test.

parent 07dedbdd
...@@ -165,7 +165,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -165,7 +165,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self._enablePreference() self._enablePreference()
# Copied from bt5/erp5_egov/TestTemplateItem/testEGovMixin.py # Copied from bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
def decode_email(self, file): def decode_email(self, file_):
# Prepare result # Prepare result
theMail = { theMail = {
'attachment_list': [], 'attachment_list': [],
...@@ -174,9 +174,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -174,9 +174,9 @@ class TestERP5Credential(ERP5TypeTestCase):
'headers': {} 'headers': {}
} }
# Get Message # Get Message
msg = email.message_from_string(file) msg = email.message_from_string(file_)
# Back up original file # Back up original file
theMail['__original__'] = file theMail['__original__'] = file_
# Recode headers to UTF-8 if needed # Recode headers to UTF-8 if needed
for key, value in msg.items(): for key, value in msg.items():
decoded_value_list = decode_header(value) decoded_value_list = decode_header(value)
...@@ -188,7 +188,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -188,7 +188,7 @@ class TestERP5Credential(ERP5TypeTestCase):
'to', 'from', 'cc', 'sender', 'reply-to'): 'to', 'from', 'cc', 'sender', 'reply-to'):
header_field = theMail['headers'].get(header) header_field = theMail['headers'].get(header)
if header_field: if header_field:
theMail['headers'][header] = parseaddr(header_field)[1] theMail['headers'][header] = parseaddr(header_field)[1]
# Get attachments # Get attachments
body_found = 0 body_found = 0
for part in msg.walk(): for part in msg.walk():
...@@ -252,7 +252,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -252,7 +252,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.tic() self.tic()
self.logout() self.logout()
def stepSetCredentialAssignmentPropertyList(self, sequence={}): def stepSetCredentialAssignmentPropertyList(self, sequence=None):
category_list = sequence.get("category_list", category_list = sequence.get("category_list",
["role/internal", "function/member"]) ["role/internal", "function/member"])
self.login() self.login()
...@@ -321,8 +321,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -321,8 +321,7 @@ class TestERP5Credential(ERP5TypeTestCase):
from Products.PluggableAuthService.interfaces.plugins import\ from Products.PluggableAuthService.interfaces.plugins import\
IAuthenticationPlugin IAuthenticationPlugin
uf = self.getUserFolder() uf = self.getUserFolder()
for plugin_name, plugin in uf._getOb('plugins').listPlugins( for _, plugin in uf._getOb('plugins').listPlugins(IAuthenticationPlugin):
IAuthenticationPlugin):
if plugin.authenticateCredentials( if plugin.authenticateCredentials(
{'login': login, 'password': password}) is not None: {'login': login, 'password': password}) is not None:
break break
...@@ -450,7 +449,6 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -450,7 +449,6 @@ class TestERP5Credential(ERP5TypeTestCase):
self._assertUserDoesNotExists('homie', 'secret') self._assertUserDoesNotExists('homie', 'secret')
# check that informations on the person object have been updated # 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') related_login_result = self.portal.portal_catalog(portal_type='ERP5 Login', reference='homie')
self.assertEqual(len(related_login_result), 1) self.assertEqual(len(related_login_result), 1)
related_person = related_login_result[0].getParentValue() related_person = related_login_result[0].getParentValue()
...@@ -742,7 +740,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -742,7 +740,7 @@ class TestERP5Credential(ERP5TypeTestCase):
Check an email containing the usernames list as been sent Check an email containing the usernames list as been sent
''' '''
person_list = sequence.get('person_list') 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 # after accept, only one email is send containing the reset link
previous_message = self.portal.MailHost._previous_message previous_message = self.portal.MailHost._previous_message
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
...@@ -760,7 +758,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -760,7 +758,7 @@ class TestERP5Credential(ERP5TypeTestCase):
# check the mail is sent to the requester : # check the mail is sent to the requester :
send_to = decoded_message['headers']['to'] 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): def stepCheckPasswordChange(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -782,7 +780,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -782,7 +780,7 @@ class TestERP5Credential(ERP5TypeTestCase):
url = line[line.find('http:'):] url = line[line.find('http:'):]
url = url.strip() url = url.strip()
self.assertNotEquals(url, None) self.assertNotEquals(url, None)
response = self.publish(url) self.publish(url)
parameters = cgi.parse_qs(urlparse.urlparse(url)[4]) parameters = cgi.parse_qs(urlparse.urlparse(url)[4])
self.assertTrue('reset_key' in parameters) self.assertTrue('reset_key' in parameters)
key = parameters['reset_key'][0] key = parameters['reset_key'][0]
...@@ -1070,8 +1068,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1070,8 +1068,8 @@ class TestERP5Credential(ERP5TypeTestCase):
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual(mfrom, 'Portal Administrator <postmaster@localhost>') self.assertEqual(mfrom, 'Portal Administrator <postmaster@localhost>')
self.assertEqual(['Vifib Test <barney@duff.com>'], mto) self.assertEqual(['Vifib Test <barney@duff.com>'], mto)
self.assertNotEquals(re.search("Subject\:.*Welcome", message_text), None) self.assertNotEquals(re.search(r"Subject\:.*Welcome", message_text), None)
self.assertNotEquals(re.search("Hello\ Vifib\ Test\,", message_text), None) self.assertNotEquals(re.search(r"Hello\ Vifib\ Test\,", message_text), None)
decoded_message = self.decode_email(last_message[2]) decoded_message = self.decode_email(last_message[2])
body_message = decoded_message['body'] body_message = decoded_message['body']
self.assertNotEquals(re.search("key=%s" % mail_message.getReference(), self.assertNotEquals(re.search("key=%s" % mail_message.getReference(),
......
<?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>
document.erp5.CredentialRequest document.erp5.CredentialRecovery
document.erp5.CredentialRecovery document.erp5.CredentialRequest
\ No newline at end of file \ No newline at end of file
test.erp5.testERP5Credential
\ No newline at end of file
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment