Commit a3d0cd99 authored by Rafael Monnerat's avatar Rafael Monnerat

Reduce setup not required code

See merge request !576
parents b90d469e b0eb77ac
Pipeline #30338 failed with stage
in 0 seconds
......@@ -55,7 +55,7 @@ class TestSlapOSSecurityMixin(SlapOSTestCaseMixin):
"""Checks that a user with login and password exists and can log in to the
system.
"""
uf = self.getUserFolder()
uf = self.portal.acl_users
self.assertNotEqual(uf.getUserById(user_id, None), None)
for _, plugin in uf._getOb('plugins').listPlugins(
IAuthenticationPlugin ):
......@@ -72,7 +72,7 @@ class TestSlapOSSecurityMixin(SlapOSTestCaseMixin):
"""Checks that a user with login and password does not exists and cannot
log in to the system.
"""
uf = self.getUserFolder()
uf = self.portal.acl_users
for plugin_name, plugin in uf._getOb('plugins').listPlugins(
IAuthenticationPlugin ):
if plugin.authenticateCredentials(
......
......@@ -25,6 +25,7 @@ from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixin
import os
class TestSlapOSConfigurator(SlapOSTestCaseMixin):
maxDiff = None
......@@ -80,53 +81,13 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
self.assertEqual([],
self.portal.portal_templates.TemplateTool_checkBusinessApplicationToModuleConsistency())
def testConfiguredVolatileCache(self):
""" Make sure Memcached is configured
"""
if self.isLiveTest():
# This test is redundant with testConfiguredVolatileCacheViaPromise
# and it is only aims to verify if test environment is behaving as
# expected, nothing else, and if alamrs were invoked.
return
from Products.ERP5Type.tests.ERP5TypeTestCase import \
_getVolatileMemcachedServerDict
memcached_tool = self.getPortal().portal_memcached
connection_dict = _getVolatileMemcachedServerDict()
url_string = 'erp5-memcached-volatile:%(port)s' % connection_dict
self.assertEqual(memcached_tool.default_memcached_plugin.getUrlString(),
url_string)
def testConfiguredPersistentCache(self):
""" Make sure Kumofs is configured
"""
if self.isLiveTest():
# This test is redundant with testConfiguredVolatileCacheViaPromise
# and it is only aims to verify if test environment is behaving as
# expected, nothing else, and if alamrs were invoked.
return
from Products.ERP5Type.tests.ERP5TypeTestCase import\
_getPersistentMemcachedServerDict
memcached_tool = self.getPortal().portal_memcached
connection_dict = _getPersistentMemcachedServerDict()
url_string = 'erp5-memcached-persistent:%(port)s' % connection_dict
self.assertEqual(memcached_tool.persistent_memcached_plugin.getUrlString(),
url_string)
def testConfiguredConversionServer(self):
""" Make sure Conversion Server (Cloudooo) is
well configured """
if self.isLiveTest():
# This test is redundant with testConfiguredConversionServerViaConstraint
# and it is only aims to verify if test environment is behaving as
# expected, nothing else, and if alamrs were invoked.
return
# set preference
preference_tool = self.portal.portal_preferences
conversion_url = "https://cloudooo.erp5.net"
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(), conversion_url)
conversion_url = ["https://cloudooo.erp5.net"]
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrlList(), conversion_url)
def testConfiguredCertificateAuthoring(self):
""" Make sure Certificate Authoting is
......@@ -299,7 +260,6 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
self.assertSameSet(module_list, expected_module_list)
def testConfiguredBusinessTemplateList(self):
""" Make sure Installed business Templates are
what it is expected. """
......
from App.config import getConfiguration
def getConfigurationCloudoooUrl(self):
try:
kw = getConfiguration().product_config['initsite']
except KeyError:
return
return kw.get("cloudooo_url", None)
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Extension Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SlapOSCheckConsistency</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSCheckConsistency</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Extension Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -17,9 +17,6 @@
<item>Reference</item>
<item>Url</item>
</portal_type>
<portal_type id="Memcached Tool">
<item>MemcachedToolServerConstraint</item>
</portal_type>
<portal_type id="OAuth Tool">
<item>OAuthToolDefaultSlapOSConnector</item>
</portal_type>
......
<?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>MemcachedToolServerConstraint</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>kumofs_check_server_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>MemcachedTool_checkKumofsServerConstraint</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>memcached_check_server_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>MemcachedTool_checkMemcachedServerConsistency</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="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>getConfigurationCloudoooUrl</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSCheckConsistency</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getConfigurationCloudoooUrl</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal_memcached = context
# erp5-memcached-persistent is provided by SlapOS, so here we are
# ensuring the site uses real DNS Configuration provided by SlapOS.
# Port and name is hardcoded (unfortunally).
expected_url = "erp5-memcached-persistent:2003"
plugin = portal_memcached.restrictedTraverse("persistent_memcached_plugin", None)
if plugin is None:
return ["portal_memcached/persistent_memcached_plugin wasn't found!"]
url = plugin.getUrlString()
if url != expected_url:
fixing = ''
if fixit:
portal_memcached.persistent_memcached_plugin.edit(url_string=expected_url)
fixing = ' (fixed)'
return ["Kumofs not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url))]
return []
<?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, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MemcachedTool_checkKumofsServerConstraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal_memcached = context
# erp5-memcached-persistent is provided by SlapOS, so here we are
# ensuring the site uses real DNS Configuration provided by SlapOS.
# Port and name is hardcoded (unfortunally).
expected_url = "erp5-memcached-volatile:2013"
plugin = portal_memcached.restrictedTraverse("default_memcached_plugin", None)
if plugin is None:
return ["portal_memcached/default_memcached_plugin wasn't found!"]
url = plugin.getUrlString()
if url != expected_url:
fixing = ''
if fixit:
portal_memcached.default_memcached_plugin.edit(url_string=expected_url)
fixing = ' (fixed)'
return ["Memcached not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url))]
return []
<?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, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MemcachedTool_checkMemcachedServerConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,18 +9,15 @@ if context.getId() == "slapos_default_system_preference" and context.getPreferen
if context.getPreferenceState() != "global":
return []
portal = context.getPortalObject()
system_preference = context
expected_url = portal.ERP5Site_getConfigurationCloudoooUrl()
url = system_preference.getPreferredDocumentConversionServerUrl()
url = context.getPreferredDocumentConversionServerUrlList()
if expected_url != url:
if not url:
fixing = ''
if fixit:
system_preference.setPreferredDocumentConversionServerUrl(expected_url)
fixing = ' (fixed)'
# Set some value if no value is set.
context.setPreferredDocumentConversionServerUrlList(['https://cloudooo1.erp5.net/', 'https://cloudooo.erp5.net/'])
fixing = ' (fixed, set https://cloudooo1.erp5.net/ and https://cloudooo.erp5.net/)'
error_log.append("Conversion Server not configured as expected%s: %s" %
(fixing, "Expect %s\nGot %s" % (expected_url, url)))
error_log.append("Conversion Server is not configured. " % fixing)
return error_log
extension.erp5.SlapOSCheckConsistency
extension.erp5.SlapOSAdministration
extension.erp5.SlapOSLogin
extension.erp5.SlapOSAdministration
\ No newline at end of file
......@@ -6,7 +6,6 @@ Contract Invitation Token | Url
Id Tool | SlapOSModuleIdGeneratorConstraint
Invitation Token | Reference
Invitation Token | Url
Memcached Tool | MemcachedToolServerConstraint
OAuth Tool | OAuthToolDefaultSlapOSConnector
Organisation | GeographicOrganisation
Template Tool | TemplateToolBusinessApplicationModuleCategoryConstraint
......
PreferenceSlapOSConstraintPreference
CertificateAuthorityToolConsistencyConstraint
SlapOSModuleIdGeneratorConstraint
MemcachedToolServerConstraint
GeographicOrganisation
WebSiteModuleShacacheConstraint
ShacacheSystemPreference
OAuthToolDefaultSlapOSConnector
CatalogToolNoneCreationDateConstraint
TemplateToolBusinessApplicationModuleCategoryConstraint
\ No newline at end of file
TemplateToolBusinessApplicationModuleCategoryConstraint
......@@ -30,7 +30,6 @@ import random
import transaction
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyMailHost
from Products.ERP5Type.Utils import convertToUpperCase
import os
import glob
......@@ -131,28 +130,10 @@ class testSlapOSMixin(ERP5TypeTestCase):
# XXX - What is the better way to know if we are in live test mode ?
return not os.environ.has_key('TEST_CA_PATH')
def _setUpDummyMailHost(self):
"""Do not play with NON persistent replacement of MailHost"""
if not self.isLiveTest():
ERP5TypeTestCase._setUpDummyMailHost(self)
def _restoreMailHost(self):
"""Do not play with NON persistent replacement of MailHost"""
if not self.isLiveTest():
ERP5TypeTestCase._restoreMailHost(self)
def beforeTearDown(self):
if self.isLiveTest():
self.deSetUpPersistentDummyMailHost()
if self.abort_transaction:
transaction.abort()
def getUserFolder(self):
"""
Return the user folder
"""
return getattr(self.getPortal(), 'acl_users', None)
def setUpOnce(self):
self.commit()
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
......@@ -160,46 +141,23 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.commit()
self.launchConfigurator()
def updateInitSite(self):
self.portal.portal_caches.updateCache()
try:
initsite = config.product_config["initsite"]
except KeyError:
initsite = {}
if initsite.get("cloudooo_url", None) is None:
initsite["cloudooo_url"] = "https://cloudooo.erp5.net"
config.product_config["initsite"] = initsite
self.commit()
def afterSetUp(self):
self.login()
self.createAlarmStep()
self.portal.email_from_address = 'romain@nexedi.com'
self.portal.email_to_address = 'romain@nexedi.com'
if getattr(self.portal.portal_caches, 'erp5_site_global_id', None):
# we are not on live test so multiple tests can run in parallel
# so ensure that each start tests from scratch
self.portal.portal_caches.erp5_site_global_id = '%s' % random.random()
self.portal.portal_caches._p_changed = 1
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.updateInitSite()
def deSetUpPersistentDummyMailHost(self):
if 'MailHost' in self.portal.objectIds():
self.portal.manage_delObjects(['MailHost'])
self.portal.manage_addProduct['MailHost'].manage_addMailHost('MailHost')
self.commit()
def setUpPersistentDummyMailHost(self):
if 'MailHost' in self.portal.objectIds():
self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost'))
self.portal.email_from_address = 'romain@nexedi.com'
self.portal.email_to_address = 'romain@nexedi.com'
def getBusinessConfiguration(self):
return self.portal.business_configuration_module[\
......@@ -208,7 +166,6 @@ class testSlapOSMixin(ERP5TypeTestCase):
def launchConfigurator(self):
self.logMessage('SlapOS launchConfigurator ...\n')
self.login()
self.updateInitSite()
# Create new Configuration
business_configuration = self.getBusinessConfiguration()
......
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