From d5e915934066c77a59d211efafca10c117b73d05 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 16 Sep 2020 21:31:15 +0100 Subject: Tests: migrated to the pytest. --- test/unit/applications/tls.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test/unit/applications/tls.py') diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py index e6a846b2..5453eef0 100644 --- a/test/unit/applications/tls.py +++ b/test/unit/applications/tls.py @@ -4,19 +4,20 @@ import ssl import subprocess from unit.applications.proto import TestApplicationProto +from conftest import option 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) + def setup_class(cls, complete_check=True): + unit = super().setup_class(complete_check=False) # check tls module @@ -45,9 +46,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 +60,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 +88,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 +106,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( { -- cgit From d491527555c076695a4202577198e12bf0b919ec Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Thu, 1 Oct 2020 10:17:00 +0100 Subject: Tests: minor fixes. Fixed temporary dir removing. Fixed printing path to log. Module checks moved to the separate file. --- test/unit/applications/tls.py | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'test/unit/applications/tls.py') diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py index 5453eef0..7c95f27b 100644 --- a/test/unit/applications/tls.py +++ b/test/unit/applications/tls.py @@ -15,27 +15,6 @@ class TestApplicationTLS(TestApplicationProto): self.context.check_hostname = False self.context.verify_mode = ssl.CERT_NONE - @classmethod - def setup_class(cls, complete_check=True): - unit = super().setup_class(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() -- cgit From 6ec0ff35964c7805712d978625949f72ff5a63bc Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 7 Oct 2020 23:18:43 +0100 Subject: Tests: minor fixes. --- test/unit/applications/tls.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/unit/applications/tls.py') diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py index 7c95f27b..fdf681ae 100644 --- a/test/unit/applications/tls.py +++ b/test/unit/applications/tls.py @@ -1,10 +1,9 @@ import os -import re import ssl import subprocess -from unit.applications.proto import TestApplicationProto from conftest import option +from unit.applications.proto import TestApplicationProto class TestApplicationTLS(TestApplicationProto): -- cgit