Commit b346c6b5 authored by Yusei Tahara's avatar Yusei Tahara

Merge branch 'master' of https://git.erp5.org/repos/erp5

parents 705330b5 c82ae4ad
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import unittest import unittest
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...@@ -46,6 +47,7 @@ if use_verbose_security: ...@@ -46,6 +47,7 @@ if use_verbose_security:
authenticated=True, authenticated=True,
verbose=True) verbose=True)
class TestERP5Credential(ERP5TypeTestCase): class TestERP5Credential(ERP5TypeTestCase):
def getTitle(self): def getTitle(self):
...@@ -92,7 +94,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -92,7 +94,7 @@ class TestERP5Credential(ERP5TypeTestCase):
def createCategories(self): def createCategories(self):
"""Create the categories for our test. """ """Create the categories for our test. """
# create categories # create categories
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList():
base_cat = cat_string.split("/")[0] base_cat = cat_string.split("/")[0]
# if base_cat not exist, create it # if base_cat not exist, create it
if getattr(self.getPortal().portal_categories, base_cat, None) == None: if getattr(self.getPortal().portal_categories, base_cat, None) == None:
...@@ -100,8 +102,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -100,8 +102,8 @@ class TestERP5Credential(ERP5TypeTestCase):
portal_type='Base Category', portal_type='Base Category',
id=base_cat) id=base_cat)
base_cat_value = self.getPortal().portal_categories[base_cat] base_cat_value = self.getPortal().portal_categories[base_cat]
for cat in cat_string.split("/")[1:] : for cat in cat_string.split("/")[1:]:
if not cat in base_cat_value.objectIds() : if not cat in base_cat_value.objectIds():
base_cat_value = base_cat_value.newContent( base_cat_value = base_cat_value.newContent(
portal_type='Category', portal_type='Category',
id=cat, id=cat,
...@@ -109,7 +111,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -109,7 +111,7 @@ class TestERP5Credential(ERP5TypeTestCase):
else: else:
base_cat_value = base_cat_value[cat] base_cat_value = base_cat_value[cat]
# check categories have been created # check categories have been created
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList():
self.assertNotEquals(None, self.assertNotEquals(None,
self.getCategoryTool().restrictedTraverse(cat_string), self.getCategoryTool().restrictedTraverse(cat_string),
cat_string) cat_string)
...@@ -255,8 +257,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -255,8 +257,8 @@ class TestERP5Credential(ERP5TypeTestCase):
self.stepTic() self.stepTic()
self.logout() self.logout()
def stepSetOrganisationCredentialUpdateAutomaticApprovalPreferences(self, sequence=None, def stepSetOrganisationCredentialUpdateAutomaticApprovalPreferences(self,
sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
self.login() self.login()
preference = self._getPreference() preference = self._getPreference()
preference.edit(preferred_organisation_credential_update_automatic_approval=True) preference.edit(preferred_organisation_credential_update_automatic_approval=True)
...@@ -290,8 +292,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -290,8 +292,8 @@ class TestERP5Credential(ERP5TypeTestCase):
reference = sequence["reference"] reference = sequence["reference"]
assignment_function = sequence["assignment_function"] assignment_function = sequence["assignment_function"]
assignment_role = sequence["assignment_role"] assignment_role = sequence["assignment_role"]
credential_request = portal_catalog.getResultValue(portal_type="Credential Request", credential_request = portal_catalog.getResultValue(
reference=reference) portal_type="Credential Request", reference=reference)
mail_message = portal_catalog.getResultValue(portal_type="Mail Message", mail_message = portal_catalog.getResultValue(portal_type="Mail Message",
follow_up=credential_request) follow_up=credential_request)
self.stepTic() self.stepTic()
...@@ -320,9 +322,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -320,9 +322,9 @@ class TestERP5Credential(ERP5TypeTestCase):
uf = self.getUserFolder() uf = self.getUserFolder()
self.assertNotEquals(uf.getUserById(login, None), None) self.assertNotEquals(uf.getUserById(login, None), None)
for plugin_name, plugin in uf._getOb('plugins').listPlugins( for plugin_name, 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
else: else:
self.fail("No plugin could authenticate '%s' with password '%s'" % self.fail("No plugin could authenticate '%s' with password '%s'" %
...@@ -336,9 +338,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -336,9 +338,9 @@ class TestERP5Credential(ERP5TypeTestCase):
IAuthenticationPlugin IAuthenticationPlugin
uf = self.getUserFolder() uf = self.getUserFolder()
for plugin_name, plugin in uf._getOb('plugins').listPlugins( for plugin_name, 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:
self.fail( self.fail(
"Plugin %s should not have authenticated '%s' with password '%s'" % "Plugin %s should not have authenticated '%s' with password '%s'" %
(plugin_name, login, password)) (plugin_name, login, password))
...@@ -716,7 +718,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -716,7 +718,7 @@ class TestERP5Credential(ERP5TypeTestCase):
credential_reference = "credential_reference" credential_reference = "credential_reference"
self._createCredentialRequest(reference=credential_reference) self._createCredentialRequest(reference=credential_reference)
sequence.edit(credential_reference=credential_reference) sequence.edit(credential_reference=credential_reference)
def stepCheckIfMailMessageWasPosted(self, sequence=None, def stepCheckIfMailMessageWasPosted(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
credential_reference_str = sequence["credential_reference"] credential_reference_str = sequence["credential_reference"]
...@@ -726,7 +728,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -726,7 +728,7 @@ class TestERP5Credential(ERP5TypeTestCase):
mail_message = portal_catalog.getResultValue(portal_type="Mail Message", mail_message = portal_catalog.getResultValue(portal_type="Mail Message",
follow_up=credential_reference) follow_up=credential_reference)
self.assertEquals(mail_message.getSimulationState(), "started") self.assertEquals(mail_message.getSimulationState(), "started")
self.assertTrue( "key=%s" % mail_message.getReference() in mail_message.getTextContent()) self.assertTrue("key=%s" % mail_message.getReference() in mail_message.getTextContent())
def stepSetPreferredCredentialAlarmAutomaticCallAsFalse(self, sequence): def stepSetPreferredCredentialAlarmAutomaticCallAsFalse(self, sequence):
sequence.edit(automatic_call=False) sequence.edit(automatic_call=False)
...@@ -1010,6 +1012,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1010,6 +1012,7 @@ class TestERP5Credential(ERP5TypeTestCase):
enought to reset his passord enought to reset his passord
''' '''
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Credential)) suite.addTest(unittest.makeSuite(TestERP5Credential))
......
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