summaryrefslogtreecommitdiffhomepage
path: root/test/unit/applications/tls.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/applications/tls.py')
-rw-r--r--test/unit/applications/tls.py41
1 files changed, 10 insertions, 31 deletions
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py
index e6a846b2..fdf681ae 100644
--- a/test/unit/applications/tls.py
+++ b/test/unit/applications/tls.py
@@ -1,40 +1,19 @@
import os
-import re
import ssl
import subprocess
+from conftest import option
from unit.applications.proto import TestApplicationProto
class TestApplicationTLS(TestApplicationProto):
- def __init__(self, test):
- super().__init__(test)
+ def setup_method(self):
+ super().setup_method()
self.context = ssl.create_default_context()
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()
@@ -45,9 +24,9 @@ class TestApplicationTLS(TestApplicationProto):
'-x509',
'-new',
'-subj', '/CN=' + name + '/',
- '-config', self.testdir + '/openssl.conf',
- '-out', self.testdir + '/' + name + '.crt',
- '-keyout', self.testdir + '/' + name + '.key',
+ '-config', self.temp_dir + '/openssl.conf',
+ '-out', self.temp_dir + '/' + name + '.crt',
+ '-keyout', self.temp_dir + '/' + name + '.key',
],
stderr=subprocess.STDOUT,
)
@@ -59,8 +38,8 @@ class TestApplicationTLS(TestApplicationProto):
if key is None:
key = crt
- key_path = self.testdir + '/' + key + '.key'
- crt_path = self.testdir + '/' + crt + '.crt'
+ key_path = self.temp_dir + '/' + key + '.key'
+ crt_path = self.temp_dir + '/' + crt + '.crt'
with open(key_path, 'rb') as k, open(crt_path, 'rb') as c:
return self.conf(k.read() + c.read(), '/certificates/' + crt)
@@ -87,7 +66,7 @@ class TestApplicationTLS(TestApplicationProto):
return ssl.get_server_certificate(addr, ssl_version=ssl_version)
def openssl_conf(self):
- conf_path = self.testdir + '/openssl.conf'
+ conf_path = self.temp_dir + '/openssl.conf'
if os.path.exists(conf_path):
return
@@ -105,7 +84,7 @@ distinguished_name = req_distinguished_name
if name is None:
name = script
- script_path = self.current_dir + '/python/' + script
+ script_path = option.test_dir + '/python/' + script
self._load_conf(
{