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

Improvements for setup and login

See merge request nexedi/slapos.core!379
parents 85441807 4aba7622
Pipeline #21191 passed with stage
in 0 seconds
......@@ -40,7 +40,7 @@
</item>
<item>
<key> <string>configuration_after_script_id</string> </key>
<value> <string>BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList</string> </value>
<value> <string>BusinessConfiguration_runPostUpgradeConsistency</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CertificateLogin_isPasswordExpired</string> </value>
<value> <string>BusinessConfiguration_runPostUpgradeConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -28,11 +28,6 @@ import os
class TestSlapOSConfigurator(SlapOSTestCaseMixin):
maxDiff = None
def bootstrapSite(self):
SlapOSTestCaseMixin.bootstrapSite(self)
self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList()
self.tic()
def testConfiguredModuleGeneratorIDViaConstraint(self):
""" Make sure Generator ID is well configured, in this
case we trust on promise outcome."""
......
......@@ -8,7 +8,7 @@
<multi_property id='base_category'>destination</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Customer</property>
<property id='title'>Customer Source</property>
<property id='description'>Monovalued role</property>
<property id='condition'>python: here.getSourceValue(portal_type='Person') is not None</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
......
......@@ -32,7 +32,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PreferenceToolSlapOSConstraintPreference</string> </value>
<value> <string>PreferenceSlapOSConstraintPreference</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>PreferenceTool_checkConversionServerConsistency</string> </value>
<value> <string>SystemPreference_checkConversionServerConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>PreferenceTool_checkSystemPreferenceConsistency</string> </value>
<value> <string>SystemPreference_checkSystemPreferenceConsistency</string> </value>
</item>
</dictionary>
</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 @@
<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>BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList</string> </value>
<value> <string>ERP5Site_getAvailableOAuthLoginList</string> </value>
</item>
</dictionary>
</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 []
if context.getId() == "slapos_default_system_preference" and context.getPreferenceState() != "global":
error_log.extend(context.SystemPreference_checkSystemPreferenceConsistency(fixit=fixit, **kw))
if context.getPreferenceState() != "global":
return []
......@@ -14,7 +19,8 @@ if expected_url != url:
if fixit:
system_preference.setPreferredDocumentConversionServerUrl(expected_url)
fixing = ' (fixed)'
return ["Conversion Server not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url))]
else:
return []
error_log.append("Conversion Server not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url)))
return error_log
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PreferenceTool_checkConversionServerConsistency</string> </value>
<value> <string>SystemPreference_checkConversionServerConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -3,13 +3,26 @@
ensure the site configuration is set.
"""
if context.getPortalType() not in [ "System Preference"]:
if context.getPortalType() not in ["System Preference"]:
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":
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 = [
"getPreferredHateoasUrl",
......@@ -20,7 +33,6 @@ preference_method_list = [
]
for method_id in preference_method_list:
result = getattr(context.portal_preferences, method_id)()
if result in [None, ""]:
error_list.append(
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PreferenceTool_checkSystemPreferenceConsistency</string> </value>
<value> <string>SystemPreference_checkSystemPreferenceConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
PreferenceToolSlapOSConstraintPreference
PreferenceToolConversionServerConstraintPreference
PreferenceSlapOSConstraintPreference
CertificateAuthorityToolConsistencyConstraint
SlapOSModuleIdGeneratorConstraint
MemcachedToolServerConstraint
......
......@@ -160,17 +160,7 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.commit()
self.launchConfigurator()
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.commit()
def updateInitSite(self):
self.portal.portal_caches.updateCache()
try:
......@@ -182,13 +172,20 @@ class testSlapOSMixin(ERP5TypeTestCase):
initsite["cloudooo_url"] = "https://cloudooo.erp5.net"
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()
if not getattr(self.portal, 'is_site_bootstrapped', 0):
self.portal.is_site_bootstrapped = 1
self.bootstrapSite()
self.portal._p_changed = 1
self.commit()
self.updateInitSite()
def deSetUpPersistentDummyMailHost(self):
if 'MailHost' in self.portal.objectIds():
......@@ -209,8 +206,9 @@ class testSlapOSMixin(ERP5TypeTestCase):
"slapos_master_configuration_workflow"]
def launchConfigurator(self):
self.logMessage('SlapOS launchConfigurator')
self.logMessage('SlapOS launchConfigurator ...\n')
self.login()
self.updateInitSite()
# Create new Configuration
business_configuration = self.getBusinessConfiguration()
......@@ -226,13 +224,13 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
self.tic(verbose=True, delay=3600)
def bootstrapSite(self):
self.logMessage('SlapOS bootstrapSite')
self.getDefaultSystemPreference().setPreferredHateoasUrl("http://dummy/")
self.getDefaultSystemPreference().setPreferredAuthenticationPolicyEnabled(True)
# Set post upgrade configurations for the tests
preference_tool = self.portal.portal_preferences.portal_preferences
preference_tool.slapos_default_system_preference.setPreferredHateoasUrl("http://dummy/")
preference_tool.slapos_default_system_preference.setPreferredAuthenticationPolicyEnabled(True)
self.clearCache()
self.tic()
self.clearCache()
def getExpectedBusinessTemplateInstalledAfterConfiguration(self):
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