Commit 82235674 authored by Vincent Pelletier's avatar Vincent Pelletier

test: migrate to ERP5 Login authentication.

parent e3f117a8
...@@ -12,7 +12,6 @@ if person is None: ...@@ -12,7 +12,6 @@ if person is None:
title=functional_test_username) title=functional_test_username)
person.edit(reference=functional_test_username, person.edit(reference=functional_test_username,
password=howto_dict['functional_test_user_password'],
default_email_text=howto_dict['functional_test_user_email']) default_email_text=howto_dict['functional_test_user_email'])
person.validate() person.validate()
...@@ -23,6 +22,13 @@ if person is None: ...@@ -23,6 +22,13 @@ if person is None:
function='company/manager') function='company/manager')
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference=functional_test_username,
password=howto_dict['functional_test_user_password'],
)
login.validate()
# XXX (lucas): These tests must be able to run on an instance without security. # XXX (lucas): These tests must be able to run on an instance without security.
for role in ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Owner'): for role in ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Owner'):
portal.acl_users.zodb_roles.assignRoleToPrincipal(role, person.Person_getUserId()) portal.acl_users.zodb_roles.assignRoleToPrincipal(role, person.Person_getUserId())
......
...@@ -12,7 +12,6 @@ if person is None: ...@@ -12,7 +12,6 @@ if person is None:
title=functional_test_username) title=functional_test_username)
person.edit(reference=functional_test_username, person.edit(reference=functional_test_username,
password=howto_dict['functional_test_user_password'],
default_email_text=howto_dict['functional_test_user_email']) default_email_text=howto_dict['functional_test_user_email'])
person.validate() person.validate()
...@@ -23,6 +22,13 @@ if person is None: ...@@ -23,6 +22,13 @@ if person is None:
function='company/manager') function='company/manager')
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference=functional_test_username,
password=howto_dict['functional_test_user_password'],
)
login.validate()
# XXX (lucas): These tests must be able to run on an instance without security. # XXX (lucas): These tests must be able to run on an instance without security.
for role in ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Owner'): for role in ('Assignee', 'Assignor', 'Associate', 'Auditor', 'Owner'):
portal.acl_users.zodb_roles.assignRoleToPrincipal(role, person.Person_getUserId()) portal.acl_users.zodb_roles.assignRoleToPrincipal(role, person.Person_getUserId())
......
...@@ -11,10 +11,15 @@ else: ...@@ -11,10 +11,15 @@ else:
person = person_module.newContent(portal_type="Person", person = person_module.newContent(portal_type="Person",
reference=user_id, reference=user_id,
id=user_id, id=user_id,
password=new_password,
default_email_text="userA@example.invalid") default_email_text="userA@example.invalid")
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference=user_id,
password=new_password,
)
login.validate()
# Make sure always a new password # Make sure always a new password
person.setPassword(new_password) person.setPassword(new_password)
......
...@@ -27,7 +27,7 @@ if not portal.person_module.has_key('test_webmaster'): ...@@ -27,7 +27,7 @@ if not portal.person_module.has_key('test_webmaster'):
else: else:
person = portal.person_module.test_webmaster person = portal.person_module.test_webmaster
person.edit(first_name='Test', last_name='Webmaster', person.edit(first_name='Test', last_name='Webmaster',
reference='test_webmaster', password='test_webmaster') reference='test_webmaster')
person.setRole('internal') person.setRole('internal')
if not len(person.objectValues(portal_type='Assignment')): if not len(person.objectValues(portal_type='Assignment')):
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
...@@ -36,6 +36,13 @@ if not len(person.objectValues(portal_type='Assignment')): ...@@ -36,6 +36,13 @@ if not len(person.objectValues(portal_type='Assignment')):
stop_date=DateTime('2990/12/31')) stop_date=DateTime('2990/12/31'))
if assignment.getValidationState() != 'open': if assignment.getValidationState() != 'open':
assignment.open() assignment.open()
if not len(person.objectValues(portal_type='ERP5 Login')):
login = person.newContent(
portal_type='ERP5 Login',
reference='test_webmaster',
password='test_webmaster',
)
login.validate()
if person.getValidationState() != 'validated': if person.getValidationState() != 'validated':
person.validate() person.validate()
......
...@@ -51,6 +51,11 @@ class TestUNGSecurity(ERP5TypeTestCase): ...@@ -51,6 +51,11 @@ class TestUNGSecurity(ERP5TypeTestCase):
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.setFunction("function/ung_user") assignment.setFunction("function/ung_user")
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference='ung_user',
)
login.validate()
self.tic() self.tic()
def testERP5Site_createNewWebDocumentAsAnonymous(self): def testERP5Site_createNewWebDocumentAsAnonymous(self):
...@@ -82,6 +87,11 @@ class TestUNGSecurity(ERP5TypeTestCase): ...@@ -82,6 +87,11 @@ class TestUNGSecurity(ERP5TypeTestCase):
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.setFunction("function/ung_user") assignment.setFunction("function/ung_user")
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference='ung_user2',
)
login.validate()
self.tic() self.tic()
self.loginByUserName("ung_user") self.loginByUserName("ung_user")
self.changeSkin("UNGDoc") self.changeSkin("UNGDoc")
...@@ -175,6 +185,11 @@ class TestUNGSecurity(ERP5TypeTestCase): ...@@ -175,6 +185,11 @@ class TestUNGSecurity(ERP5TypeTestCase):
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.setFunction("function/ung_user") assignment.setFunction("function/ung_user")
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference='ung_user2',
)
login.validate()
self.tic() self.tic()
self.loginByUserName("ung_user") self.loginByUserName("ung_user")
self.changeSkin("UNGDoc") self.changeSkin("UNGDoc")
......
...@@ -133,10 +133,12 @@ class TestUNG(ERP5TypeTestCase): ...@@ -133,10 +133,12 @@ class TestUNG(ERP5TypeTestCase):
reference="ung_new_user") reference="ung_new_user")
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference=person.getReference()).validate()
person = portal.person_module.newContent(portal_type='Person', person = portal.person_module.newContent(portal_type='Person',
reference="ung_new_user2") reference="ung_new_user2")
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference=person.getReference()).validate()
self.tic() self.tic()
self.loginByUserName("ung_new_user") self.loginByUserName("ung_new_user")
self.changeSkin("UNGDoc") self.changeSkin("UNGDoc")
......
...@@ -52,8 +52,13 @@ class ShaSecurityMixin(object): ...@@ -52,8 +52,13 @@ class ShaSecurityMixin(object):
if person is None: if person is None:
person = self.portal.person_module.newContent(portal_type='Person') person = self.portal.person_module.newContent(portal_type='Person')
person.edit(first_name=reference, person.edit(first_name=reference,
reference=reference, reference=reference)
password=password) login = person.newContent(
portal_type='ERP5 Login',
reference=reference,
password=password,
)
login.validate()
self.tic() self.tic()
create = True create = True
......
...@@ -82,6 +82,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -82,6 +82,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
default_email_text=self.recipient_email_address) default_email_text=self.recipient_email_address)
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference=self.username).validate()
self.tic() self.tic()
uf = self.portal.acl_users uf = self.portal.acl_users
......
...@@ -126,6 +126,7 @@ class TestBug(ERP5TypeTestCase): ...@@ -126,6 +126,7 @@ class TestBug(ERP5TypeTestCase):
start_date='1980-01-01', start_date='1980-01-01',
stop_date='2099-12-31') stop_date='2099-12-31')
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference='dummy').validate()
self.tic() self.tic()
portal_type_list = [] portal_type_list = []
for portal_type in (self.project_portal_type, for portal_type in (self.project_portal_type,
......
...@@ -50,6 +50,7 @@ class TestCertificateAuthority(ERP5TypeTestCase): ...@@ -50,6 +50,7 @@ class TestCertificateAuthority(ERP5TypeTestCase):
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
reference=login, password=login) reference=login, password=login)
person.newContent(portal_type='Assignment').open() person.newContent(portal_type='Assignment').open()
person.newContent(portal_type='ERP5 Login', reference=login).validate()
self.tic() self.tic()
return login return login
......
...@@ -1167,14 +1167,14 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1167,14 +1167,14 @@ class TestERP5Base(ERP5TypeTestCase):
self.tic() self.tic()
# a user is created # a user is created
user = self.portal.acl_users.getUserById('user_login') user = self.portal.acl_users.getUser('user_login')
self.assertNotEquals(None, user) self.assertNotEquals(None, user)
# and this user has a preference created # and this user has a preference created
newSecurityManager(None, user.__of__(self.portal.acl_users)) newSecurityManager(None, user.__of__(self.portal.acl_users))
self.assertNotEquals(None, self.assertNotEquals(None,
self.portal.portal_catalog.getResultValue(portal_type='Preference', self.portal.portal_catalog.getResultValue(portal_type='Preference',
owner='user_login')) owner=user.getId()))
# for his assignent group # for his assignent group
self.assertEqual('group/nexedi', self.assertEqual('group/nexedi',
self.portal.portal_preferences.getPreferredSectionCategory()) self.portal.portal_preferences.getPreferredSectionCategory())
......
...@@ -227,6 +227,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -227,6 +227,7 @@ class TestCommerce(ERP5TypeTestCase):
start_date='1972-01-01', stop_date='2999-12-31', start_date='1972-01-01', stop_date='2999-12-31',
group=group, destination_project=destination_project) group=group, destination_project=destination_project)
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference=reference).validate()
self.tic() self.tic()
#XXX: Security hack (lucas) #XXX: Security hack (lucas)
......
...@@ -303,8 +303,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -303,8 +303,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.portal.ERP5Site_activeLogin(mail_message.getReference()) self.portal.ERP5Site_activeLogin(mail_message.getReference())
self.login() self.login()
self.tic() self.tic()
person = portal_catalog.getResultValue(reference=reference, person = self.portal.acl_users.getUser(reference).getUserValue()
portal_type="Person")
assignment_list = person.objectValues(portal_type="Assignment") assignment_list = person.objectValues(portal_type="Assignment")
self.assertEqual(len(assignment_list), 1) self.assertEqual(len(assignment_list), 1)
assignment = assignment_list[0] assignment = assignment_list[0]
...@@ -380,7 +379,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -380,7 +379,7 @@ class TestERP5Credential(ERP5TypeTestCase):
last_name='Simpson', reference='homie') last_name='Simpson', reference='homie')
self.assertEqual(len(result), 1) self.assertEqual(len(result), 1)
sequence.edit(subscription_request=result[0], sequence.edit(subscription_request=result[0],
person_reference=credential_reference) login_reference=credential_reference)
def stepAcceptSubscriptionRequest(self, sequence=None, sequence_list=None, def stepAcceptSubscriptionRequest(self, sequence=None, sequence_list=None,
**kw): **kw):
...@@ -407,9 +406,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -407,9 +406,9 @@ class TestERP5Credential(ERP5TypeTestCase):
# check homie can log in the system # check homie can log in the system
self._assertUserExists('homie', 'secret') self._assertUserExists('homie', 'secret')
self.login('homie') self.loginByUserName('homie')
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
self.assertEqual(getSecurityManager().getUser().getIdOrUserName(), 'homie') self.assertEqual(getSecurityManager().getUser().getUserName(), 'homie')
def stepCreateCredentialUpdate(self, sequence=None, sequence_list=None, **kw): def stepCreateCredentialUpdate(self, sequence=None, sequence_list=None, **kw):
''' '''
...@@ -418,10 +417,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -418,10 +417,9 @@ class TestERP5Credential(ERP5TypeTestCase):
''' '''
self.login() self.login()
# get the 'homie' person object # get the 'homie' person object
person_module = self.portal.getDefaultModule('Person') result = self.portal.portal_catalog(portal_type='ERP5 Login', reference='homie')
result = person_module.searchFolder(reference='homie')
self.assertEqual(len(result), 1) self.assertEqual(len(result), 1)
homie = result[0] homie = result[0].getParentValue()
# create a credential update # create a credential update
credential_update_module = self.portal.getDefaultModule(\ credential_update_module = self.portal.getDefaultModule(\
...@@ -453,9 +451,9 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -453,9 +451,9 @@ class TestERP5Credential(ERP5TypeTestCase):
# 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') person_module = self.portal.getDefaultModule('Person')
related_person_result = person_module.searchFolder(reference='homie') related_login_result = self.portal.portal_catalog(portal_type='ERP5 Login', reference='homie')
self.assertEqual(len(related_person_result), 1) self.assertEqual(len(related_login_result), 1)
related_person = related_person_result[0] related_person = related_login_result[0].getParentValue()
self.assertEqual(related_person.getLastName(), 'Simpsons') self.assertEqual(related_person.getLastName(), 'Simpsons')
self.assertEqual(related_person.getDefaultEmailText(), self.assertEqual(related_person.getDefaultEmailText(),
'homie.simpsons@fox.com') 'homie.simpsons@fox.com')
...@@ -609,7 +607,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -609,7 +607,7 @@ class TestERP5Credential(ERP5TypeTestCase):
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-login', 'secret') self._assertUserExists('barney-login', 'secret')
self.login('barney') self.loginByUserName('barney-login')
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
self.assertEqual(getSecurityManager().getUser().getIdOrUserName(), person.Person_getUserId()) self.assertEqual(getSecurityManager().getUser().getIdOrUserName(), person.Person_getUserId())
...@@ -658,10 +656,10 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -658,10 +656,10 @@ class TestERP5Credential(ERP5TypeTestCase):
self.portal.ERP5Site_newCredentialRecovery( self.portal.ERP5Site_newCredentialRecovery(
default_email_text=default_email_text) default_email_text=default_email_text)
def stepLoginAsCurrentPersonReference(self, sequence=None, def stepLoginAsCurrentLoginReference(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
person_reference = sequence["person_reference"] login_reference = sequence["login_reference"]
self.login(person_reference) self.loginByUserName(login_reference)
def stepCreateCredentialUpdateWithERP5Site_newCredentialUpdate(self, def stepCreateCredentialUpdateWithERP5Site_newCredentialUpdate(self,
sequence=None, sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
...@@ -863,8 +861,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -863,8 +861,7 @@ class TestERP5Credential(ERP5TypeTestCase):
def stepCheckPersonAfterSubscriptionRequest(self, sequence=None, def stepCheckPersonAfterSubscriptionRequest(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
self.login() self.login()
person = self.portal.portal_catalog.getResultValue( person = self.portal.acl_users.getUser(sequence['login_reference']).getUserValue()
reference=sequence["person_reference"], portal_type="Person")
self.assertEqual("Homer", person.getFirstName()) self.assertEqual("Homer", person.getFirstName())
self.assertEqual("Simpson", person.getLastName()) self.assertEqual("Simpson", person.getLastName())
self.assertEqual("homer.simpson@fox.com", person.getDefaultEmailText()) self.assertEqual("homer.simpson@fox.com", person.getDefaultEmailText())
...@@ -873,16 +870,14 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -873,16 +870,14 @@ class TestERP5Credential(ERP5TypeTestCase):
def stepSetAuditorRoleToCurrentPerson(self, sequence=None, def stepSetAuditorRoleToCurrentPerson(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
person_reference = sequence["person_reference"]
self.login() self.login()
person = self.portal.acl_users.getUser(person_reference).getUserValue() person = self.portal.acl_users.getUser(sequence['login_reference']).getUserValue()
person.manage_setLocalRoles(person.Person_getUserId(), ["Auditor"]) person.manage_setLocalRoles(person.Person_getUserId(), ["Auditor"])
self.logout() self.logout()
def stepCheckPersonAfterUpdatePerson(self, sequence=None, def stepCheckPersonAfterUpdatePerson(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
person = self.portal.portal_catalog.getResultValue( person = self.portal.acl_users.getUser(sequence['login_reference']).getUserValue()
reference=sequence["person_reference"], portal_type="Person")
self.assertEqual("tom", person.getFirstName()) self.assertEqual("tom", person.getFirstName())
self.assertEqual("Simpson", person.getLastName()) self.assertEqual("Simpson", person.getLastName())
self.assertEqual("tom@host.com", person.getDefaultEmailText()) self.assertEqual("tom@host.com", person.getDefaultEmailText())
...@@ -1123,8 +1118,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1123,8 +1118,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.portal.ERP5Site_activeLogin(mail_message.getReference()) self.portal.ERP5Site_activeLogin(mail_message.getReference())
self.login() self.login()
self.tic() self.tic()
person = portal_catalog.getResultValue(reference="barney", person = self.portal.acl_users.getUser('barney').getUserValue()
portal_type="Person")
assignment_list = person.objectValues(portal_type="Assignment") assignment_list = person.objectValues(portal_type="Assignment")
self.assertNotEquals(assignment_list, []) self.assertNotEquals(assignment_list, [])
self.assertEqual(len(assignment_list), 1) self.assertEqual(len(assignment_list), 1)
...@@ -1233,7 +1227,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1233,7 +1227,7 @@ class TestERP5Credential(ERP5TypeTestCase):
"stepCheckPersonAfterSubscriptionRequest " \ "stepCheckPersonAfterSubscriptionRequest " \
"SetAuditorRoleToCurrentPerson " \ "SetAuditorRoleToCurrentPerson " \
"SetAssigneeRoleToCurrentPersonInCredentialUpdateModule Tic " \ "SetAssigneeRoleToCurrentPersonInCredentialUpdateModule Tic " \
"LoginAsCurrentPersonReference " \ "LoginAsCurrentLoginReference " \
"CreateCredentialUpdateWithERP5Site_newCredentialUpdate Tic " \ "CreateCredentialUpdateWithERP5Site_newCredentialUpdate Tic " \
"SelectCredentialUpdate " \ "SelectCredentialUpdate " \
"AcceptCredentialUpdate Tic "\ "AcceptCredentialUpdate Tic "\
...@@ -1296,7 +1290,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1296,7 +1290,7 @@ class TestERP5Credential(ERP5TypeTestCase):
''' '''
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = "CreatePersonWithQuestionUsingCamelCase Tic " \ sequence_string = "CreatePersonWithQuestionUsingCamelCase Tic " \
"LoginAsCurrentPersonReference " \ "LoginAsCurrentLoginReference " \
"CreateCredentialRecoveryWithSensitiveAnswer Tic " \ "CreateCredentialRecoveryWithSensitiveAnswer Tic " \
"AcceptCredentialRecovery Tic " \ "AcceptCredentialRecovery Tic " \
"CheckEmailIsSent Tic "\ "CheckEmailIsSent Tic "\
......
This diff is collapsed.
...@@ -117,6 +117,7 @@ class TestWorklist(ERP5TypeTestCase): ...@@ -117,6 +117,7 @@ class TestWorklist(ERP5TypeTestCase):
stop_date = '01/01/2900', stop_date = '01/01/2900',
) )
assignment.open() assignment.open()
person.newContent(portal_type='ERP5 Login', reference=user_login).validate()
# Reindexing is required for the security to work # Reindexing is required for the security to work
self.tic() self.tic()
......
...@@ -150,6 +150,10 @@ class TestERP5BankingMixin(ERP5TypeTestCase): ...@@ -150,6 +150,10 @@ class TestERP5BankingMixin(ERP5TypeTestCase):
# by the assignment workflow when NuxUserGroup is used and # by the assignment workflow when NuxUserGroup is used and
# by ERP5Security PAS plugins in the context of PAS use. # by ERP5Security PAS plugins in the context of PAS use.
assignment.open() assignment.open()
person.newContent(
portal_type='ERP5 Login',
reference=user_login,
).validate()
if self.PAS_installed: if self.PAS_installed:
# reindexing is required for the security to work # reindexing is required for the security to work
......
...@@ -128,6 +128,7 @@ CREATE TABLE alternate_roles_and_users ( ...@@ -128,6 +128,7 @@ CREATE TABLE alternate_roles_and_users (
reference='user1') reference='user1')
user1_id = user1.Person_getUserId() user1_id = user1.Person_getUserId()
user1.newContent(portal_type='Assignment', group='g1').open() user1.newContent(portal_type='Assignment', group='g1').open()
user1.newContent(portal_type='ERP5 Login', reference='user1').validate()
user1.updateLocalRolesOnSecurityGroups() user1.updateLocalRolesOnSecurityGroups()
self.assertEqual(user1.__ac_local_roles__.get(user1_id), ['Auditor']) self.assertEqual(user1.__ac_local_roles__.get(user1_id), ['Auditor'])
self.assertEqual(user1.__ac_local_roles__.get('GROUP1'), ['Unknown']) self.assertEqual(user1.__ac_local_roles__.get('GROUP1'), ['Unknown'])
...@@ -136,6 +137,7 @@ CREATE TABLE alternate_roles_and_users ( ...@@ -136,6 +137,7 @@ CREATE TABLE alternate_roles_and_users (
reference='user2') reference='user2')
user2_id = user2.Person_getUserId() user2_id = user2.Person_getUserId()
user2.newContent(portal_type='Assignment', group='g1').open() user2.newContent(portal_type='Assignment', group='g1').open()
user2.newContent(portal_type='ERP5 Login', reference='user2').validate()
user2.updateLocalRolesOnSecurityGroups() user2.updateLocalRolesOnSecurityGroups()
self.assertEqual(user2.__ac_local_roles__.get(user2_id), ['Auditor']) self.assertEqual(user2.__ac_local_roles__.get(user2_id), ['Auditor'])
self.assertEqual(user2.__ac_local_roles__.get('GROUP1'), ['Unknown']) self.assertEqual(user2.__ac_local_roles__.get('GROUP1'), ['Unknown'])
......
...@@ -72,6 +72,7 @@ class TestGUISecurity(ERP5TypeTestCase): ...@@ -72,6 +72,7 @@ class TestGUISecurity(ERP5TypeTestCase):
self.assertTrue('Created Successfully' in message) self.assertTrue('Created Successfully' in message)
if not hasattr(portal.person_module, 'user'): if not hasattr(portal.person_module, 'user'):
user = portal.person_module.newContent(portal_type='Person', id='user', reference='user') user = portal.person_module.newContent(portal_type='Person', id='user', reference='user')
user.newContent(portal_type='ERP5 Login', reference='user').validate()
asg = user.newContent(portal_type='Assignment') asg = user.newContent(portal_type='Assignment')
asg.setStartDate(DateTime() - 100) asg.setStartDate(DateTime() - 100)
asg.setStopDate(DateTime() + 100) asg.setStopDate(DateTime() + 100)
......
...@@ -64,10 +64,15 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -64,10 +64,15 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
person = person_module.newContent(id='pers', portal_type='Person', person = person_module.newContent(id='pers', portal_type='Person',
reference=self.username, reference=self.username,
first_name=self.first_name, first_name=self.first_name,
password=self.password,
default_email_text=self.recipient_email_address) default_email_text=self.recipient_email_address)
assignment = person.newContent(portal_type='Assignment') assignment = person.newContent(portal_type='Assignment')
assignment.open() assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference=self.username,
password=self.password,
)
login.validate()
self.tic() self.tic()
def loginAsUser(self, username): def loginAsUser(self, username):
......
...@@ -471,8 +471,11 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -471,8 +471,11 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
reference=reference, reference=reference,
password=password,
**person_kw) **person_kw)
login = person.newContent(portal_type='ERP5 Login',
reference=reference,
password=password)
login.validate()
return person return person
def createUserAssignment(self, user, assignment_kw): def createUserAssignment(self, user, assignment_kw):
......
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