Commit 92129fcd authored by Rafael Monnerat's avatar Rafael Monnerat

General cleanup slapos erp5

See merge request nexedi/slapos.core!603
parents ba6cfec5 e309dcd8
...@@ -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(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
......
...@@ -43,7 +43,8 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -43,7 +43,8 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
def testConfiguredShacacheWebSite(self): def testConfiguredShacacheWebSite(self):
""" Make sure Shacache WebSite is setuped by Alarm """ Make sure Shacache WebSite is setuped by Alarm
case we trust on promise outcome.""" case we trust on promise outcome, this checks:
WebSiteModule_checkShacacheConstraint """
self.assertEqual(self.portal.web_site_module.checkConsistency(), []) self.assertEqual(self.portal.web_site_module.checkConsistency(), [])
def testConfiguredCacheViaConstraint(self): def testConfiguredCacheViaConstraint(self):
...@@ -54,7 +55,13 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -54,7 +55,13 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
def testConfiguredConversionServerViaConstraint(self): def testConfiguredConversionServerViaConstraint(self):
""" Make sure Conversion Server was configured well, """ Make sure Conversion Server was configured well,
invoking checkConsistency """ invoking checkConsistency """
self.assertEqual(self.portal.portal_preferences.checkConsistency(), []) pref_tool = self.portal.portal_preferences
self.assertEqual(pref_tool.checkConsistency(), [])
# Check if configuration is properly set:
self.assertEqual(
pref_tool.slapos_default_system_preference.SystemPreference_checkSystemPreferenceConsistency(),
[])
def testConfiguredCertificateAuthoringConstraint(self): def testConfiguredCertificateAuthoringConstraint(self):
"""Make sure Certificate Authoring was configured well, """Make sure Certificate Authoring was configured well,
...@@ -81,9 +88,9 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -81,9 +88,9 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
self.assertEqual([], self.assertEqual([],
self.portal.portal_templates.TemplateTool_checkBusinessApplicationToModuleConsistency()) self.portal.portal_templates.TemplateTool_checkBusinessApplicationToModuleConsistency())
def testConfiguredConversionServer(self): def test_SystemPreference_checkConversionServerConsistency(self):
""" Make sure Conversion Server (Cloudooo) is """ Make sure Conversion Server (Cloudooo) is
well configured """ well configured."""
# set preference # set preference
preference_tool = self.portal.portal_preferences preference_tool = self.portal.portal_preferences
conversion_url = ["https://cloudooo.erp5.net/"] conversion_url = ["https://cloudooo.erp5.net/"]
...@@ -111,10 +118,19 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -111,10 +118,19 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
""" Make sure portal_alarms is subscribed. """ """ Make sure portal_alarms is subscribed. """
self.assertTrue(self.portal.portal_alarms.isSubscribed()) self.assertTrue(self.portal.portal_alarms.isSubscribed())
def test_TemplateTool_checkSlapOSPASConsistency(self):
""" Ensure that PAS is configured after the configuration """
self.assertEqual(self.portal.portal_templates.TemplateTool_checkSlapOSPASConsistency(),
[])
self.assertEqual(self.portal.portal_templates.TemplateTool_checkSlapOSPASConsistency(),
[])
def testInteractionDropped(self): def testInteractionDropped(self):
""" Make sure that no portal type uses interaction workflow for simulation """ """ Make sure that no portal type uses interaction workflow for simulation """
for pt in self.portal.portal_types.objectValues(): for pt in self.portal.portal_types.objectValues():
for dropped_workflow in ["delivery_movement_simulation_interaction_workflow", for dropped_workflow in [
"delivery_movement_simulation_interaction_workflow",
"delivery_simulation_interaction_workflow", "delivery_simulation_interaction_workflow",
"open_order_simulation_interaction_workflow", "open_order_simulation_interaction_workflow",
"open_order_path_simulation_interaction_workflow", "open_order_path_simulation_interaction_workflow",
...@@ -126,7 +142,7 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -126,7 +142,7 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
"Workflow %s still present on %s Portal Type (%s)" % \ "Workflow %s still present on %s Portal Type (%s)" % \
(dropped_workflow, pt, pt.getTypeWorkflowList())) (dropped_workflow, pt, pt.getTypeWorkflowList()))
def testModuleHasIdGeneratorByDay(self): def test_Module_checkSlapOSModuleIdGeneratorConsistency(self):
""" Ensure the Constraint sets appropriate id generator on all modules. """ Ensure the Constraint sets appropriate id generator on all modules.
""" """
module_list = [module.getId() for module in self.portal.objectValues() module_list = [module.getId() for module in self.portal.objectValues()
...@@ -260,6 +276,9 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin): ...@@ -260,6 +276,9 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
self.assertSameSet(module_list, expected_module_list) self.assertSameSet(module_list, expected_module_list)
self.assertEqual(self.portal.portal_simulation.getIdGenerator(), "_generatePerDayId")
self.assertEqual(self.portal.portal_activities.getIdGenerator(), "_generatePerDayId")
def testConfiguredBusinessTemplateList(self): def testConfiguredBusinessTemplateList(self):
""" Make sure Installed business Templates are """ Make sure Installed business Templates are
what it is expected. """ what it is expected. """
......
...@@ -54,26 +54,3 @@ def Login_unrestrictedSearchPasswordEvent(self, REQUEST=None): ...@@ -54,26 +54,3 @@ def Login_unrestrictedSearchPasswordEvent(self, REQUEST=None):
validation_state='confirmed', validation_state='confirmed',
sort_on=(('creation_date', 'DESC'), ), sort_on=(('creation_date', 'DESC'), ),
limit=1) limit=1)
def migrateInstanceToERP5Login(self):
assert self.getPortalType() in ( 'Compute Node', 'Software Instance')
reference = self.getReference()
if not reference:
# no user id and no login is required
return
if not (self.hasUserId() or self.getUserId() == reference):
self.setUserId(reference)
if len(self.objectValues(
portal_type=["Certificate Login", "ERP5 Login"])):
# already migrated
return
login = self.newContent(
portal_type='Certificate Login',
reference=reference,
)
login.validate()
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSLogin</string> </value> <value> <string>SlapOSLogin</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
<item>Reference</item> <item>Reference</item>
<item>Url</item> <item>Url</item>
</portal_type> </portal_type>
<portal_type id="OAuth Tool">
<item>OAuthToolDefaultSlapOSConnector</item>
</portal_type>
<portal_type id="Organisation"> <portal_type id="Organisation">
<item>GeographicOrganisation</item> <item>GeographicOrganisation</item>
</portal_type> </portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>acl_users_slapos_machine_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>CertificateAuthorityTool_checkSlapOSMachineNonExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OAuthToolDefaultSlapOSConnector</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>FacebookConnector_existence_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>OAuthTool_checkFacebookConnectorExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GoogleConnector_existence_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>OAuthTool_checkGoogleConnectorExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
Certificate Login isn't controlled by ERP5 itself
"""
if context.getPassword() in [None, ""]:
return False
return context.Login_isLoginBlocked()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Login_isLoginBlocked</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
Certificate Login isn't controlled by ERP5 itself
"""
if context.getPassword() in [None, ""]:
return False
return context.Login_isPasswordExpired()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Login_isPasswordExpired</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
Return true if user account is blocked. Return true if user account is blocked.
""" """
from DateTime import DateTime from DateTime import DateTime
from erp5.component.module.Log import log
request = context.REQUEST request = context.REQUEST
portal = context.getPortalObject() portal = context.getPortalObject()
portal_preferences = portal.portal_preferences portal_preferences = portal.portal_preferences
...@@ -15,6 +17,13 @@ one_second = 1/24.0/60.0/60.0 ...@@ -15,6 +17,13 @@ one_second = 1/24.0/60.0/60.0
check_duration = portal_preferences.getPreferredAuthenticationFailureCheckDuration() check_duration = portal_preferences.getPreferredAuthenticationFailureCheckDuration()
block_duration = portal_preferences.getPreferredAuthenticationFailureBlockDuration() block_duration = portal_preferences.getPreferredAuthenticationFailureBlockDuration()
max_authentication_failures = portal_preferences.getPreferredMaxAuthenticationFailure() max_authentication_failures = portal_preferences.getPreferredMaxAuthenticationFailure()
if None in (check_duration,
block_duration,
max_authentication_failures):
log('Login block is not working because authentication policy in system preference is not set properly.')
return 0
check_time = now - check_duration*one_second check_time = now - check_duration*one_second
# some failures might be still unindexed # some failures might be still unindexed
......
"""
This script generates a human readable random
password in the form 'word'+digits+'word'.
from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410076
parameters: number of 'characters' , number of 'digits'
Pradeep Kishore Gowda <pradeep at btbytes.com >
License : GPL
Date : 2005.April.15
Revision 1.2
ChangeLog:
1.1 - fixed typos
1.2 - renamed functions _apart & _npart to a_part & n_part as zope does not allow functions to
start with _
"""
import string, random
vowel_list = ['a','e','i','o','u']
consonant_list = [a for a in string.ascii_lowercase if a not in vowel_list]
digit_list = string.digits
symbol_list = ["$", "-", "_", "&"]
def a_part(slen):
ret = ''
for i in range(slen):
if i%2 ==0:
randid = random.randint(0,20) #number of consonants
ret += consonant_list[randid]
else:
randid = random.randint(0,4) #number of vowels
ret += vowel_list[randid]
return ret
def n_part(slen):
ret = ''
for _ in range(slen):
randid = random.randint(0,9) #number of digits
ret += digit_list[randid]
return ret
def s_part(slen):
ret = ''
for _ in range(slen):
randid = random.randint(0,3) #number of digits
ret += symbol_list[randid]
return ret
fpl = alpha/2
if alpha % 2 :
fpl = int(alpha/2) + 1
lpl = alpha - fpl
begin = string.upper(a_part(fpl))
mid = n_part(numeric)
third = a_part(lpl)
end = s_part(symbol)
newpass = "%s%s%s%s" % (begin, mid, third, end)
return newpass
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>alpha=6, numeric=2, symbol=1</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Person_generatePassword</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Generate human readable random password</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
acl_users = portal.acl_users
plugin_id = 'slapos_machine'
error_list = []
if plugin_id not in acl_users.plugins.getAllPlugins(plugin_type='IExtractionPlugin')['active']:
error_list.append('SlapOS Machine Authentication Plugin is desactive as %s/%s' % (acl_users.getPath(), plugin_id))
if fixit:
tag = 'slapos_login_migration'
portal.portal_catalog.activate(tag=tag, activity='SQLQueue').searchAndActivate(
portal_type=('Compute Node', 'Software Instance'),
activate_kw={'tag': tag, 'priority': 6},
method_id='Instance_migrateToERP5Login',
)
getattr(acl_users, plugin_id).manage_activateInterfaces([
'IExtractionPlugin'
])
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CertificateAuthorityTool_checkSlapOSMachineNonExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>migrateInstanceToERP5Login</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSLogin</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_migrateToERP5Login</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal_oauth = context.portal_oauth
for connector in portal_oauth.searchFolder(portal_type="Facebook Connector"):
if connector.getReference() == "default":
return []
if fixit:
system_preference = context.portal_preferences.getActiveSystemPreference()
connector = portal_oauth.newContent(
portal_type="Facebook Connector",
reference="default",
client_id=getattr(system_preference, "preferred_vifib_facebook_application_id", None),
secret_key=getattr(system_preference, "preferred_vifib_facebook_application_secret", None)
)
connector.validate()
return []
return ["Default Facebook Connector is missing."]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OAuthTool_checkFacebookConnectorExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal_oauth = context.portal_oauth
for connector in portal_oauth.searchFolder(portal_type="Google Connector"):
if connector.getReference() == "default":
return []
if fixit:
system_preference = context.portal_preferences.getActiveSystemPreference()
connector = portal_oauth.newContent(
portal_type="Google Connector",
reference="default",
client_id=getattr(system_preference, "preferred_vifib_google_application_id", None),
secret_key=getattr(system_preference, "preferred_vifib_google_application_secret", None)
)
connector.validate()
return []
return ["Default Google Connector is missing."]
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OAuthTool_checkGoogleConnectorExistenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
...@@ -44,9 +43,9 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -44,9 +43,9 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
def _getPasswordEventList(self, login): def _getPasswordEventList(self, login):
return [x.getObject() for x in self.portal.portal_catalog( return [x.getObject() for x in self.portal.portal_catalog(
portal_type = 'Password Event', portal_type='Password Event',
default_destination_uid = login.getUid(), default_destination_uid=login.getUid(),
sort_on = (('creation_date', 'DESC',),))] sort_on=(('creation_date', 'DESC',),))]
def _notifyLoginFailureAboveMaximum(self, login): def _notifyLoginFailureAboveMaximum(self, login):
login.notifyLoginFailure() login.notifyLoginFailure()
...@@ -98,16 +97,6 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -98,16 +97,6 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
login = self._test(document, login_portal_type) login = self._test(document, login_portal_type)
self.assertTrue(login.isLoginBlocked()) self.assertTrue(login.isLoginBlocked())
def test_block_ERP5Login_without_password_on_person(self):
person = self.makePerson(user=0)
person.edit(
first_name="SOMENAME",
last_name="LASTNAME"
)
self._test_login_block_if_password_is_set(
document=person,
login_portal_type="ERP5 Login")
def test_block_CertificateLogin_without_password_on_person(self): def test_block_CertificateLogin_without_password_on_person(self):
person = self.makePerson(user=0) person = self.makePerson(user=0)
person.edit( person.edit(
...@@ -202,16 +191,6 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin): ...@@ -202,16 +191,6 @@ class TestSlapOSAuthenticationPolicyL(SlapOSTestCaseMixin):
self._clearCache() self._clearCache()
self.assertFalse(login.isPasswordExpired()) self.assertFalse(login.isPasswordExpired())
def test_expire_ERP5Login_without_password_on_person(self):
person = self.makePerson(user=0)
person.edit(
first_name="SOMENAME",
last_name="LASTNAME"
)
self._test_expire_when_passoword_is_set(
document=person,
login_portal_type="ERP5 Login")
def test_expire_CertificateLogin_without_password_on_person(self): def test_expire_CertificateLogin_without_password_on_person(self):
person = self.makePerson(user=0) person = self.makePerson(user=0)
person.edit( person.edit(
......
...@@ -230,6 +230,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -230,6 +230,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_hal_json_style/ERP5Site_receiveGoogleCallback', 'slapos_hal_json_style/ERP5Site_receiveGoogleCallback',
'slapos_hal_json_style/Event_getAcknowledgementDict', 'slapos_hal_json_style/Event_getAcknowledgementDict',
'slapos_hal_json_style/InstanceTree_getConnectionParameterList', 'slapos_hal_json_style/InstanceTree_getConnectionParameterList',
'slapos_hal_json_style/InstanceTree_getMonitorParameterDict',
'slapos_hal_json_style/Item_getCurrentProjectTitle', 'slapos_hal_json_style/Item_getCurrentProjectTitle',
'slapos_hal_json_style/Item_getCurrentSiteTitle', 'slapos_hal_json_style/Item_getCurrentSiteTitle',
'slapos_hal_json_style/Login_edit', 'slapos_hal_json_style/Login_edit',
...@@ -295,24 +296,13 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -295,24 +296,13 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_disaster_recovery/ERP5Site_recoverFromRestoration', 'slapos_disaster_recovery/ERP5Site_recoverFromRestoration',
'slapos_disaster_recovery/ERP5Site_reindexOrUnindexDocumentList', 'slapos_disaster_recovery/ERP5Site_reindexOrUnindexDocumentList',
'slapos_disaster_recovery/ERP5Site_unindexDeletedDocumentList', 'slapos_disaster_recovery/ERP5Site_unindexDeletedDocumentList',
'slapos_base/ERP5Login_isLoginBlocked',
'slapos_base/ERP5Login_isPasswordExpired',
'slapos_base/Login_getFastExpirationReferenceList', 'slapos_base/Login_getFastExpirationReferenceList',
'slapos_base/Login_isLoginBlocked', 'slapos_base/Login_isLoginBlocked',
'slapos_base/Login_isPasswordExpired', 'slapos_base/Login_isPasswordExpired',
'slapos_base/Login_notifyPasswordExpire', 'slapos_base/Login_notifyPasswordExpire',
'slapos_base/Person_applyContractInvitation', 'slapos_base/Person_applyContractInvitation',
'slapos_base/ERP5Site_getAvailableOAuthLoginList', 'slapos_base/ERP5Site_getAvailableOAuthLoginList',
'slapos_erp5/CatalogTool_checkNoneCreationDateConsistency', 'slapos_erp5/CatalogTool_checkNoneCreationDateConsistency']
'slapos_erp5/CertificateAuthorityTool_checkCertificateAuthorityConsistency',
'slapos_erp5/CertificateAuthorityTool_checkSlapOSMachineNonExistenceConsistency',
'slapos_erp5/CertificateAuthorityTool_checkSlapOSPASConsistency',
'slapos_erp5/Module_checkSlapOSModuleIdGeneratorConsistency',
'slapos_erp5/OAuthTool_checkFacebookConnectorExistenceConsistency',
'slapos_erp5/OAuthTool_checkGoogleConnectorExistenceConsistency',
'slapos_erp5/WebSiteModule_checkShacacheConstraint',
'slapos_erp5/SystemPreference_checkConversionServerConsistency',
'slapos_erp5/SystemPreference_checkSystemPreferenceConsistency']
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
......
...@@ -6,7 +6,6 @@ Contract Invitation Token | Url ...@@ -6,7 +6,6 @@ Contract Invitation Token | Url
Id Tool | SlapOSModuleIdGeneratorConstraint Id Tool | SlapOSModuleIdGeneratorConstraint
Invitation Token | Reference Invitation Token | Reference
Invitation Token | Url Invitation Token | Url
OAuth Tool | OAuthToolDefaultSlapOSConnector
Organisation | GeographicOrganisation Organisation | GeographicOrganisation
Template Tool | TemplateToolBusinessApplicationModuleCategoryConstraint Template Tool | TemplateToolBusinessApplicationModuleCategoryConstraint
Web Site Module | WebSiteModuleShacacheConstraint Web Site Module | WebSiteModuleShacacheConstraint
\ No newline at end of file
PreferenceSlapOSConstraintPreference CatalogToolNoneCreationDateConstraint
CertificateAuthorityToolConsistencyConstraint CertificateAuthorityToolConsistencyConstraint
SlapOSModuleIdGeneratorConstraint
GeographicOrganisation GeographicOrganisation
WebSiteModuleShacacheConstraint PreferenceSlapOSConstraintPreference
ShacacheSystemPreference ShacacheSystemPreference
OAuthToolDefaultSlapOSConnector SlapOSModuleIdGeneratorConstraint
CatalogToolNoneCreationDateConstraint
TemplateToolBusinessApplicationModuleCategoryConstraint TemplateToolBusinessApplicationModuleCategoryConstraint
TemplateToolPASConsistencyConstraint
WebSiteModuleShacacheConstraint
...@@ -28,13 +28,10 @@ for role in ['member', 'subscriber']: ...@@ -28,13 +28,10 @@ for role in ['member', 'subscriber']:
title = '%s Assignment' % (role.capitalize()), title = '%s Assignment' % (role.capitalize()),
role = role).open(comment="Created by Subscription Request") role = role).open(comment="Created by Subscription Request")
password = list("".join([context.Person_generatePassword(15, 5, 4) for _ in range(random.randint(2, 4))]))
random.shuffle(password)
login = person.newContent( login = person.newContent(
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference="%s-FIRST-SUBSCRIBER-LOGIN" % person.getUserId(), reference="%s-FIRST-SUBSCRIBER-LOGIN" % person.getUserId(),
password="".join(password)) password=context.Person_generatePassword())
login.validate() login.validate()
......
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