Tests: refactored prerequisites model.

This commit is contained in:
Andrey Zelenkov
2019-09-14 14:44:35 +03:00
parent 962cdb6659
commit 65ca2d7b19
24 changed files with 146 additions and 113 deletions

View File

@@ -1,4 +1,5 @@
import os
import re
import ssl
import subprocess
from unit.applications.proto import TestApplicationProto
@@ -12,6 +13,27 @@ class TestApplicationTLS(TestApplicationProto):
self.context.check_hostname = False
self.context.verify_mode = ssl.CERT_NONE
@classmethod
def setUpClass(cls, complete_check=True):
unit = super().setUpClass(complete_check=False)
# check tls module
try:
subprocess.check_output(['which', 'openssl'])
output = subprocess.check_output(
[unit.unitd, '--version'], stderr=subprocess.STDOUT
)
if re.search('--openssl', output.decode()):
cls.available['modules']['openssl'] = []
except:
pass
return unit if not complete_check else unit.complete()
def certificate(self, name='default', load=True):
self.openssl_conf()