Tests: added missing checks for configuration results.

This commit is contained in:
Andrei Zeliankou
2021-01-14 03:04:20 +00:00
parent 5d983ea762
commit d43a84139d
11 changed files with 72 additions and 56 deletions

View File

@@ -90,7 +90,9 @@ Connection: close
def test_access_log_ipv6(self): def test_access_log_ipv6(self):
self.load('empty') self.load('empty')
self.conf({"[::1]:7080": {"pass": "applications/empty"}}, 'listeners') assert 'success' in self.conf(
{"[::1]:7080": {"pass": "applications/empty"}}, 'listeners'
)
self.get(sock_type='ipv6') self.get(sock_type='ipv6')
@@ -106,7 +108,7 @@ Connection: close
addr = option.temp_dir + '/sock' addr = option.temp_dir + '/sock'
self.conf( assert 'success' in self.conf(
{"unix:" + addr: {"pass": "applications/empty"}}, 'listeners' {"unix:" + addr: {"pass": "applications/empty"}}, 'listeners'
) )
@@ -240,7 +242,7 @@ Connection: close
def test_access_log_delete(self): def test_access_log_delete(self):
self.load('empty') self.load('empty')
self.conf_delete('access_log') assert 'success' in self.conf_delete('access_log')
self.get(url='/delete') self.get(url='/delete')
@@ -251,7 +253,9 @@ Connection: close
self.get() self.get()
self.conf('"' + option.temp_dir + '/new.log"', 'access_log') assert 'success' in self.conf(
'"' + option.temp_dir + '/new.log"', 'access_log'
)
self.get() self.get()

View File

