diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2019-07-14 23:49:37 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2019-07-14 23:49:37 +0300 |
commit | b097476824b356bfd025e7afffdc4650bae2b375 (patch) | |
tree | cc7751acb112f390413993b3cb1ecfdde505c2a9 /test/unit/applications/tls.py | |
parent | 72e987e1105822fa10899378d26b2706f04f5515 (diff) | |
download | unit-b097476824b356bfd025e7afffdc4650bae2b375.tar.gz unit-b097476824b356bfd025e7afffdc4650bae2b375.tar.bz2 |
Tests: TestApplicationTLS.openssl_conf() introduced.
Diffstat (limited to 'test/unit/applications/tls.py')
-rw-r--r-- | test/unit/applications/tls.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py index 0f1053bf..6e8deefb 100644 --- a/test/unit/applications/tls.py +++ b/test/unit/applications/tls.py @@ -1,3 +1,4 @@ +import os import ssl import subprocess from unit.applications.proto import TestApplicationProto @@ -12,6 +13,8 @@ class TestApplicationTLS(TestApplicationProto): self.context.verify_mode = ssl.CERT_NONE def certificate(self, name='default', load=True): + self.openssl_conf() + subprocess.call( [ 'openssl', @@ -59,13 +62,13 @@ class TestApplicationTLS(TestApplicationProto): return ssl.get_server_certificate(addr, ssl_version=ssl_version) - def load(self, script, name=None): - if name is None: - name = script + def openssl_conf(self): + conf_path = self.testdir + '/openssl.conf' - # create default openssl configuration + if os.path.exists(conf_path): + return - with open(self.testdir + '/openssl.conf', 'w') as f: + with open(conf_path, 'w') as f: f.write( """[ req ] default_bits = 2048 @@ -74,6 +77,10 @@ distinguished_name = req_distinguished_name [ req_distinguished_name ]""" ) + def load(self, script, name=None): + if name is None: + name = script + script_path = self.current_dir + '/python/' + script self._load_conf( |