Commit e309dcd8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Ensure that addERP5Login dont fail when set password

   The password has to work accordinally the policy, if fail retry a few times.
parent d68a7d7a
......@@ -33,7 +33,7 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript
import transaction
import functools
from functools import wraps
from zLOG import LOG, INFO
def changeSkin(skin_name):
def decorator(func):
......@@ -193,12 +193,21 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return custom_organisation
def _addERP5Login(self, document, **kw):
if document.getPortalType() == "Person":
kw["password"] = document.Person_generatePassword()
if document.getPortalType() != "Person":
raise ValueError("Only Person supports add ERP5 Login")
login = document.newContent(
portal_type="ERP5 Login",
reference=document.getReference(),
**kw)
for _ in range(5):
try:
login.setPassword(document.Person_generatePassword())
break
except ValueError:
# Skip the generated password wasnt acceptable let it try again.
LOG("SlapOSTextCaseMixin._addERP5Login", INFO, "Set password failed, try few more times")
login.validate()
return login
......@@ -211,7 +220,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return login
def makePerson(self, new_id=None, index=True, user=True):
if new_id is None:
new_id = self.generateNewId()
# Clone person document
......
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