@@ -149,7 +149,7 @@ class TestGoApplication(TestApplicationGo):
arg2 = '--cc-opt=\'-O0 -DNXT_DEBUG_MEMORY=1 -fsanitize=address\'' arg2 = '--cc-opt=\'-O0 -DNXT_DEBUG_MEMORY=1 -fsanitize=address\''
arg3 = '--debug' arg3 = '--debug'
self.conf( assert 'success' in self.conf(
'["' + arg1 + '", "' + arg2 + '", "' + arg3 + '"]', '["' + arg1 + '", "' + arg2 + '", "' + arg3 + '"]',
'applications/command_line_arguments/arguments', 'applications/command_line_arguments/arguments',
) )
@@ -163,15 +163,15 @@ class TestGoApplication(TestApplicationGo):
args_path = 'applications/command_line_arguments/arguments' args_path = 'applications/command_line_arguments/arguments'
self.conf('["0", "a", "$", ""]', args_path) assert 'success' in self.conf('["0", "a", "$", ""]', args_path)
assert self.get()['body'] == '0,a,$,', 'arguments' assert self.get()['body'] == '0,a,$,', 'arguments'
self.conf('["-1", "b", "%"]', args_path) assert 'success' in self.conf('["-1", "b", "%"]', args_path)
assert self.get()['body'] == '-1,b,%', 'arguments change' assert self.get()['body'] == '-1,b,%', 'arguments change'
self.conf('[]', args_path) assert 'success' in self.conf('[]', args_path)
assert ( assert (
self.get()['headers']['Content-Length'] == '0' self.get()['headers']['Content-Length'] == '0'

View File

@@ -268,7 +268,7 @@ class TestPHPApplication(TestApplicationPHP):
assert self.get()['headers']['X-Precision'] != '4', 'ini value default' assert self.get()['headers']['X-Precision'] != '4', 'ini value default'
self.conf( assert 'success' in self.conf(
{"file": "ini/php.ini"}, 'applications/ini_precision/options' {"file": "ini/php.ini"}, 'applications/ini_precision/options'
) )
@@ -290,7 +290,7 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_admin(self): def test_php_application_ini_admin(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"file": "php.ini", "admin": {"precision": "5"}}, {"file": "php.ini", "admin": {"precision": "5"}},
'applications/ini_precision/options', 'applications/ini_precision/options',
) )
@@ -300,7 +300,7 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_user(self): def test_php_application_ini_user(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"file": "php.ini", "user": {"precision": "5"}}, {"file": "php.ini", "user": {"precision": "5"}},
'applications/ini_precision/options', 'applications/ini_precision/options',
) )
@@ -310,13 +310,13 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_user_2(self): def test_php_application_ini_user_2(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"file": "ini/php.ini"}, 'applications/ini_precision/options' {"file": "ini/php.ini"}, 'applications/ini_precision/options'
) )
assert self.get()['headers']['X-Precision'] == '4', 'ini user file' assert self.get()['headers']['X-Precision'] == '4', 'ini user file'
self.conf( assert 'success' in self.conf(
{"precision": "5"}, 'applications/ini_precision/options/user' {"precision": "5"}, 'applications/ini_precision/options/user'
) )
@@ -325,7 +325,7 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_set_admin(self): def test_php_application_ini_set_admin(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"admin": {"precision": "5"}}, 'applications/ini_precision/options' {"admin": {"precision": "5"}}, 'applications/ini_precision/options'
) )
@@ -336,7 +336,7 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_set_user(self): def test_php_application_ini_set_user(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"user": {"precision": "5"}}, 'applications/ini_precision/options' {"user": {"precision": "5"}}, 'applications/ini_precision/options'
) )
@@ -347,7 +347,7 @@ class TestPHPApplication(TestApplicationPHP):
def test_php_application_ini_repeat(self): def test_php_application_ini_repeat(self):
self.load('ini_precision') self.load('ini_precision')
self.conf( assert 'success' in self.conf(
{"user": {"precision": "5"}}, 'applications/ini_precision/options' {"user": {"precision": "5"}}, 'applications/ini_precision/options'
) )
@@ -360,7 +360,7 @@ class TestPHPApplication(TestApplicationPHP):
self.before_disable_functions() self.before_disable_functions()
self.conf( assert 'success' in self.conf(
{"admin": {"disable_functions": "exec"}}, {"admin": {"disable_functions": "exec"}},
'applications/time_exec/options', 'applications/time_exec/options',
) )
@@ -375,7 +375,7 @@ class TestPHPApplication(TestApplicationPHP):
self.before_disable_functions() self.before_disable_functions()
self.conf( assert 'success' in self.conf(
{"admin": {"disable_functions": "exec,time"}}, {"admin": {"disable_functions": "exec,time"}},
'applications/time_exec/options', 'applications/time_exec/options',
) )
@@ -452,7 +452,7 @@ class TestPHPApplication(TestApplicationPHP):
self.before_disable_functions() self.before_disable_functions()
self.conf( assert 'success' in self.conf(
{"admin": {"disable_functions": "exec time"}}, {"admin": {"disable_functions": "exec time"}},
'applications/time_exec/options', 'applications/time_exec/options',
) )
@@ -471,7 +471,7 @@ class TestPHPApplication(TestApplicationPHP):
self.before_disable_functions() self.before_disable_functions()
self.conf( assert 'success' in self.conf(
{"user": {"disable_functions": "exec"}}, {"user": {"disable_functions": "exec"}},
'applications/time_exec/options', 'applications/time_exec/options',
) )
@@ -488,7 +488,7 @@ class TestPHPApplication(TestApplicationPHP):
self.before_disable_functions() self.before_disable_functions()
self.conf( assert 'success' in self.conf(
{"admin": {"disable_functions": "blah"}}, {"admin": {"disable_functions": "blah"}},
'applications/time_exec/options', 'applications/time_exec/options',
) )
@@ -509,7 +509,7 @@ class TestPHPApplication(TestApplicationPHP):
r'012345', self.get()['body'] r'012345', self.get()['body']
), 'disable_classes before' ), 'disable_classes before'
self.conf( assert 'success' in self.conf(
{"admin": {"disable_classes": "DateTime"}}, {"admin": {"disable_classes": "DateTime"}},
'applications/date_time/options', 'applications/date_time/options',
) )
@@ -525,7 +525,7 @@ class TestPHPApplication(TestApplicationPHP):
r'012345', self.get()['body'] r'012345', self.get()['body']
), 'disable_classes before' ), 'disable_classes before'
self.conf( assert 'success' in self.conf(
{"user": {"disable_classes": "DateTime"}}, {"user": {"disable_classes": "DateTime"}},
'applications/date_time/options', 'applications/date_time/options',
) )

View File

