Commit 36cd20fe authored by Vincent Pelletier's avatar Vincent Pelletier

Products.ERP5Security.test.testERP5Security: Rollback when creation raises.

For realism: the goal of this exception is to prevent duplicate, and it
relies on the exception triggering a rollback in the transaction manager
(like any transaction error).
Also, use "any()" rather than building entire lists just to check for non-
emptiness.
parent cbb861b7
...@@ -548,6 +548,7 @@ class DuplicatePrevention(UserManagementTestCase): ...@@ -548,6 +548,7 @@ class DuplicatePrevention(UserManagementTestCase):
'user id P%i already exists' % (latest_user_id + 1), 'user id P%i already exists' % (latest_user_id + 1),
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person') portal_type='Person')
self.abort()
# This error is not permanent, the id is skipped and next generation should succeed # This error is not permanent, the id is skipped and next generation should succeed
self.assertEqual( self.assertEqual(
...@@ -928,16 +929,18 @@ class TestMigration(UserManagementTestCase): ...@@ -928,16 +929,18 @@ class TestMigration(UserManagementTestCase):
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person', portal_type='Person',
reference='old_user_id') reference='old_user_id')
self.abort()
self.portal.portal_templates.fixConsistency(filter={'constraint_type': 'post_upgrade'}) self.portal.portal_templates.fixConsistency(filter={'constraint_type': 'post_upgrade'})
def stop_condition(message_list): def stop_condition(message_list):
if [m for m in message_list if m.method_id != 'immediateReindexObject']: if any(m.method_id != 'immediateReindexObject' for m in message_list):
self.assertRaisesRegexp( self.assertRaisesRegexp(
ValidationFailed, ValidationFailed,
'user id old_user_id already exists', 'user id old_user_id already exists',
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person', portal_type='Person',
reference='old_user_id') reference='old_user_id')
self.abort()
return False return False
self.tic(stop_condition=stop_condition) self.tic(stop_condition=stop_condition)
self.portal.person_module.newContent(portal_type='Person', reference='old_user_id') self.portal.person_module.newContent(portal_type='Person', reference='old_user_id')
...@@ -947,6 +950,7 @@ class TestMigration(UserManagementTestCase): ...@@ -947,6 +950,7 @@ class TestMigration(UserManagementTestCase):
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person', portal_type='Person',
user_id='old_user_id') user_id='old_user_id')
self.abort()
def test_DuplicateUserIdFromInitUserIdPreventionDuringMigration(self): def test_DuplicateUserIdFromInitUserIdPreventionDuringMigration(self):
self._enableERP5UsersPlugin() self._enableERP5UsersPlugin()
...@@ -964,15 +968,17 @@ class TestMigration(UserManagementTestCase): ...@@ -964,15 +968,17 @@ class TestMigration(UserManagementTestCase):
'user id P1234 already exists', 'user id P1234 already exists',
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person',) portal_type='Person',)
self.abort()
self.portal.portal_templates.fixConsistency(filter={'constraint_type': 'post_upgrade'}) self.portal.portal_templates.fixConsistency(filter={'constraint_type': 'post_upgrade'})
def stop_condition(message_list): def stop_condition(message_list):
if [m for m in message_list if m.method_id != 'immediateReindexObject']: if any(m.method_id != 'immediateReindexObject' for m in message_list):
self.assertRaisesRegexp( self.assertRaisesRegexp(
ValidationFailed, ValidationFailed,
'user id P1234 already exists', 'user id P1234 already exists',
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person',) portal_type='Person',)
self.abort()
return False return False
self.tic(stop_condition=stop_condition) self.tic(stop_condition=stop_condition)
...@@ -981,6 +987,7 @@ class TestMigration(UserManagementTestCase): ...@@ -981,6 +987,7 @@ class TestMigration(UserManagementTestCase):
'user id P1234 already exists', 'user id P1234 already exists',
self.portal.person_module.newContent, self.portal.person_module.newContent,
portal_type='Person',) portal_type='Person',)
self.abort()
def test_NonMigratedPersonCanBecomeUserLater(self): def test_NonMigratedPersonCanBecomeUserLater(self):
self._enableERP5UsersPlugin() self._enableERP5UsersPlugin()
......
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