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