Commit b99aa55f 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 d174c076
Pipeline #32732 failed with stage
in 0 seconds
...@@ -33,7 +33,7 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript ...@@ -33,7 +33,7 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript
import transaction import transaction
import functools import functools
from functools import wraps from functools import wraps
from zLOG import LOG, INFO
def changeSkin(skin_name): def changeSkin(skin_name):
def decorator(func): def decorator(func):
...@@ -193,12 +193,21 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -193,12 +193,21 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return custom_organisation return custom_organisation
def _addERP5Login(self, document, **kw): def _addERP5Login(self, document, **kw):
if document.getPortalType() == "Person": if document.getPortalType() != "Person":
kw["password"] = document.Person_generatePassword() raise ValueError("Only Person supports add ERP5 Login")
login = document.newContent( login = document.newContent(
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference=document.getReference(), reference=document.getReference(),
**kw) **kw)
for _ in range(5):
try:
login.setPassword(password=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() login.validate()
return login return login
...@@ -211,7 +220,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -211,7 +220,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return login return login
def makePerson(self, new_id=None, index=True, user=True): def makePerson(self, new_id=None, index=True, user=True):
if new_id is None: if new_id is None:
new_id = self.generateNewId() new_id = self.generateNewId()
# Clone person document # 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