Commit 0efe833e authored by Rafael Monnerat's avatar Rafael Monnerat

Improvements for setup and login

See merge request !379
parents 85441807 4aba7622
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_after_script_id</string> </key> <key> <string>configuration_after_script_id</string> </key>
<value> <string>BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList</string> </value> <value> <string>BusinessConfiguration_runPostUpgradeConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>CertificateLogin_isPasswordExpired</string> </value> <value> <string>BusinessConfiguration_runPostUpgradeConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -28,11 +28,6 @@ import os ...@@ -28,11 +28,6 @@ import os
class TestSlapOSConfigurator(SlapOSTestCaseMixin): class TestSlapOSConfigurator(SlapOSTestCaseMixin):
maxDiff = None maxDiff = None
def bootstrapSite(self):
SlapOSTestCaseMixin.bootstrapSite(self)
self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList()
self.tic()
def testConfiguredModuleGeneratorIDViaConstraint(self): def testConfiguredModuleGeneratorIDViaConstraint(self):
""" Make sure Generator ID is well configured, in this """ Make sure Generator ID is well configured, in this
case we trust on promise outcome.""" case we trust on promise outcome."""
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<multi_property id='base_category'>destination</multi_property> <multi_property id='base_category'>destination</multi_property>
</role> </role>
<role id='Auditor'> <role id='Auditor'>
<property id='title'>Customer</property> <property id='title'>Customer Source</property>
<property id='description'>Monovalued role</property> <property id='description'>Monovalued role</property>
<property id='condition'>python: here.getSourceValue(portal_type='Person') is not None</property> <property id='condition'>python: here.getSourceValue(portal_type='Person') is not None</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>PreferenceToolSlapOSConstraintPreference</string> </value> <value> <string>PreferenceSlapOSConstraintPreference</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</item> </item>
<item> <item>
<key> <string>script_id</string> </key> <key> <string>script_id</string> </key>
<value> <string>PreferenceTool_checkConversionServerConsistency</string> </value> <value> <string>SystemPreference_checkConversionServerConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</item> </item>
<item> <item>
<key> <string>script_id</string> </key> <key> <string>script_id</string> </key>
<value> <string>PreferenceTool_checkSystemPreferenceConsistency</string> </value> <value> <string>SystemPreference_checkSystemPreferenceConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?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>PreferenceToolConversionServerConstraintPreference</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="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>id</string> </key>
<value> <string>CertificateLogin_isLoginBlocked</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
oauth_login_list = []
portal_skin = context.getPortalObject().portal_skins
if getattr(portal_skin, "erp5_oauth_google_login", None) is not None:
connector = context.ERP5Site_getGoogleConnector()
if connector is not None and connector[0].getClientId() is not None:
oauth_login_list.append("google")
if getattr(portal_skin, "erp5_oauth_facebook_login", None) is not None:
connector = context.ERP5Site_getFacebookConnector()
if connector is not None and connector[0].getClientId() is not None:
oauth_login_list.append("facebook")
if getattr(portal_skin, "erp5_openid_connect_client", None) is not None:
oauth_login_list.append("openidconnect")
return oauth_login_list
...@@ -52,9 +52,17 @@ ...@@ -52,9 +52,17 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList</string> </value> <value> <string>ERP5Site_getAvailableOAuthLoginList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>id</string> </key>
<value> <string>FacebookLogin_isLoginBlocked</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>id</string> </key>
<value> <string>FacebookLogin_isPasswordExpired</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>id</string> </key>
<value> <string>GoogleLogin_isLoginBlocked</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>id</string> </key>
<value> <string>GoogleLogin_isPasswordExpired</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if context.getPortalType() not in [ "System Preference"]: error_log = []
if context.getPortalType() not in ["System Preference"]:
return [] return []
if context.getId() == "slapos_default_system_preference" and context.getPreferenceState() != "global":
error_log.extend(context.SystemPreference_checkSystemPreferenceConsistency(fixit=fixit, **kw))
if context.getPreferenceState() != "global": if context.getPreferenceState() != "global":
return [] return []
...@@ -14,7 +19,8 @@ if expected_url != url: ...@@ -14,7 +19,8 @@ if expected_url != url:
if fixit: if fixit:
system_preference.setPreferredDocumentConversionServerUrl(expected_url) system_preference.setPreferredDocumentConversionServerUrl(expected_url)
fixing = ' (fixed)' fixing = ' (fixed)'
return ["Conversion Server not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url))] error_log.append("Conversion Server not configured as expected%s: %s" %
else: (fixing, "Expect %s\nGot %s" % (expected_url, url)))
return []
return error_log
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>PreferenceTool_checkConversionServerConsistency</string> </value> <value> <string>SystemPreference_checkConversionServerConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -3,13 +3,26 @@ ...@@ -3,13 +3,26 @@
ensure the site configuration is set. ensure the site configuration is set.
""" """
if context.getPortalType() not in [ "System Preference"]: if context.getPortalType() not in ["System Preference"]:
return [] return []
error_list = []
if context.getId() == "slapos_default_system_preference" and context.getPreferenceState() != "global":
error_list.append(
"The Default System preference globally enabled shouldn't be slapos_default_system_preference" % context.getId())
if fixit:
context.globalEnable(comment="Enabled by PreferenceTool_checkSystemPreferenceConsistency")
if context.getPreferenceState() != "global": if context.getPreferenceState() != "global":
return [] return []
error_list = [] if context.getId() != "slapos_default_system_preference":
error_list.append(
"The Default System preference globally enabled shouldn't be %s but slapos_default_system_preference" % context.getId())
if fixit:
context.disable(comment="Disabled by PreferenceTool_checkSystemPreferenceConsistency")
preference_method_list = [ preference_method_list = [
"getPreferredHateoasUrl", "getPreferredHateoasUrl",
...@@ -20,7 +33,6 @@ preference_method_list = [ ...@@ -20,7 +33,6 @@ preference_method_list = [
] ]
for method_id in preference_method_list: for method_id in preference_method_list:
result = getattr(context.portal_preferences, method_id)() result = getattr(context.portal_preferences, method_id)()
if result in [None, ""]: if result in [None, ""]:
error_list.append( error_list.append(
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>PreferenceTool_checkSystemPreferenceConsistency</string> </value> <value> <string>SystemPreference_checkSystemPreferenceConsistency</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
PreferenceToolSlapOSConstraintPreference PreferenceSlapOSConstraintPreference
PreferenceToolConversionServerConstraintPreference
CertificateAuthorityToolConsistencyConstraint CertificateAuthorityToolConsistencyConstraint
SlapOSModuleIdGeneratorConstraint SlapOSModuleIdGeneratorConstraint
MemcachedToolServerConstraint MemcachedToolServerConstraint
......
...@@ -160,17 +160,7 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -160,17 +160,7 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.commit() self.commit()
self.launchConfigurator() self.launchConfigurator()
def afterSetUp(self): def updateInitSite(self):
self.login()
self.createAlarmStep()
if self.isLiveTest():
self.setUpPersistentDummyMailHost()
return
self.portal.portal_caches.erp5_site_global_id = '%s' % random.random()
self.portal.portal_caches._p_changed = 1
self.createCertificateAuthorityFile()
self.commit()
self.portal.portal_caches.updateCache() self.portal.portal_caches.updateCache()
try: try:
...@@ -182,13 +172,20 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -182,13 +172,20 @@ class testSlapOSMixin(ERP5TypeTestCase):
initsite["cloudooo_url"] = "https://cloudooo.erp5.net" initsite["cloudooo_url"] = "https://cloudooo.erp5.net"
config.product_config["initsite"] = initsite config.product_config["initsite"] = initsite
self.commit()
def afterSetUp(self):
self.login()
self.createAlarmStep()
if self.isLiveTest():
self.setUpPersistentDummyMailHost()
return
self.portal.portal_caches.erp5_site_global_id = '%s' % random.random()
self.portal.portal_caches._p_changed = 1
self.createCertificateAuthorityFile() self.createCertificateAuthorityFile()
if not getattr(self.portal, 'is_site_bootstrapped', 0): self.commit()
self.portal.is_site_bootstrapped = 1 self.updateInitSite()
self.bootstrapSite()
self.portal._p_changed = 1
self.commit()
def deSetUpPersistentDummyMailHost(self): def deSetUpPersistentDummyMailHost(self):
if 'MailHost' in self.portal.objectIds(): if 'MailHost' in self.portal.objectIds():
...@@ -209,8 +206,9 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -209,8 +206,9 @@ class testSlapOSMixin(ERP5TypeTestCase):
"slapos_master_configuration_workflow"] "slapos_master_configuration_workflow"]
def launchConfigurator(self): def launchConfigurator(self):
self.logMessage('SlapOS launchConfigurator') self.logMessage('SlapOS launchConfigurator ...\n')
self.login() self.login()
self.updateInitSite()
# Create new Configuration # Create new Configuration
business_configuration = self.getBusinessConfiguration() business_configuration = self.getBusinessConfiguration()
...@@ -226,13 +224,13 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -226,13 +224,13 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary() self.portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
self.tic(verbose=True, delay=3600) self.tic(verbose=True, delay=3600)
def bootstrapSite(self): # Set post upgrade configurations for the tests
self.logMessage('SlapOS bootstrapSite') preference_tool = self.portal.portal_preferences.portal_preferences
self.getDefaultSystemPreference().setPreferredHateoasUrl("http://dummy/") preference_tool.slapos_default_system_preference.setPreferredHateoasUrl("http://dummy/")
self.getDefaultSystemPreference().setPreferredAuthenticationPolicyEnabled(True) preference_tool.slapos_default_system_preference.setPreferredAuthenticationPolicyEnabled(True)
self.clearCache()
self.tic() self.tic()
self.clearCache()
def getExpectedBusinessTemplateInstalledAfterConfiguration(self): def getExpectedBusinessTemplateInstalledAfterConfiguration(self):
return [ 'erp5_core', return [ 'erp5_core',
......
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