Tests: address configuration tests reworked.
This commit is contained in:
@@ -8,6 +8,15 @@ from unit.control import TestControl
|
|||||||
class TestConfiguration(TestControl):
|
class TestConfiguration(TestControl):
|
||||||
prerequisites = {'modules': {'python': 'any'}}
|
prerequisites = {'modules': {'python': 'any'}}
|
||||||
|
|
||||||
|
def try_addr(self, addr):
|
||||||
|
return self.conf(
|
||||||
|
{
|
||||||
|
"listeners": {addr: {"pass": "routes"}},
|
||||||
|
"routes": [{"action": {"return": 200}}],
|
||||||
|
"applications": {},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def test_json_empty(self):
|
def test_json_empty(self):
|
||||||
assert 'error' in self.conf(''), 'empty'
|
assert 'error' in self.conf(''), 'empty'
|
||||||
|
|
||||||
@@ -218,50 +227,20 @@ class TestConfiguration(TestControl):
|
|||||||
{"*:7080": {"pass": "applications/app"}}, 'listeners'
|
{"*:7080": {"pass": "applications/app"}}, 'listeners'
|
||||||
), 'listeners no app'
|
), 'listeners no app'
|
||||||
|
|
||||||
def test_listeners_wildcard(self):
|
def test_listeners_addr(self):
|
||||||
assert 'success' in self.conf(
|
assert 'success' in self.try_addr("*:7080"), 'wildcard'
|
||||||
{
|
assert 'success' in self.try_addr("127.0.0.1:7081"), 'explicit'
|
||||||
"listeners": {"*:7080": {"pass": "applications/app"}},
|
assert 'success' in self.try_addr("[::1]:7082"), 'explicit ipv6'
|
||||||
"applications": {
|
|
||||||
"app": {
|
|
||||||
"type": "python",
|
|
||||||
"processes": {"spare": 0},
|
|
||||||
"path": "/app",
|
|
||||||
"module": "wsgi",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
), 'listeners wildcard'
|
|
||||||
|
|
||||||
def test_listeners_explicit(self):
|
def test_listeners_addr_error(self):
|
||||||
assert 'success' in self.conf(
|
assert 'error' in self.try_addr("127.0.0.1"), 'no port'
|
||||||
{
|
|
||||||
"listeners": {"127.0.0.1:7080": {"pass": "applications/app"}},
|
|
||||||
"applications": {
|
|
||||||
"app": {
|
|
||||||
"type": "python",
|
|
||||||
"processes": {"spare": 0},
|
|
||||||
"path": "/app",
|
|
||||||
"module": "wsgi",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
), 'explicit'
|
|
||||||
|
|
||||||
def test_listeners_explicit_ipv6(self):
|
def test_listeners_addr_error_2(self, skip_alert):
|
||||||
assert 'success' in self.conf(
|
skip_alert(r'bind.*failed', r'failed to apply new conf')
|
||||||
{
|
|
||||||
"listeners": {"[::1]:7080": {"pass": "applications/app"}},
|
assert 'error' in self.try_addr(
|
||||||
"applications": {
|
"[f607:7403:1e4b:6c66:33b2:843f:2517:da27]:7080"
|
||||||
"app": {
|
)
|
||||||
"type": "python",
|
|
||||||
"processes": {"spare": 0},
|
|
||||||
"path": "/app",
|
|
||||||
"module": "wsgi",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
), 'explicit ipv6'
|
|
||||||
|
|
||||||
def test_listeners_port_release(self):
|
def test_listeners_port_release(self):
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
@@ -290,22 +269,6 @@ class TestConfiguration(TestControl):
|
|||||||
|
|
||||||
assert 'success' in resp, 'port release'
|
assert 'success' in resp, 'port release'
|
||||||
|
|
||||||
@pytest.mark.skip('not yet, unsafe')
|
|
||||||
def test_listeners_no_port(self):
|
|
||||||
assert 'error' in self.conf(
|
|
||||||
{
|
|
||||||
"listeners": {"127.0.0.1": {"pass": "applications/app"}},
|
|
||||||
"applications": {
|
|
||||||
"app": {
|
|
||||||
"type": "python",
|
|
||||||
"processes": {"spare": 0},
|
|
||||||
"path": "/app",
|
|
||||||
"module": "wsgi",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
), 'no port'
|
|
||||||
|
|
||||||
def test_json_application_name_large(self):
|
def test_json_application_name_large(self):
|
||||||
name = "X" * 1024 * 1024
|
name = "X" * 1024 * 1024
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user