@@ -19,7 +19,7 @@ class TestPHPBasic(TestControl):
} }
def test_php_get_applications(self): def test_php_get_applications(self):
self.conf(self.conf_app, 'applications') assert 'success' in self.conf(self.conf_app, 'applications')
conf = self.conf_get() conf = self.conf_get()
@@ -55,7 +55,7 @@ class TestPHPBasic(TestControl):
), 'spare processes' ), 'spare processes'
def test_php_get_listeners(self): def test_php_get_listeners(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert self.conf_get()['listeners'] == { assert self.conf_get()['listeners'] == {
"*:7080": {"pass": "applications/app"} "*:7080": {"pass": "applications/app"}
@@ -70,16 +70,20 @@ class TestPHPBasic(TestControl):
}, 'listeners prefix 2' }, 'listeners prefix 2'
def test_php_change_listener(self): def test_php_change_listener(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners') assert 'success' in self.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners'
)
assert self.conf_get('listeners') == { assert self.conf_get('listeners') == {
"*:7081": {"pass": "applications/app"} "*:7081": {"pass": "applications/app"}
}, 'change listener' }, 'change listener'
def test_php_add_listener(self): def test_php_add_listener(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf({"pass": "applications/app"}, 'listeners/*:7082') assert 'success' in self.conf(
{"pass": "applications/app"}, 'listeners/*:7082'
)
assert self.conf_get('listeners') == { assert self.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"}, "*:7080": {"pass": "applications/app"},
@@ -87,20 +91,20 @@ class TestPHPBasic(TestControl):
}, 'add listener' }, 'add listener'
def test_php_change_application(self): def test_php_change_application(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf('30', 'applications/app/processes/max') assert 'success' in self.conf('30', 'applications/app/processes/max')
assert ( assert (
self.conf_get('applications/app/processes/max') == 30 self.conf_get('applications/app/processes/max') == 30
), 'change application max' ), 'change application max'
self.conf('"/www"', 'applications/app/root') assert 'success' in self.conf('"/www"', 'applications/app/root')
assert ( assert (
self.conf_get('applications/app/root') == '/www' self.conf_get('applications/app/root') == '/www'
), 'change application root' ), 'change application root'
def test_php_delete(self): def test_php_delete(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert 'error' in self.conf_delete('applications/app') assert 'error' in self.conf_delete('applications/app')
assert 'success' in self.conf_delete('listeners/*:7080') assert 'success' in self.conf_delete('listeners/*:7080')
@@ -108,7 +112,7 @@ class TestPHPBasic(TestControl):
assert 'error' in self.conf_delete('applications/app') assert 'error' in self.conf_delete('applications/app')
def test_php_delete_blocks(self): def test_php_delete_blocks(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert 'success' in self.conf_delete('listeners') assert 'success' in self.conf_delete('listeners')
assert 'success' in self.conf_delete('applications') assert 'success' in self.conf_delete('applications')

View File

@@ -172,7 +172,9 @@ Content-Length: 10
assert resp['status'] == 200, 'status' assert resp['status'] == 200, 'status'
assert resp['body'] == payload, 'body' assert resp['body'] == payload, 'body'
self.conf({'http': {'max_body_size': 32 * 1024 * 1024}}, 'settings') assert 'success' in self.conf(
{'http': {'max_body_size': 32 * 1024 * 1024}}, 'settings'
)
payload = '0123456789abcdef' * 32 * 64 * 1024 payload = '0123456789abcdef' * 32 * 64 * 1024
resp = self.post_http10(body=payload, read_buffer_size=1024 * 1024) resp = self.post_http10(body=payload, read_buffer_size=1024 * 1024)
@@ -486,7 +488,7 @@ Content-Length: 10
r'accept.*failed', r'accept.*failed',
r'new connections are not accepted', r'new connections are not accepted',
) )
self.conf( assert 'success' in self.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:7080": {"pass": "routes"},

View File

@@ -153,7 +153,7 @@ custom-header: BLAH
assert resp['status'] == 200, 'ctx iter status' assert resp['status'] == 200, 'ctx iter status'
assert resp['body'] == '0123456789', 'ctx iter body' assert resp['body'] == '0123456789', 'ctx iter body'
self.conf({"listeners": {}, "applications": {}}) assert 'success' in self.conf({"listeners": {}, "applications": {}})
assert ( assert (
self.wait_for_record(r'RuntimeError') is not None self.wait_for_record(r'RuntimeError') is not None
@@ -331,7 +331,7 @@ Connection: close
self.get() self.get()
self.conf({"listeners": {}, "applications": {}}) assert 'success' in self.conf({"listeners": {}, "applications": {}})
assert self.wait_for_record(r'At exit called\.') is not None, 'atexit' assert self.wait_for_record(r'At exit called\.') is not None, 'atexit'

View File

@@ -58,7 +58,7 @@ class TestPythonBasic(TestControl):
assert self.conf_get('applications/app/processes/spare') == 0, 'spare' assert self.conf_get('applications/app/processes/spare') == 0, 'spare'
def test_python_get_listeners(self): def test_python_get_listeners(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert self.conf_get()['listeners'] == { assert self.conf_get()['listeners'] == {
"*:7080": {"pass": "applications/app"} "*:7080": {"pass": "applications/app"}
@@ -73,16 +73,20 @@ class TestPythonBasic(TestControl):
}, 'listeners prefix 2' }, 'listeners prefix 2'
def test_python_change_listener(self): def test_python_change_listener(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners') assert 'success' in self.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners'
)
assert self.conf_get('listeners') == { assert self.conf_get('listeners') == {
"*:7081": {"pass": "applications/app"} "*:7081": {"pass": "applications/app"}
}, 'change listener' }, 'change listener'
def test_python_add_listener(self): def test_python_add_listener(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf({"pass": "applications/app"}, 'listeners/*:7082') assert 'success' in self.conf(
{"pass": "applications/app"}, 'listeners/*:7082'
)
assert self.conf_get('listeners') == { assert self.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"}, "*:7080": {"pass": "applications/app"},
@@ -90,20 +94,20 @@ class TestPythonBasic(TestControl):
}, 'add listener' }, 'add listener'
def test_python_change_application(self): def test_python_change_application(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
self.conf('30', 'applications/app/processes/max') assert 'success' in self.conf('30', 'applications/app/processes/max')
assert ( assert (
self.conf_get('applications/app/processes/max') == 30 self.conf_get('applications/app/processes/max') == 30
), 'change application max' ), 'change application max'
self.conf('"/www"', 'applications/app/path') assert 'success' in self.conf('"/www"', 'applications/app/path')
assert ( assert (
self.conf_get('applications/app/path') == '/www' self.conf_get('applications/app/path') == '/www'
), 'change application path' ), 'change application path'
def test_python_delete(self): def test_python_delete(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert 'error' in self.conf_delete('applications/app') assert 'error' in self.conf_delete('applications/app')
assert 'success' in self.conf_delete('listeners/*:7080') assert 'success' in self.conf_delete('listeners/*:7080')
@@ -111,7 +115,7 @@ class TestPythonBasic(TestControl):
assert 'error' in self.conf_delete('applications/app') assert 'error' in self.conf_delete('applications/app')
def test_python_delete_blocks(self): def test_python_delete_blocks(self):
self.conf(self.conf_basic) assert 'success' in self.conf(self.conf_basic)
assert 'success' in self.conf_delete('listeners') assert 'success' in self.conf_delete('listeners')
assert 'success' in self.conf_delete('applications') assert 'success' in self.conf_delete('applications')

View File

@@ -197,6 +197,6 @@ class TestPythonProcman(TestApplicationPython):
), 'max zero' ), 'max zero'
def stop_all(self): def stop_all(self):
self.conf({"listeners": {}, "applications": {}}) assert 'success' in self.conf({"listeners": {}, "applications": {}})
assert len(self.pids_for_process()) == 0, 'stop all' assert len(self.pids_for_process()) == 0, 'stop all'

View File

@@ -316,7 +316,7 @@ class TestRouting(TestApplicationProto):
check_pass_error("%1", "%1") check_pass_error("%1", "%1")
def test_routes_absent(self): def test_routes_absent(self):
self.conf( assert 'success' in self.conf(
{ {
"listeners": {"*:7081": {"pass": "applications/empty"}}, "listeners": {"*:7081": {"pass": "applications/empty"}},
"applications": { "applications": {

View File

@@ -217,7 +217,7 @@ class TestRubyApplication(TestApplicationRuby):
self.get() self.get()
self.conf({"listeners": {}, "applications": {}}) assert 'success' in self.conf({"listeners": {}, "applications": {}})
assert ( assert (
self.wait_for_record(r'\[error\].+At exit called\.') is not None self.wait_for_record(r'\[error\].+At exit called\.') is not None

View File

@@ -19,7 +19,7 @@ class TestTLS(TestApplicationTLS):
return self.date_to_sec_epoch(date, '%b %d %H:%M:%S %Y %Z') return self.date_to_sec_epoch(date, '%b %d %H:%M:%S %Y %Z')
def add_tls(self, application='empty', cert='default', port=7080): def add_tls(self, application='empty', cert='default', port=7080):
self.conf( assert 'success' in self.conf(
{ {
"pass": "applications/" + application, "pass": "applications/" + application,
"tls": {"certificate": cert} "tls": {"certificate": cert}
@@ -28,7 +28,7 @@ class TestTLS(TestApplicationTLS):
) )
def remove_tls(self, application='empty', port=7080): def remove_tls(self, application='empty', port=7080):
self.conf( assert 'success' in self.conf(
{"pass": "applications/" + application}, 'listeners/*:' + str(port) {"pass": "applications/" + application}, 'listeners/*:' + str(port)
) )
@@ -477,8 +477,10 @@ basicConstraints = critical,CA:TRUE"""
read_timeout=1, read_timeout=1,
) )
self.conf({"pass": "applications/empty"}, 'listeners/*:7080') assert 'success' in self.conf(
self.conf_delete('/certificates/default') {"pass": "applications/empty"}, 'listeners/*:7080'
)
assert 'success' in self.conf_delete('/certificates/default')
try: try:
resp = self.get_ssl( resp = self.get_ssl(
@@ -508,7 +510,7 @@ basicConstraints = critical,CA:TRUE"""
self.certificate() self.certificate()
self.conf('1', 'applications/mirror/processes') assert 'success' in self.conf('1', 'applications/mirror/processes')
self.add_tls(application='mirror') self.add_tls(application='mirror')