Commit 85e411bf authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5&cloud: Reuse Person_generatePassword on Tests

   We don't need to generate password everywhere
parent 91e4fb57
...@@ -131,7 +131,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -131,7 +131,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def _addERP5Login(self, document, **kw): def _addERP5Login(self, document, **kw):
if document.getPortalType() == "Person": if document.getPortalType() == "Person":
kw["password"] = "%s-aA$1" % self.generateNewId() kw["password"] = document.Person_generatePassword()
login = document.newContent( login = document.newContent(
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference=document.getReference(), reference=document.getReference(),
......
...@@ -182,8 +182,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin): ...@@ -182,8 +182,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
self.test_inactive(login_portal_type="ERP5 Login") self.test_inactive(login_portal_type="ERP5 Login")
class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
def test_active(self, login_portal_type="Certificate Login"): def test_active(self, login_portal_type="Certificate Login"):
password = '%s-aA1$' % str(random.random())
reference = self._generateRandomUniqueReference('Person') reference = self._generateRandomUniqueReference('Person')
user_id = self._generateRandomUniqueUserId('Person') user_id = self._generateRandomUniqueUserId('Person')
...@@ -192,6 +191,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -192,6 +191,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
reference=reference) reference=reference)
person.setUserId(user_id) person.setUserId(user_id)
password = person.Person_generatePassword()
person.newContent(portal_type='Assignment').open() person.newContent(portal_type='Assignment').open()
if login_portal_type == "ERP5 Login": if login_portal_type == "ERP5 Login":
person.newContent(portal_type=login_portal_type, person.newContent(portal_type=login_portal_type,
...@@ -235,12 +235,12 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -235,12 +235,12 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups()) self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups())
def test_inactive(self, login_portal_type="Certificate Login"): def test_inactive(self, login_portal_type="Certificate Login"):
password = '%s-aA1$' % str(random.random())
reference = self._generateRandomUniqueReference('Person') reference = self._generateRandomUniqueReference('Person')
user_id = self._generateRandomUniqueReference('Person') user_id = self._generateRandomUniqueReference('Person')
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
reference=reference) reference=reference)
password = person.Person_generatePassword()
self.tic() self.tic()
......
...@@ -100,24 +100,28 @@ ...@@ -100,24 +100,28 @@
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>validate</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>validate</string> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>validated</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>validated</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
...@@ -84,7 +84,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -84,7 +84,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
self.assertFalse(login.isLoginBlocked()) self.assertFalse(login.isLoginBlocked())
# Password should be ignored # Password should be ignored
login.setPassword("%s-aA$1" % self.generateNewId()) login.setPassword(document.Person_generatePassword())
self._clearCache() self._clearCache()
self.tic() self.tic()
...@@ -197,7 +197,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -197,7 +197,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
login_portal_type=login_portal_type login_portal_type=login_portal_type
) )
login.setPassword("%s-aA$1" % self.generateNewId()) login.setPassword(document.Person_generatePassword())
self.system_preference.setPreferredMaxPasswordLifetimeDuration(0) self.system_preference.setPreferredMaxPasswordLifetimeDuration(0)
self._clearCache() self._clearCache()
self.assertTrue(login.isPasswordExpired()) self.assertTrue(login.isPasswordExpired())
...@@ -208,7 +208,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -208,7 +208,7 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
login_portal_type=login_portal_type login_portal_type=login_portal_type
) )
login.setPassword("%s-aA$1" % self.generateNewId()) login.setPassword(document.Person_generatePassword())
self.system_preference.setPreferredMaxPasswordLifetimeDuration(0) self.system_preference.setPreferredMaxPasswordLifetimeDuration(0)
self._clearCache() self._clearCache()
self.assertFalse(login.isPasswordExpired()) self.assertFalse(login.isPasswordExpired())
......
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