Commit 65d5d08a authored by Rafael Monnerat's avatar Rafael Monnerat

tests: Fix conflicts on certificate when run parallel tests

parent 4faf1cfa
...@@ -34,6 +34,7 @@ from Products.ERP5Type.tests.utils import DummyMailHost ...@@ -34,6 +34,7 @@ from Products.ERP5Type.tests.utils import DummyMailHost
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
import os import os
import glob import glob
import shutil
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager setSecurityManager
from App.config import getConfiguration from App.config import getConfiguration
...@@ -71,28 +72,46 @@ class testSlapOSMixin(ERP5TypeTestCase): ...@@ -71,28 +72,46 @@ class testSlapOSMixin(ERP5TypeTestCase):
def createCertificateAuthorityFile(self): def createCertificateAuthorityFile(self):
"""Sets up portal_certificate_authority""" """Sets up portal_certificate_authority"""
ca_path = os.path.join(os.environ['TEST_CA_PATH'],
self.__class__.__name__)
if os.path.exists(ca_path):
shutil.rmtree(ca_path)
os.mkdir(ca_path)
os.mkdir(os.path.join(ca_path, 'private'))
os.mkdir(os.path.join(ca_path, 'crl'))
os.mkdir(os.path.join(ca_path, 'certs'))
shutil.copy(os.path.join(os.environ['TEST_CA_PATH'], 'openssl.cnf'),
os.path.join(ca_path, 'openssl.cnf'))
shutil.copy(os.path.join(os.environ['TEST_CA_PATH'], 'cacert.pem'),
os.path.join(ca_path, 'cacert.pem'))
# reset test CA to have it always count from 0 # reset test CA to have it always count from 0
open(os.path.join(os.environ['TEST_CA_PATH'], 'serial'), 'w').write('01') open(os.path.join(ca_path, 'serial'), 'w').write('01')
open(os.path.join(os.environ['TEST_CA_PATH'], 'crlnumber'), 'w').write( open(os.path.join(ca_path, 'crlnumber'), 'w').write('01')
'01') open(os.path.join(ca_path, 'index.txt'), 'w').write('')
open(os.path.join(os.environ['TEST_CA_PATH'], 'index.txt'), 'w').write('') private_list = glob.glob('%s/*.key' % os.path.join(ca_path, 'private'))
private_list = glob.glob('%s/*.key' % os.path.join(os.environ['TEST_CA_PATH'],
'private'))
for private in private_list: for private in private_list:
os.remove(private) os.remove(private)
crl_list = glob.glob('%s/*' % os.path.join(os.environ['TEST_CA_PATH'],
'crl')) crl_list = glob.glob('%s/*' % os.path.join(ca_path, 'crl'))
for crl in crl_list: for crl in crl_list:
os.remove(crl) os.remove(crl)
certs_list = glob.glob('%s/*' % os.path.join(os.environ['TEST_CA_PATH'],
'certs')) certs_list = glob.glob('%s/*' % os.path.join(ca_path, 'certs'))
for cert in certs_list: for cert in certs_list:
os.remove(cert) os.remove(cert)
newcerts_list = glob.glob('%s/*' % os.path.join(os.environ['TEST_CA_PATH'],
'newcerts')) newcerts_list = glob.glob('%s/*' % os.path.join(ca_path, 'newcerts'))
for newcert in newcerts_list: for newcert in newcerts_list:
os.remove(newcert) os.remove(newcert)
self.portal.portal_certificate_authority.manage_editCertificateAuthorityTool(
certificate_authority_path=ca_path)
def setupPortalAlarms(self): def setupPortalAlarms(self):
if not self.portal.portal_alarms.isSubscribed(): if not self.portal.portal_alarms.isSubscribed():
......
...@@ -58,7 +58,3 @@ class SlapOSCloud(SavedTestSuite, ProjectTestSuite): ...@@ -58,7 +58,3 @@ class SlapOSCloud(SavedTestSuite, ProjectTestSuite):
test_list.append(test_case) test_list.append(test_case)
return test_list return test_list
def __init__(self, max_instance_count=1, *args, **kw):
# hardcode number of node, to prevent concurrency issue on certificate
# authority file system storage
super(SlapOSCloud, self).__init__(max_instance_count=1, *args, **kw)
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