Commit d80c0cc4 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

test: use different reference between Person and ERP5 Login in testERP5Credential.

parent 560ccc5d
...@@ -322,7 +322,6 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -322,7 +322,6 @@ class TestERP5Credential(ERP5TypeTestCase):
from Products.PluggableAuthService.interfaces.plugins import\ from Products.PluggableAuthService.interfaces.plugins import\
IAuthenticationPlugin IAuthenticationPlugin
uf = self.getUserFolder() uf = self.getUserFolder()
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(
...@@ -558,11 +557,12 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -558,11 +557,12 @@ class TestERP5Credential(ERP5TypeTestCase):
# create a login # create a login
login = person.newContent( login = person.newContent(
portal_type='ERP5 Login', portal_type='ERP5 Login',
reference=person.getReference(), reference=person.getReference() + '-login',
password='secret', password='secret',
) )
login.validate() login.validate()
sequence.edit(person_reference=person.getReference(), sequence.edit(person_reference=person.getReference(),
login_reference=login.getReference(),
default_email_text=person.getDefaultEmailText()) default_email_text=person.getDefaultEmailText())
def stepCreateSameEmailPersonList(self, sequence=None, sequence_list=None, def stepCreateSameEmailPersonList(self, sequence=None, sequence_list=None,
...@@ -587,7 +587,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -587,7 +587,7 @@ class TestERP5Credential(ERP5TypeTestCase):
# create a login # create a login
login = person.newContent( login = person.newContent(
portal_type='ERP5 Login', portal_type='ERP5 Login',
reference=person.getReference(), reference=person.getReference() + '-login',
password='secret', password='secret',
) )
login.validate() login.validate()
...@@ -603,11 +603,12 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -603,11 +603,12 @@ class TestERP5Credential(ERP5TypeTestCase):
''' '''
portal = self.getPortalObject() portal = self.getPortalObject()
person_reference = sequence["person_reference"] person_reference = sequence["person_reference"]
login_reference = sequence["login_reference"]
person = portal.portal_catalog.getResultValue(portal_type="Person", person = portal.portal_catalog.getResultValue(portal_type="Person",
reference=person_reference) reference=person_reference)
sequence.edit(barney=person) sequence.edit(barney=person)
# check barney can log in the system # check barney can log in the system
self._assertUserExists('barney', 'secret') self._assertUserExists('barney-login', 'secret')
self.login('barney') self.login('barney')
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
self.assertEqual(str(getSecurityManager().getUser()), 'barney') self.assertEqual(str(getSecurityManager().getUser()), 'barney')
...@@ -620,7 +621,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -620,7 +621,7 @@ class TestERP5Credential(ERP5TypeTestCase):
# associate it with barney # associate it with barney
credential_recovery.setDestinationDecisionValue(person) credential_recovery.setDestinationDecisionValue(person)
credential_recovery.setReference(person.getReference()) credential_recovery.setReference(login_reference)
sequence.edit(credential_recovery=credential_recovery) sequence.edit(credential_recovery=credential_recovery)
def stepCreateCredentialRecoveryForUsername(self, sequence=None, sequence_list=None, def stepCreateCredentialRecoveryForUsername(self, sequence=None, sequence_list=None,
...@@ -648,8 +649,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -648,8 +649,8 @@ class TestERP5Credential(ERP5TypeTestCase):
def stepRequestCredentialRecoveryWithERP5Site_newCredentialRecovery(self, def stepRequestCredentialRecoveryWithERP5Site_newCredentialRecovery(self,
sequence=None, sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
person_reference = sequence["person_reference"] login_reference = sequence["login_reference"]
self.portal.ERP5Site_newCredentialRecovery(reference=person_reference) self.portal.ERP5Site_newCredentialRecovery(reference=login_reference)
def stepRequestCredentialRecoveryWithERP5Site_newCredentialRecoveryByEmail( def stepRequestCredentialRecoveryWithERP5Site_newCredentialRecoveryByEmail(
self, sequence=None, sequence_list=None, **kw): self, sequence=None, sequence_list=None, **kw):
...@@ -669,9 +670,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -669,9 +670,9 @@ class TestERP5Credential(ERP5TypeTestCase):
def stepCreateCredentialRecoveryWithSensitiveAnswer(self, sequence=None, def stepCreateCredentialRecoveryWithSensitiveAnswer(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
person_reference = sequence["person_reference"] login_reference = sequence["login_reference"]
result = self.portal.ERP5Site_newCredentialRecovery( result = self.portal.ERP5Site_newCredentialRecovery(
reference=person_reference, reference=login_reference,
default_credential_question_question='credential/library_card_number', default_credential_question_question='credential/library_card_number',
default_credential_question_answer='ABCDeF', default_credential_question_answer='ABCDeF',
) )
...@@ -680,7 +681,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -680,7 +681,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.tic() self.tic()
self.login() self.login()
result_list = self.portal.portal_catalog( result_list = self.portal.portal_catalog(
portal_type='Credential Recovery', reference=person_reference) portal_type='Credential Recovery', reference=login_reference)
self.assertEqual(1, len(result_list)) self.assertEqual(1, len(result_list))
credential_recovery = result_list[0] credential_recovery = result_list[0]
sequence.edit(credential_recovery=credential_recovery) sequence.edit(credential_recovery=credential_recovery)
...@@ -694,9 +695,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -694,9 +695,9 @@ class TestERP5Credential(ERP5TypeTestCase):
def stepCheckCredentialRecoveryCreation(self, sequence=None, def stepCheckCredentialRecoveryCreation(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
person_reference = sequence["person_reference"] login_reference = sequence["login_reference"]
result_list = self.portal.portal_catalog( result_list = self.portal.portal_catalog(
portal_type='Credential Recovery', reference=person_reference) portal_type='Credential Recovery', reference=login_reference)
self.assertEqual(1, len(result_list)) self.assertEqual(1, len(result_list))
credential_recovery = result_list[0] credential_recovery = result_list[0]
person = credential_recovery.getDestinationDecisionValue() person = credential_recovery.getDestinationDecisionValue()
...@@ -788,8 +789,8 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -788,8 +789,8 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertTrue('reset_key' in parameters) self.assertTrue('reset_key' in parameters)
key = parameters['reset_key'][0] key = parameters['reset_key'][0]
# before changing, check that the user exists with 'secret' password # before changing, check that the user exists with 'secret' password
self._assertUserExists('barney', 'secret') self._assertUserExists('barney-login', 'secret')
self.portal.portal_password.changeUserPassword(user_login="barney", self.portal.portal_password.changeUserPassword(user_login="barney-login",
password="new_password", password="new_password",
password_confirm="new_password", password_confirm="new_password",
password_key=key) password_key=key)
...@@ -797,10 +798,10 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -797,10 +798,10 @@ class TestERP5Credential(ERP5TypeTestCase):
# reset the cache # reset the cache
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
# check we cannot login anymore with the previous password 'secret' # check we cannot login anymore with the previous password 'secret'
self._assertUserDoesNotExists('barney', 'secret') self._assertUserDoesNotExists('barney-login', 'secret')
# check we can now login with the new password 'new_password' # check we can now login with the new password 'new_password'
self._assertUserExists('barney', 'new_password') self._assertUserExists('barney-login', 'new_password')
def _createCredentialRequest(self, first_name="Barney", def _createCredentialRequest(self, first_name="Barney",
last_name="Simpson", last_name="Simpson",
...@@ -1247,10 +1248,16 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1247,10 +1248,16 @@ class TestERP5Credential(ERP5TypeTestCase):
reference = self.id() reference = self.id()
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
reference=reference, reference=reference,
password='secret',
role='internal') role='internal')
assignment = person.newContent(portal_type='Assignment', function='manager') assignment = person.newContent(portal_type='Assignment', function='manager')
assignment.open() assignment.open()
# create a login
login = person.newContent(
portal_type='ERP5 Login',
reference=person.getReference() + '-login',
password='secret',
)
login.validate()
self.commit() self.commit()
credential_update = self.portal.credential_update_module.newContent( credential_update = self.portal.credential_update_module.newContent(
portal_type='Credential Update', portal_type='Credential Update',
...@@ -1268,13 +1275,20 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1268,13 +1275,20 @@ class TestERP5Credential(ERP5TypeTestCase):
person_module = self.portal.getDefaultModule('Person') person_module = self.portal.getDefaultModule('Person')
person = person_module.newContent(title='Barney', person = person_module.newContent(title='Barney',
reference='barney', reference='barney',
password='secret',
default_email_text='barney@duff.com') default_email_text='barney@duff.com')
# create an assignment # create an assignment
assignment = person.newContent(portal_type='Assignment', assignment = person.newContent(portal_type='Assignment',
function='member') function='member')
assignment.open() assignment.open()
sequence.edit(person_reference=person.getReference()) # create a login
login = person.newContent(
portal_type='ERP5 Login',
reference=person.getReference() + '-login',
password='secret',
)
login.validate()
sequence.edit(person_reference=person.getReference(),
login_reference=login.getReference())
def test_checkCredentialQuestionIsNotCaseSensitive(self): def test_checkCredentialQuestionIsNotCaseSensitive(self):
''' '''
......
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