summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/unit/applications/lang/go.py6
-rw-r--r--test/unit/applications/lang/java.py7
-rw-r--r--test/unit/applications/lang/node.py9
-rw-r--r--test/unit/applications/lang/perl.py7
-rw-r--r--test/unit/applications/lang/php.py7
-rw-r--r--test/unit/applications/lang/python.py9
-rw-r--r--test/unit/applications/lang/ruby.py7
-rw-r--r--test/unit/applications/proto.py4
-rw-r--r--test/unit/applications/tls.py18
-rw-r--r--test/unit/applications/websockets.py4
-rw-r--r--test/unit/check/chroot.py4
-rw-r--r--test/unit/check/go.py4
-rw-r--r--test/unit/check/isolation.py20
-rw-r--r--test/unit/check/unix_abstract.py4
-rw-r--r--test/unit/control.py4
-rw-r--r--test/unit/http.py2
-rw-r--r--test/unit/option.py3
-rw-r--r--test/unit/status.py4
18 files changed, 66 insertions, 57 deletions
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
index 557753a4..93e0738b 100644
--- a/test/unit/applications/lang/go.py
+++ b/test/unit/applications/lang/go.py
@@ -2,11 +2,11 @@ import os
import shutil
import subprocess
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationGo(TestApplicationProto):
+class ApplicationGo(ApplicationProto):
@staticmethod
def prepare_env(script, name='app', static=False):
try:
@@ -88,7 +88,7 @@ replace unit.nginx.org/go => {replace_path}
executable = f"/go/{name}"
static_build = True
- TestApplicationGo.prepare_env(script, name, static=static_build)
+ ApplicationGo.prepare_env(script, name, static=static_build)
conf = {
"listeners": {"*:7080": {"pass": f"applications/{script}"}},
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index b6382cfe..f6f71b7d 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -4,12 +4,13 @@ import shutil
import subprocess
import pytest
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationJava(TestApplicationProto):
- application_type = "java"
+class ApplicationJava(ApplicationProto):
+ def __init__(self, application_type='java'):
+ self.application_type = application_type
def prepare_env(self, script):
app_path = f'{option.temp_dir}/java'
diff --git a/test/unit/applications/lang/node.py b/test/unit/applications/lang/node.py
index 87d5a19c..4f18c780 100644
--- a/test/unit/applications/lang/node.py
+++ b/test/unit/applications/lang/node.py
@@ -1,14 +1,15 @@
import shutil
from urllib.parse import quote
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
from unit.utils import public_dir
-class TestApplicationNode(TestApplicationProto):
- application_type = "node"
- es_modules = False
+class ApplicationNode(ApplicationProto):
+ def __init__(self, application_type='node', es_modules=False):
+ self.application_type = application_type
+ self.es_modules = es_modules
def prepare_env(self, script):
# copy application
diff --git a/test/unit/applications/lang/perl.py b/test/unit/applications/lang/perl.py
index 19852363..037e98e8 100644
--- a/test/unit/applications/lang/perl.py
+++ b/test/unit/applications/lang/perl.py
@@ -1,9 +1,10 @@
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationPerl(TestApplicationProto):
- application_type = "perl"
+class ApplicationPerl(ApplicationProto):
+ def __init__(self, application_type='perl'):
+ self.application_type = application_type
def load(self, script, name='psgi.pl', **kwargs):
script_path = f'{option.test_dir}/perl/{script}'
diff --git a/test/unit/applications/lang/php.py b/test/unit/applications/lang/php.py
index 1b94c3ae..b9b6dbf1 100644
--- a/test/unit/applications/lang/php.py
+++ b/test/unit/applications/lang/php.py
@@ -1,12 +1,13 @@
import os
import shutil
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationPHP(TestApplicationProto):
- application_type = "php"
+class ApplicationPHP(ApplicationProto):
+ def __init__(self, application_type='php'):
+ self.application_type = application_type
def load(self, script, index='index.php', **kwargs):
script_path = f'{option.test_dir}/php/{script}'
diff --git a/test/unit/applications/lang/python.py b/test/unit/applications/lang/python.py
index 0bb69992..4e1fd897 100644
--- a/test/unit/applications/lang/python.py
+++ b/test/unit/applications/lang/python.py
@@ -2,13 +2,14 @@ import os
import shutil
from urllib.parse import quote
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationPython(TestApplicationProto):
- application_type = "python"
- load_module = "wsgi"
+class ApplicationPython(ApplicationProto):
+ def __init__(self, application_type='python', load_module='wsgi'):
+ self.application_type = application_type
+ self.load_module = load_module
def load(self, script, name=None, module=None, **kwargs):
if name is None:
diff --git a/test/unit/applications/lang/ruby.py b/test/unit/applications/lang/ruby.py
index e0712fc6..f6c4f6c3 100644
--- a/test/unit/applications/lang/ruby.py
+++ b/test/unit/applications/lang/ruby.py
@@ -1,12 +1,13 @@
import shutil
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
from unit.utils import public_dir
-class TestApplicationRuby(TestApplicationProto):
- application_type = "ruby"
+class ApplicationRuby(ApplicationProto):
+ def __init__(self, application_type='ruby'):
+ self.application_type = application_type
def prepare_env(self, script):
shutil.copytree(
diff --git a/test/unit/applications/proto.py b/test/unit/applications/proto.py
index 354c31af..7a1636c6 100644
--- a/test/unit/applications/proto.py
+++ b/test/unit/applications/proto.py
@@ -1,10 +1,10 @@
import os
-from unit.control import TestControl
+from unit.control import Control
from unit.option import option
-class TestApplicationProto(TestControl):
+class ApplicationProto(Control):
application_type = None
def get_application_type(self):
diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py
index e5813312..e9bcc514 100644
--- a/test/unit/applications/tls.py
+++ b/test/unit/applications/tls.py
@@ -2,15 +2,15 @@ import os
import ssl
import subprocess
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
from unit.option import option
-class TestApplicationTLS(TestApplicationProto):
- def setup_method(self):
- self.context = ssl.create_default_context()
- self.context.check_hostname = False
- self.context.verify_mode = ssl.CERT_NONE
+class ApplicationTLS(ApplicationProto):
+ def __init__(self):
+ self._default_context = ssl.create_default_context()
+ self._default_context.check_hostname = False
+ self._default_context.verify_mode = ssl.CERT_NONE
def certificate(self, name='default', load=True):
self.openssl_conf()
@@ -47,10 +47,12 @@ class TestApplicationTLS(TestApplicationProto):
return self.conf(k.read() + c.read(), f'/certificates/{crt}')
def get_ssl(self, **kwargs):
- return self.get(wrapper=self.context.wrap_socket, **kwargs)
+ context = kwargs.get('context', self._default_context)
+ return self.get(wrapper=context.wrap_socket, **kwargs)
def post_ssl(self, **kwargs):
- return self.post(wrapper=self.context.wrap_socket, **kwargs)
+ context = kwargs.get('context', self._default_context)
+ return self.post(wrapper=context.wrap_socket, **kwargs)
def openssl_conf(self, rewrite=False, alt_names=None):
alt_names = alt_names or []
diff --git a/test/unit/applications/websockets.py b/test/unit/applications/websockets.py
index a4b9287d..29725943 100644
--- a/test/unit/applications/websockets.py
+++ b/test/unit/applications/websockets.py
@@ -6,12 +6,12 @@ import select
import struct
import pytest
-from unit.applications.proto import TestApplicationProto
+from unit.applications.proto import ApplicationProto
GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
-class TestApplicationWebsocket(TestApplicationProto):
+class ApplicationWebsocket(ApplicationProto):
OP_CONT = 0x00
OP_TEXT = 0x01
diff --git a/test/unit/check/chroot.py b/test/unit/check/chroot.py
index ac5a91d0..b749fab6 100644
--- a/test/unit/check/chroot.py
+++ b/test/unit/check/chroot.py
@@ -1,9 +1,9 @@
import json
-from unit.http import TestHTTP
+from unit.http import HTTP1
from unit.option import option
-http = TestHTTP()
+http = HTTP1()
def check_chroot():
diff --git a/test/unit/check/go.py b/test/unit/check/go.py
index 469bef1d..1ecd429b 100644
--- a/test/unit/check/go.py
+++ b/test/unit/check/go.py
@@ -1,5 +1,5 @@
-from unit.applications.lang.go import TestApplicationGo
+from unit.applications.lang.go import ApplicationGo
def check_go():
- return TestApplicationGo.prepare_env('empty') is not None
+ return ApplicationGo.prepare_env('empty') is not None
diff --git a/test/unit/check/isolation.py b/test/unit/check/isolation.py
index aaa9b166..e4674f4d 100644
--- a/test/unit/check/isolation.py
+++ b/test/unit/check/isolation.py
@@ -1,16 +1,16 @@
import json
import os
-from unit.applications.lang.go import TestApplicationGo
-from unit.applications.lang.java import TestApplicationJava
-from unit.applications.lang.node import TestApplicationNode
-from unit.applications.lang.ruby import TestApplicationRuby
-from unit.http import TestHTTP
+from unit.applications.lang.go import ApplicationGo
+from unit.applications.lang.java import ApplicationJava
+from unit.applications.lang.node import ApplicationNode
+from unit.applications.lang.ruby import ApplicationRuby
+from unit.http import HTTP1
from unit.option import option
from unit.utils import getns
allns = ['pid', 'mnt', 'ipc', 'uts', 'cgroup', 'net']
-http = TestHTTP()
+http = HTTP1()
def check_isolation():
@@ -18,7 +18,7 @@ def check_isolation():
conf = ''
if 'go' in available['modules']:
- TestApplicationGo().prepare_env('empty', 'app')
+ ApplicationGo().prepare_env('empty', 'app')
conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}},
@@ -64,7 +64,7 @@ def check_isolation():
}
elif 'ruby' in available['modules']:
- TestApplicationRuby().prepare_env('empty')
+ ApplicationRuby().prepare_env('empty')
conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}},
@@ -80,7 +80,7 @@ def check_isolation():
}
elif 'java' in available['modules']:
- TestApplicationJava().prepare_env('empty')
+ ApplicationJava().prepare_env('empty')
conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}},
@@ -97,7 +97,7 @@ def check_isolation():
}
elif 'node' in available['modules']:
- TestApplicationNode().prepare_env('basic')
+ ApplicationNode().prepare_env('basic')
conf = {
"listeners": {"*:7080": {"pass": "applications/basic"}},
diff --git a/test/unit/check/unix_abstract.py b/test/unit/check/unix_abstract.py
index 780e0212..8fc7dd84 100644
--- a/test/unit/check/unix_abstract.py
+++ b/test/unit/check/unix_abstract.py
@@ -1,9 +1,9 @@
import json
-from unit.http import TestHTTP
+from unit.http import HTTP1
from unit.option import option
-http = TestHTTP()
+http = HTTP1()
def check_unix_abstract():
diff --git a/test/unit/control.py b/test/unit/control.py
index 61b6edf4..164d0e60 100644
--- a/test/unit/control.py
+++ b/test/unit/control.py
@@ -1,6 +1,6 @@
import json
-from unit.http import TestHTTP
+from unit.http import HTTP1
from unit.option import option
@@ -29,7 +29,7 @@ def args_handler(conf_func):
return args_wrapper
-class TestControl(TestHTTP):
+class Control(HTTP1):
@args_handler
def conf(self, conf, url):
return self.put(**self._get_args(url, conf))['body']
diff --git a/test/unit/http.py b/test/unit/http.py
index 6a267e26..347382f5 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -10,7 +10,7 @@ import pytest
from unit.option import option
-class TestHTTP:
+class HTTP1:
def http(self, start_str, **kwargs):
sock_type = kwargs.get('sock_type', 'ipv4')
port = kwargs.get('port', 7080)
diff --git a/test/unit/option.py b/test/unit/option.py
index 6bd0c836..ee1f46dd 100644
--- a/test/unit/option.py
+++ b/test/unit/option.py
@@ -1,6 +1,7 @@
import os
import platform
+
class Options:
_options = {
'architecture': platform.architecture()[0],
@@ -8,7 +9,7 @@ class Options:
'is_privileged': os.geteuid() == 0,
'skip_alerts': [],
'skip_sanitizer': False,
- 'system': platform.system()
+ 'system': platform.system(),
}
def __setattr__(self, name, value):
diff --git a/test/unit/status.py b/test/unit/status.py
index 17416f17..84c958a3 100644
--- a/test/unit/status.py
+++ b/test/unit/status.py
@@ -1,9 +1,9 @@
-from unit.control import TestControl
+from unit.control import Control
class Status:
_status = None
- control = TestControl()
+ control = Control()
def _check_zeros():
assert Status.control.conf_get('/status') == {