Tests: 8XXX used as default port range.

After the launch of the project, the testing infrastructure was shared with
nginx project in some cases.  To avoid port overlap, a decision was made
to shift the port range for Unit tests.  This problem was resolved a long time
ago and is no longer relevant, so it is now safe to use port 8XXX range as the
default, as it is more appropriate for testing purposes.
This commit is contained in:
Andrei Zeliankou
2023-11-08 18:37:02 +00:00
parent 78c133d0ca
commit 0b85fe29f7
101 changed files with 412 additions and 412 deletions

View File

@@ -18,5 +18,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -19,5 +19,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -15,5 +15,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -9,5 +9,5 @@ func handler(w http.ResponseWriter, r *http.Request) {}
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -13,5 +13,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -17,5 +17,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -97,5 +97,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -15,5 +15,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -26,5 +26,5 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
unit.ListenAndServe(":7080", nil) unit.ListenAndServe(":8080", nil)
} }

View File

@@ -3,4 +3,4 @@ var fs = require('fs');
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(404, {}).end(fs.readFileSync('404.html')); res.writeHead(404, {}).end(fs.readFileSync('404.html'));
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
.end('Hello World\n'); .end('Hello World\n');
}).listen(7080); }).listen(8080);

View File

@@ -1,4 +1,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.end().end(); res.end().end();
}).listen(7080); }).listen(8080);

View File

@@ -4,4 +4,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-Header', 'blah'); res.setHeader('X-Header', 'blah');
res.setHeader('X-Names', res.getHeaderNames()); res.setHeader('X-Names', res.getHeaderNames());
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -3,4 +3,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-Number', 100); res.setHeader('X-Number', 100);
res.setHeader('X-Type', typeof(res.getHeader('X-Number'))); res.setHeader('X-Type', typeof(res.getHeader('X-Number')));
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -5,4 +5,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-Var-2', query.var2); res.setHeader('X-Var-2', query.var2);
res.setHeader('X-Var-3', query.var3); res.setHeader('X-Var-3', query.var3);
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.setHeader('X-Has-Header', res.hasHeader(req.headers['x-header']) + ''); res.setHeader('X-Has-Header', res.hasHeader(req.headers['x-header']) + '');
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -4,4 +4,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-header', '2'); res.setHeader('X-header', '2');
res.setHeader('X-HEADER', '3'); res.setHeader('X-HEADER', '3');
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -3,4 +3,4 @@ require('http').createServer(function (req, res) {
res.writeHead(200, {}); res.writeHead(200, {});
res.setHeader('@$', 'test'); res.setHeader('@$', 'test');
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.setHeader('X-Header', {}); res.setHeader('X-Header', {});
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -3,4 +3,4 @@ import http from "http"
http.createServer(function (req, res) { http.createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
.end('Hello World\n'); .end('Hello World\n');
}).listen(7080); }).listen(8080);

View File

@@ -3,4 +3,4 @@ import http from "http"
http.createServer(function (req, res) { http.createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
.end('Hello World\n'); .end('Hello World\n');
}).listen(7080); }).listen(8080);

View File

@@ -4,7 +4,7 @@ import websocket from "websocket"
let server = http.createServer(function() {}); let server = http.createServer(function() {});
let webSocketServer = websocket.server; let webSocketServer = websocket.server;
server.listen(7080, function() {}); server.listen(8080, function() {});
var wsServer = new webSocketServer({ var wsServer = new webSocketServer({
maxReceivedMessageSize: 0x1000000000, maxReceivedMessageSize: 0x1000000000,

View File

@@ -4,7 +4,7 @@ import websocket from "websocket"
let server = http.createServer(function() {}); let server = http.createServer(function() {});
let webSocketServer = websocket.server; let webSocketServer = websocket.server;
server.listen(7080, function() {}); server.listen(8080, function() {});
var wsServer = new webSocketServer({ var wsServer = new webSocketServer({
maxReceivedMessageSize: 0x1000000000, maxReceivedMessageSize: 0x1000000000,

View File

@@ -3,6 +3,6 @@ const http = require("http");
http.createServer(function (req, res) { http.createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
.end('Hello World\n'); .end('Hello World\n');
}).listen(7080); }).listen(8080);
module.exports = http; module.exports = http;

View File

@@ -1,4 +1,4 @@
require("unit-http").createServer(function (req, res) { require("unit-http").createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 12, 'Content-Type': 'text/plain'})
.end('Hello World\n'); .end('Hello World\n');
}).listen(7080); }).listen(8080);

View File

@@ -8,4 +8,4 @@ require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Length': Buffer.byteLength(body)}) res.writeHead(200, {'Content-Length': Buffer.byteLength(body)})
.end(body); .end(body);
}); });
}).listen(7080); }).listen(8080);

View File

@@ -11,4 +11,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-Var-3', query.var3); res.setHeader('X-Var-3', query.var3);
res.end(); res.end();
}); });
}).listen(7080); }).listen(8080);

View File

@@ -12,4 +12,4 @@ require('http').createServer(function (req, res) {
fs.appendFile('callback', '', function() {}); fs.appendFile('callback', '', function() {});
}); });
}).listen(7080); }).listen(8080);

View File

@@ -13,4 +13,4 @@ require('http').createServer(function (req, res) {
fs.appendFile(data.toString(), '', function() {}); fs.appendFile(data.toString(), '', function() {});
}); });
}); });
}).listen(7080); }).listen(8080);

View File

@@ -7,4 +7,4 @@ require('http').createServer(function (req, res) {
res.setHeader('Has-Header', res.hasHeader('X-Header').toString()); res.setHeader('Has-Header', res.hasHeader('X-Header').toString());
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.setHeader('Set-Cookie', ['tc=one,two,three', 'tc=four,five,six']); res.setHeader('Set-Cookie', ['tc=one,two,three', 'tc=four,five,six']);
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -1,4 +1,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(200, 'blah', {'Content-Type': 'text/plain'}).end(); res.writeHead(200, 'blah', {'Content-Type': 'text/plain'}).end();
}).listen(7080); }).listen(8080);

View File

@@ -3,4 +3,4 @@ require('http').createServer(function (req, res) {
res.setHeader('X-Header', 'test'); res.setHeader('X-Header', 'test');
res.setHeader('X-Header', 'new'); res.setHeader('X-Header', 'new');
res.end(); res.end();
}).listen(7080); }).listen(8080);

View File

@@ -15,4 +15,4 @@ require('http').createServer(function (req, res) {
res.setHeader('Http-Host', req.headers['host']); res.setHeader('Http-Host', req.headers['host']);
res.writeHead(200, {}).end(body); res.writeHead(200, {}).end(body);
}); });
}).listen(7080); }).listen(8080);

View File

@@ -2,7 +2,7 @@
server = require('http').createServer(function() {}); server = require('http').createServer(function() {});
webSocketServer = require('websocket').server; webSocketServer = require('websocket').server;
server.listen(7080, function() {}); server.listen(8080, function() {});
var wsServer = new webSocketServer({ var wsServer = new webSocketServer({
maxReceivedMessageSize: 0x1000000000, maxReceivedMessageSize: 0x1000000000,

View File

@@ -2,7 +2,7 @@
server = require('http').createServer(function() {}); server = require('http').createServer(function() {});
webSocketServer = require('websocket').server; webSocketServer = require('websocket').server;
server.listen(7080, function() {}); server.listen(8080, function() {});
var wsServer = new webSocketServer({ var wsServer = new webSocketServer({
httpServer: server httpServer: server

View File

@@ -1,4 +1,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Length': 5, 'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Length': 5, 'Content-Type': 'text/plain'})
.end(new Uint8Array(Buffer.from('array', 'utf8'))); .end(new Uint8Array(Buffer.from('array', 'utf8')));
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.write('blah'); res.write('blah');
res.writeHead(200, {'Content-Type': 'text/plain'}).end(); res.writeHead(200, {'Content-Type': 'text/plain'}).end();
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Type': 'text/plain'})
.end(Buffer.from('buffer', 'utf8')); .end(Buffer.from('buffer', 'utf8'));
}).listen(7080); }).listen(8080);

View File

@@ -9,4 +9,4 @@ require('http').createServer(function (req, res) {
fs.appendFile('callback', '', function() {}); fs.appendFile('callback', '', function() {});
}); });
res.end(a); res.end(a);
}).listen(7080); }).listen(8080);

View File

@@ -4,4 +4,4 @@ require('http').createServer(function (req, res) {
res.write('write'); res.write('write');
res.write('write2'); res.write('write2');
res.end('end'); res.end('end');
}).listen(7080); }).listen(8080);

View File

@@ -2,4 +2,4 @@
require('http').createServer(function (req, res) { require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'}) res.writeHead(200, {'Content-Type': 'text/plain'})
.end(res.write('body').toString()); .end(res.write('body').toString());
}).listen(7080); }).listen(8080);

View File

@@ -93,7 +93,7 @@ def test_access_log_ipv6(wait_for_record):
load('empty') load('empty')
assert 'success' in client.conf( assert 'success' in client.conf(
{"[::1]:7080": {"pass": "applications/empty"}}, 'listeners' {"[::1]:8080": {"pass": "applications/empty"}}, 'listeners'
) )
client.get(sock_type='ipv6') client.get(sock_type='ipv6')

View File

@@ -60,7 +60,7 @@ def test_asgi_application_ipv6():
client.load('empty') client.load('empty')
assert 'success' in client.conf( assert 'success' in client.conf(
{"[::1]:7080": {"pass": "applications/empty"}}, 'listeners' {"[::1]:8080": {"pass": "applications/empty"}}, 'listeners'
) )
assert client.get(sock_type='ipv6')['status'] == 200 assert client.get(sock_type='ipv6')['status'] == 200
@@ -172,7 +172,7 @@ def test_asgi_application_server_port():
client.load('server_port') client.load('server_port')
assert ( assert (
client.get()['headers']['Server-Port'] == '7080' client.get()['headers']['Server-Port'] == '8080'
), 'Server-Port header' ), 'Server-Port header'

View File

@@ -59,7 +59,7 @@ def test_asgi_lifespan_targets():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/1"}, "match": {"uri": "/1"},

View File

@@ -16,7 +16,7 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/1"}, "match": {"uri": "/1"},

View File

@@ -15,11 +15,11 @@ def setup_method_fixture():
def client_ip(options): def client_ip(options):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"client_ip": options, "client_ip": options,
"pass": "applications/client_ip", "pass": "applications/client_ip",
}, },
"[::1]:7082": { "[::1]:8082": {
"client_ip": options, "client_ip": options,
"pass": "applications/client_ip", "pass": "applications/client_ip",
}, },
@@ -34,8 +34,8 @@ def client_ip(options):
def get_xff(xff, sock_type='ipv4'): def get_xff(xff, sock_type='ipv4'):
address = { address = {
'ipv4': ('127.0.0.1', 7081), 'ipv4': ('127.0.0.1', 8081),
'ipv6': ('::1', 7082), 'ipv6': ('::1', 8082),
'unix': (f'{option.temp_dir}/sock', None), 'unix': (f'{option.temp_dir}/sock', None),
} }
(addr, port) = address[sock_type] (addr, port) = address[sock_type]
@@ -51,9 +51,9 @@ def get_xff(xff, sock_type='ipv4'):
def test_client_ip_single_ip(): def test_client_ip_single_ip():
client_ip({'header': 'X-Forwarded-For', 'source': '123.123.123.123'}) client_ip({'header': 'X-Forwarded-For', 'source': '123.123.123.123'})
assert client.get(port=7081)['body'] == '127.0.0.1', 'ipv4 default' assert client.get(port=8081)['body'] == '127.0.0.1', 'ipv4 default'
assert ( assert (
client.get(sock_type='ipv6', port=7082)['body'] == '::1' client.get(sock_type='ipv6', port=8082)['body'] == '::1'
), 'ipv6 default' ), 'ipv6 default'
assert get_xff('1.1.1.1') == '127.0.0.1', 'bad source' assert get_xff('1.1.1.1') == '127.0.0.1', 'bad source'
assert get_xff('blah') == '127.0.0.1', 'bad header' assert get_xff('blah') == '127.0.0.1', 'bad header'
@@ -61,9 +61,9 @@ def test_client_ip_single_ip():
client_ip({'header': 'X-Forwarded-For', 'source': '127.0.0.1'}) client_ip({'header': 'X-Forwarded-For', 'source': '127.0.0.1'})
assert client.get(port=7081)['body'] == '127.0.0.1', 'ipv4 default 2' assert client.get(port=8081)['body'] == '127.0.0.1', 'ipv4 default 2'
assert ( assert (
client.get(sock_type='ipv6', port=7082)['body'] == '::1' client.get(sock_type='ipv6', port=8082)['body'] == '::1'
), 'ipv6 default 2' ), 'ipv6 default 2'
assert get_xff('1.1.1.1') == '1.1.1.1', 'replace' assert get_xff('1.1.1.1') == '1.1.1.1', 'replace'
assert get_xff('blah') == '127.0.0.1', 'bad header 2' assert get_xff('blah') == '127.0.0.1', 'bad header 2'
@@ -159,7 +159,7 @@ def test_client_ip_empty_source():
def test_client_ip_invalid(): def test_client_ip_invalid():
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"client_ip": {"source": '127.0.0.1'}, "client_ip": {"source": '127.0.0.1'},
"pass": "applications/client_ip", "pass": "applications/client_ip",
} }
@@ -170,7 +170,7 @@ def test_client_ip_invalid():
def check_invalid_source(source): def check_invalid_source(source):
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"client_ip": { "client_ip": {
"header": "X-Forwarded-For", "header": "X-Forwarded-For",
"source": source, "source": source,

View File

@@ -234,12 +234,12 @@ def test_applications_relative_path():
@pytest.mark.skip('not yet, unsafe') @pytest.mark.skip('not yet, unsafe')
def test_listeners_empty(): def test_listeners_empty():
assert 'error' in client.conf({"*:7080": {}}, 'listeners'), 'listener empty' assert 'error' in client.conf({"*:8080": {}}, 'listeners'), 'listener empty'
def test_listeners_no_app(): def test_listeners_no_app():
assert 'error' in client.conf( assert 'error' in client.conf(
{"*:7080": {"pass": "applications/app"}}, 'listeners' {"*:8080": {"pass": "applications/app"}}, 'listeners'
), 'listeners no app' ), 'listeners no app'
@@ -254,9 +254,9 @@ def test_listeners_unix_abstract(system):
def test_listeners_addr(): def test_listeners_addr():
assert 'success' in try_addr("*:7080"), 'wildcard' assert 'success' in try_addr("*:8080"), 'wildcard'
assert 'success' in try_addr("127.0.0.1:7081"), 'explicit' assert 'success' in try_addr("127.0.0.1:8081"), 'explicit'
assert 'success' in try_addr("[::1]:7082"), 'explicit ipv6' assert 'success' in try_addr("[::1]:8082"), 'explicit ipv6'
def test_listeners_addr_error(): def test_listeners_addr_error():
@@ -266,7 +266,7 @@ def test_listeners_addr_error():
def test_listeners_addr_error_2(skip_alert): def test_listeners_addr_error_2(skip_alert):
skip_alert(r'bind.*failed', r'failed to apply new conf') skip_alert(r'bind.*failed', r'failed to apply new conf')
assert 'error' in try_addr("[f607:7403:1e4b:6c66:33b2:843f:2517:da27]:7080") assert 'error' in try_addr("[f607:7403:1e4b:6c66:33b2:843f:2517:da27]:8080")
def test_listeners_port_release(): def test_listeners_port_release():
@@ -277,7 +277,7 @@ def test_listeners_port_release():
client.conf( client.conf(
{ {
"listeners": {"127.0.0.1:7080": {"pass": "routes"}}, "listeners": {"127.0.0.1:8080": {"pass": "routes"}},
"routes": [], "routes": [],
} }
) )
@@ -285,7 +285,7 @@ def test_listeners_port_release():
resp = client.conf({"listeners": {}, "applications": {}}) resp = client.conf({"listeners": {}, "applications": {}})
try: try:
s.bind(('127.0.0.1', 7080)) s.bind(('127.0.0.1', 8080))
s.listen() s.listen()
except OSError: except OSError:
@@ -302,7 +302,7 @@ def test_json_application_name_large():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{name}"}}, "listeners": {"*:8080": {"pass": f"applications/{name}"}},
"applications": { "applications": {
name: { name: {
"type": "python", "type": "python",
@@ -349,7 +349,7 @@ def test_json_application_python_prefix():
"prefix": "/app", "prefix": "/app",
} }
}, },
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/app/*"}, "match": {"uri": "/app/*"},
@@ -378,7 +378,7 @@ def test_json_application_prefix_target():
}, },
} }
}, },
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/app/*"}, "match": {"uri": "/app/*"},
@@ -405,7 +405,7 @@ def test_json_application_invalid_python_prefix():
"prefix": "app", "prefix": "app",
} }
}, },
"listeners": {"*:7080": {"pass": "applications/sub-app"}}, "listeners": {"*:8080": {"pass": "applications/sub-app"}},
} }
assert 'error' in client.conf(conf) assert 'error' in client.conf(conf)
@@ -422,7 +422,7 @@ def test_json_application_empty_python_prefix():
"prefix": "", "prefix": "",
} }
}, },
"listeners": {"*:7080": {"pass": "applications/sub-app"}}, "listeners": {"*:8080": {"pass": "applications/sub-app"}},
} }
assert 'error' in client.conf(conf) assert 'error' in client.conf(conf)
@@ -441,7 +441,7 @@ def test_json_application_many2():
# open files limit due to the lack of file descriptors. # open files limit due to the lack of file descriptors.
for a in range(100) for a in range(100)
}, },
"listeners": {"*:7080": {"pass": "applications/app-1"}}, "listeners": {"*:8080": {"pass": "applications/app-1"}},
} }
assert 'success' in client.conf(conf) assert 'success' in client.conf(conf)

View File

@@ -14,11 +14,11 @@ def setup_method_fixture():
def forwarded_header(forwarded): def forwarded_header(forwarded):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"forwarded": forwarded, "forwarded": forwarded,
"pass": "applications/forwarded_header", "pass": "applications/forwarded_header",
}, },
"[::1]:7082": { "[::1]:8082": {
"forwarded": forwarded, "forwarded": forwarded,
"pass": "applications/forwarded_header", "pass": "applications/forwarded_header",
}, },
@@ -28,7 +28,7 @@ def forwarded_header(forwarded):
def get_fwd(sock_type='ipv4', xff=None, xfp=None): def get_fwd(sock_type='ipv4', xff=None, xfp=None):
port = 7081 if sock_type == 'ipv4' else 7082 port = 8081 if sock_type == 'ipv4' else 8082
headers = {'Connection': 'close'} headers = {'Connection': 'close'}
@@ -243,7 +243,7 @@ def test_forwarded_header_source_range():
def test_forwarded_header_invalid(): def test_forwarded_header_invalid():
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"forwarded": {"source": '127.0.0.1'}, "forwarded": {"source": '127.0.0.1'},
"pass": "applications/forwarded_header", "pass": "applications/forwarded_header",
} }
@@ -254,7 +254,7 @@ def test_forwarded_header_invalid():
def check_invalid_source(source): def check_invalid_source(source):
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"127.0.0.1:7081": { "127.0.0.1:8081": {
"forwarded": { "forwarded": {
"client_ip": "X-Forwarded-For", "client_ip": "X-Forwarded-For",
"source": source, "source": source,

View File

@@ -333,7 +333,7 @@ def test_http_header_host_port():
client.load('host') client.load('host')
resp = client.get( resp = client.get(
headers={'Host': 'exmaple.com:7080', 'Connection': 'close'} headers={'Host': 'exmaple.com:8080', 'Connection': 'close'}
) )
assert resp['status'] == 200, 'Host port status' assert resp['status'] == 200, 'Host port status'
@@ -341,7 +341,7 @@ def test_http_header_host_port():
resp['headers']['X-Server-Name'] == 'exmaple.com' resp['headers']['X-Server-Name'] == 'exmaple.com'
), 'Host port SERVER_NAME' ), 'Host port SERVER_NAME'
assert ( assert (
resp['headers']['X-Http-Host'] == 'exmaple.com:7080' resp['headers']['X-Http-Host'] == 'exmaple.com:8080'
), 'Host port HTTP_HOST' ), 'Host port HTTP_HOST'
@@ -373,14 +373,14 @@ def test_http_header_host_literal():
def test_http_header_host_literal_ipv6(): def test_http_header_host_literal_ipv6():
client.load('host') client.load('host')
resp = client.get(headers={'Host': '[::1]:7080', 'Connection': 'close'}) resp = client.get(headers={'Host': '[::1]:8080', 'Connection': 'close'})
assert resp['status'] == 200, 'Host literal ipv6 status' assert resp['status'] == 200, 'Host literal ipv6 status'
assert ( assert (
resp['headers']['X-Server-Name'] == '[::1]' resp['headers']['X-Server-Name'] == '[::1]'
), 'Host literal ipv6 SERVER_NAME' ), 'Host literal ipv6 SERVER_NAME'
assert ( assert (
resp['headers']['X-Http-Host'] == '[::1]:7080' resp['headers']['X-Http-Host'] == '[::1]:8080'
), 'Host literal ipv6 HTTP_HOST' ), 'Host literal ipv6 HTTP_HOST'

View File

@@ -20,7 +20,7 @@ def test_java_conf_error(temp_dir, skip_alert):
) )
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/app"}}, "listeners": {"*:8080": {"pass": "applications/app"}},
"applications": { "applications": {
"app": { "app": {
"type": client.get_application_type(), "type": client.get_application_type(),

View File

@@ -14,7 +14,7 @@ client = ApplicationProto()
def setup_method_fixture(temp_dir): def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f"{temp_dir}/assets$uri"}}], "routes": [{"action": {"share": f"{temp_dir}/assets$uri"}}],
} }
) )

View File

@@ -23,7 +23,7 @@ def test_njs_modules():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"settings": {"js_module": "next"}, "settings": {"js_module": "next"},
"listeners": {"*:7080": {"pass": "routes/first"}}, "listeners": {"*:8080": {"pass": "routes/first"}},
"routes": { "routes": {
"first": [{"action": {"pass": "`routes/${next.route()}`"}}], "first": [{"action": {"pass": "`routes/${next.route()}`"}}],
"next": [{"action": {"return": 200}}], "next": [{"action": {"return": 200}}],
@@ -68,7 +68,7 @@ def test_njs_modules_import():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"settings": {"js_module": "import_from"}, "settings": {"js_module": "import_from"},
"listeners": {"*:7080": {"pass": "routes/first"}}, "listeners": {"*:8080": {"pass": "routes/first"}},
"routes": { "routes": {
"first": [ "first": [
{"action": {"pass": "`routes/${import_from.num()}`"}} {"action": {"pass": "`routes/${import_from.num()}`"}}
@@ -86,7 +86,7 @@ def test_njs_modules_this():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"settings": {"js_module": "global_this"}, "settings": {"js_module": "global_this"},
"listeners": {"*:7080": {"pass": "routes/first"}}, "listeners": {"*:8080": {"pass": "routes/first"}},
"routes": { "routes": {
"first": [ "first": [
{"action": {"pass": "`routes/${global_this.str()}`"}} {"action": {"pass": "`routes/${global_this.str()}`"}}

View File

@@ -88,7 +88,7 @@ def test_perl_application_server_port():
client.load('server_port') client.load('server_port')
assert ( assert (
client.get()['headers']['Server-Port'] == '7080' client.get()['headers']['Server-Port'] == '8080'
), 'Server-Port header' ), 'Server-Port header'

View File

@@ -174,7 +174,7 @@ def test_php_application_query_string_empty():
def test_php_application_query_string_rewrite(): def test_php_application_query_string_rewrite():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {
@@ -678,7 +678,7 @@ def test_php_application_error_log(findall, wait_for_record):
def test_php_application_script(): def test_php_application_script():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/script"}}, "listeners": {"*:8080": {"pass": "applications/script"}},
"applications": { "applications": {
"script": { "script": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -699,7 +699,7 @@ def test_php_application_script():
def test_php_application_index_default(): def test_php_application_index_default():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/phpinfo"}}, "listeners": {"*:8080": {"pass": "applications/phpinfo"}},
"applications": { "applications": {
"phpinfo": { "phpinfo": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -727,7 +727,7 @@ def test_php_application_trailing_slash(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "applications/php-path"}, "*:8080": {"pass": "applications/php-path"},
f'unix:{addr}': {"pass": "applications/php-path"}, f'unix:{addr}': {"pass": "applications/php-path"},
}, },
"applications": { "applications": {
@@ -745,7 +745,7 @@ def test_php_application_trailing_slash(temp_dir):
resp = client.get(url='/path?q=a') resp = client.get(url='/path?q=a')
assert resp['status'] == 301, 'uri without trailing /' assert resp['status'] == 301, 'uri without trailing /'
assert ( assert (
resp['headers']['Location'] == 'http://localhost:7080/path/?q=a' resp['headers']['Location'] == 'http://localhost:8080/path/?q=a'
), 'Location with query string' ), 'Location with query string'
resp = client.get( resp = client.get(
@@ -767,7 +767,7 @@ def test_php_application_forbidden(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/php-path"}}, "listeners": {"*:8080": {"pass": "applications/php-path"}},
"applications": { "applications": {
"php-path": { "php-path": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -792,7 +792,7 @@ def test_php_application_extension_check(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/phpinfo"}}, "listeners": {"*:8080": {"pass": "applications/phpinfo"}},
"applications": { "applications": {
"phpinfo": { "phpinfo": {
"type": client.get_application_type(), "type": client.get_application_type(),

View File

@@ -14,7 +14,7 @@ conf_app = {
} }
conf_basic = { conf_basic = {
"listeners": {"*:7080": {"pass": "applications/app"}}, "listeners": {"*:8080": {"pass": "applications/app"}},
"applications": conf_app, "applications": conf_app,
} }
@@ -60,14 +60,14 @@ def test_php_get_listeners():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert client.conf_get()['listeners'] == { assert client.conf_get()['listeners'] == {
"*:7080": {"pass": "applications/app"} "*:8080": {"pass": "applications/app"}
}, 'listeners' }, 'listeners'
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"} "*:8080": {"pass": "applications/app"}
}, 'listeners prefix' }, 'listeners prefix'
assert client.conf_get('listeners/*:7080') == { assert client.conf_get('listeners/*:8080') == {
"pass": "applications/app" "pass": "applications/app"
}, 'listeners prefix 2' }, 'listeners prefix 2'
@@ -75,23 +75,23 @@ def test_php_get_listeners():
def test_php_change_listener(): def test_php_change_listener():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'success' in client.conf( assert 'success' in client.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners' {"*:8081": {"pass": "applications/app"}}, 'listeners'
) )
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7081": {"pass": "applications/app"} "*:8081": {"pass": "applications/app"}
}, 'change listener' }, 'change listener'
def test_php_add_listener(): def test_php_add_listener():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/app"}, 'listeners/*:7082' {"pass": "applications/app"}, 'listeners/*:8082'
) )
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"}, "*:8080": {"pass": "applications/app"},
"*:7082": {"pass": "applications/app"}, "*:8082": {"pass": "applications/app"},
}, 'add listener' }, 'add listener'
@@ -113,7 +113,7 @@ def test_php_delete():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'error' in client.conf_delete('applications/app') assert 'error' in client.conf_delete('applications/app')
assert 'success' in client.conf_delete('listeners/*:7080') assert 'success' in client.conf_delete('listeners/*:8080')
assert 'success' in client.conf_delete('applications/app') assert 'success' in client.conf_delete('applications/app')
assert 'error' in client.conf_delete('applications/app') assert 'error' in client.conf_delete('applications/app')
@@ -126,5 +126,5 @@ def test_php_delete_blocks():
assert 'success' in client.conf(conf_app, 'applications') assert 'success' in client.conf(conf_app, 'applications')
assert 'success' in client.conf( assert 'success' in client.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners' {"*:8081": {"pass": "applications/app"}}, 'listeners'
), 'applications restore' ), 'applications restore'

View File

@@ -10,7 +10,7 @@ def test_php_application_targets():
targets_dir = f"{option.test_dir}/php/targets" targets_dir = f"{option.test_dir}/php/targets"
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/1"}, "match": {"uri": "/1"},
@@ -65,7 +65,7 @@ def test_php_application_targets():
def test_php_application_targets_error(): def test_php_application_targets_error():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/targets/default"}}, "listeners": {"*:8080": {"pass": "applications/targets/default"}},
"applications": { "applications": {
"targets": { "targets": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -83,7 +83,7 @@ def test_php_application_targets_error():
assert client.get()['status'] == 200 assert client.get()['status'] == 200
assert 'error' in client.conf( assert 'error' in client.conf(
{"pass": "applications/targets/blah"}, 'listeners/*:7080' {"pass": "applications/targets/blah"}, 'listeners/*:8080'
), 'invalid targets pass' ), 'invalid targets pass'
assert 'error' in client.conf( assert 'error' in client.conf(
f'"{option.test_dir}/php/targets"', f'"{option.test_dir}/php/targets"',

View File

@@ -23,10 +23,10 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/mirror"}, "*:8081": {"pass": "applications/mirror"},
}, },
"routes": [{"action": {"proxy": "http://127.0.0.1:7081"}}], "routes": [{"action": {"proxy": "http://127.0.0.1:8081"}}],
"applications": { "applications": {
"mirror": { "mirror": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -110,19 +110,19 @@ def test_proxy_chain():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes/first"}, "*:8080": {"pass": "routes/first"},
"*:7081": {"pass": "routes/second"}, "*:8081": {"pass": "routes/second"},
"*:7082": {"pass": "routes/third"}, "*:8082": {"pass": "routes/third"},
"*:7083": {"pass": "routes/fourth"}, "*:8083": {"pass": "routes/fourth"},
"*:7084": {"pass": "routes/fifth"}, "*:8084": {"pass": "routes/fifth"},
"*:7085": {"pass": "applications/mirror"}, "*:8085": {"pass": "applications/mirror"},
}, },
"routes": { "routes": {
"first": [{"action": {"proxy": "http://127.0.0.1:7081"}}], "first": [{"action": {"proxy": "http://127.0.0.1:8081"}}],
"second": [{"action": {"proxy": "http://127.0.0.1:7082"}}], "second": [{"action": {"proxy": "http://127.0.0.1:8082"}}],
"third": [{"action": {"proxy": "http://127.0.0.1:7083"}}], "third": [{"action": {"proxy": "http://127.0.0.1:8083"}}],
"fourth": [{"action": {"proxy": "http://127.0.0.1:7084"}}], "fourth": [{"action": {"proxy": "http://127.0.0.1:8084"}}],
"fifth": [{"action": {"proxy": "http://127.0.0.1:7085"}}], "fifth": [{"action": {"proxy": "http://127.0.0.1:8085"}}],
}, },
"applications": { "applications": {
"mirror": { "mirror": {
@@ -210,7 +210,7 @@ def test_proxy_parallel():
def test_proxy_header(): def test_proxy_header():
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/custom_header"}, 'listeners/*:7081' {"pass": "applications/custom_header"}, 'listeners/*:8081'
), 'custom_header configure' ), 'custom_header configure'
header_value = 'blah' header_value = 'blah'
@@ -325,7 +325,7 @@ def test_proxy_fragmented_body_close():
def test_proxy_nowhere(): def test_proxy_nowhere():
assert 'success' in client.conf( assert 'success' in client.conf(
[{"action": {"proxy": "http://127.0.0.1:7082"}}], 'routes' [{"action": {"proxy": "http://127.0.0.1:8082"}}], 'routes'
), 'proxy path changed' ), 'proxy path changed'
assert get_http10()['status'] == 502, 'status' assert get_http10()['status'] == 502, 'status'
@@ -334,14 +334,14 @@ def test_proxy_nowhere():
def test_proxy_ipv6(): def test_proxy_ipv6():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"[::1]:7081": {'application': 'mirror'}, "[::1]:8081": {'application': 'mirror'},
}, },
'listeners', 'listeners',
), 'add ipv6 listener configure' ), 'add ipv6 listener configure'
assert 'success' in client.conf( assert 'success' in client.conf(
[{"action": {"proxy": "http://[::1]:7081"}}], 'routes' [{"action": {"proxy": "http://[::1]:8081"}}], 'routes'
), 'proxy ipv6 configure' ), 'proxy ipv6 configure'
assert get_http10()['status'] == 200, 'status' assert get_http10()['status'] == 200, 'status'
@@ -352,7 +352,7 @@ def test_proxy_unix(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
f'unix:{addr}': {'application': 'mirror'}, f'unix:{addr}': {'application': 'mirror'},
}, },
'listeners', 'listeners',
@@ -367,7 +367,7 @@ def test_proxy_unix(temp_dir):
def test_proxy_delayed(): def test_proxy_delayed():
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/delayed"}, 'listeners/*:7081' {"pass": "applications/delayed"}, 'listeners/*:8081'
), 'delayed configure' ), 'delayed configure'
body = '0123456789' * 1000 body = '0123456789' * 1000
@@ -400,7 +400,7 @@ def test_proxy_delayed():
def test_proxy_delayed_close(): def test_proxy_delayed_close():
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/delayed"}, 'listeners/*:7081' {"pass": "applications/delayed"}, 'listeners/*:8081'
), 'delayed configure' ), 'delayed configure'
sock = post_http10( sock = post_http10(
@@ -469,11 +469,11 @@ def test_proxy_invalid():
check_proxy('http://127.0.0.1:') check_proxy('http://127.0.0.1:')
check_proxy('http://127.0.0.1:blah') check_proxy('http://127.0.0.1:blah')
check_proxy('http://127.0.0.1:-1') check_proxy('http://127.0.0.1:-1')
check_proxy('http://127.0.0.1:7080b') check_proxy('http://127.0.0.1:8080b')
check_proxy('http://[]') check_proxy('http://[]')
check_proxy('http://[]:7080') check_proxy('http://[]:8080')
check_proxy('http://[:]:7080') check_proxy('http://[:]:8080')
check_proxy('http://[::7080') check_proxy('http://[::8080')
@pytest.mark.skip('not yet') @pytest.mark.skip('not yet')
@@ -486,11 +486,11 @@ def test_proxy_loop(skip_alert):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/mirror"}, "*:8081": {"pass": "applications/mirror"},
"*:7082": {"pass": "routes"}, "*:8082": {"pass": "routes"},
}, },
"routes": [{"action": {"proxy": "http://127.0.0.1:7082"}}], "routes": [{"action": {"proxy": "http://127.0.0.1:8082"}}],
"applications": { "applications": {
"mirror": { "mirror": {
"type": client.get_application_type(), "type": client.get_application_type(),

View File

@@ -22,7 +22,7 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
}, },
"routes": [ "routes": [
{"action": {"proxy": f'http://127.0.0.1:{SERVER_PORT}'}} {"action": {"proxy": f'http://127.0.0.1:{SERVER_PORT}'}}

View File

@@ -160,7 +160,7 @@ def test_python_application_server_port():
client.load('server_port') client.load('server_port')
assert ( assert (
client.get()['headers']['Server-Port'] == '7080' client.get()['headers']['Server-Port'] == '8080'
), 'Server-Port header' ), 'Server-Port header'

View File

@@ -14,7 +14,7 @@ conf_app = {
} }
conf_basic = { conf_basic = {
"listeners": {"*:7080": {"pass": "applications/app"}}, "listeners": {"*:8080": {"pass": "applications/app"}},
"applications": conf_app, "applications": conf_app,
} }
@@ -64,14 +64,14 @@ def test_python_get_listeners():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert client.conf_get()['listeners'] == { assert client.conf_get()['listeners'] == {
"*:7080": {"pass": "applications/app"} "*:8080": {"pass": "applications/app"}
}, 'listeners' }, 'listeners'
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"} "*:8080": {"pass": "applications/app"}
}, 'listeners prefix' }, 'listeners prefix'
assert client.conf_get('listeners/*:7080') == { assert client.conf_get('listeners/*:8080') == {
"pass": "applications/app" "pass": "applications/app"
}, 'listeners prefix 2' }, 'listeners prefix 2'
@@ -79,23 +79,23 @@ def test_python_get_listeners():
def test_python_change_listener(): def test_python_change_listener():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'success' in client.conf( assert 'success' in client.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners' {"*:8081": {"pass": "applications/app"}}, 'listeners'
) )
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7081": {"pass": "applications/app"} "*:8081": {"pass": "applications/app"}
}, 'change listener' }, 'change listener'
def test_python_add_listener(): def test_python_add_listener():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/app"}, 'listeners/*:7082' {"pass": "applications/app"}, 'listeners/*:8082'
) )
assert client.conf_get('listeners') == { assert client.conf_get('listeners') == {
"*:7080": {"pass": "applications/app"}, "*:8080": {"pass": "applications/app"},
"*:7082": {"pass": "applications/app"}, "*:8082": {"pass": "applications/app"},
}, 'add listener' }, 'add listener'
@@ -117,7 +117,7 @@ def test_python_delete():
assert 'success' in client.conf(conf_basic) assert 'success' in client.conf(conf_basic)
assert 'error' in client.conf_delete('applications/app') assert 'error' in client.conf_delete('applications/app')
assert 'success' in client.conf_delete('listeners/*:7080') assert 'success' in client.conf_delete('listeners/*:8080')
assert 'success' in client.conf_delete('applications/app') assert 'success' in client.conf_delete('applications/app')
assert 'error' in client.conf_delete('applications/app') assert 'error' in client.conf_delete('applications/app')
@@ -130,5 +130,5 @@ def test_python_delete_blocks():
assert 'success' in client.conf(conf_app, 'applications') assert 'success' in client.conf(conf_app, 'applications')
assert 'success' in client.conf( assert 'success' in client.conf(
{"*:7081": {"pass": "applications/app"}}, 'listeners' {"*:8081": {"pass": "applications/app"}}, 'listeners'
), 'applications restore' ), 'applications restore'

View File

@@ -151,8 +151,8 @@ def test_python_isolation_cgroup_two(require):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "applications/one"}, "*:8080": {"pass": "applications/one"},
"*:7081": {"pass": "applications/two"}, "*:8081": {"pass": "applications/two"},
}, },
"applications": { "applications": {
"one": { "one": {
@@ -193,7 +193,7 @@ def test_python_isolation_cgroup_invalid(require):
script_path = f'{option.test_dir}/python/empty' script_path = f'{option.test_dir}/python/empty'
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "applications/empty"}}, "listeners": {"*:8080": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"type": "python", "type": "python",

View File

@@ -11,7 +11,7 @@ def test_python_targets():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/1"}, "match": {"uri": "/1"},
@@ -56,7 +56,7 @@ def test_python_targets_prefix():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": ["/app*"]}, "match": {"uri": ["/app*"]},

View File

@@ -10,7 +10,7 @@ client = ApplicationProto()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": {}, "applications": {},
} }

View File

@@ -20,7 +20,7 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": { "*:8080": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": "default"}, "tls": {"certificate": "default"},
} }
@@ -40,7 +40,7 @@ def create_socket():
ssl_sock = ctx.wrap_socket( ssl_sock = ctx.wrap_socket(
s, server_hostname='localhost', do_handshake_on_connect=False s, server_hostname='localhost', do_handshake_on_connect=False
) )
ssl_sock.connect(('127.0.0.1', 7080)) ssl_sock.connect(('127.0.0.1', 8080))
return ssl_sock return ssl_sock
@@ -51,7 +51,7 @@ def clear_conf():
@pytest.mark.skip('not yet') @pytest.mark.skip('not yet')
def test_reconfigure_tls_switch(): def test_reconfigure_tls_switch():
assert 'success' in client.conf_delete('listeners/*:7080/tls') assert 'success' in client.conf_delete('listeners/*:8080/tls')
(_, sock) = client.get( (_, sock) = client.get(
headers={'Host': 'localhost', 'Connection': 'keep-alive'}, headers={'Host': 'localhost', 'Connection': 'keep-alive'},
@@ -61,7 +61,7 @@ def test_reconfigure_tls_switch():
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "routes", "tls": {"certificate": "default"}}, {"pass": "routes", "tls": {"certificate": "default"}},
'listeners/*:7080', 'listeners/*:8080',
) )
assert client.get(sock=sock)['status'] == 200, 'reconfigure' assert client.get(sock=sock)['status'] == 200, 'reconfigure'

View File

@@ -17,7 +17,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
}, },
"routes": [ "routes": [
{ {
@@ -59,7 +59,7 @@ def test_response_last_action():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes/first"}, "*:8080": {"pass": "routes/first"},
}, },
"routes": { "routes": {
"first": [ "first": [
@@ -91,7 +91,7 @@ def test_response_pass(require):
assert 'success' in client_python.conf( assert 'success' in client_python.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
}, },
"routes": [ "routes": [
{ {
@@ -121,7 +121,7 @@ def test_response_pass(require):
def test_response_fallback(): def test_response_fallback():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {

View File

@@ -10,7 +10,7 @@ client = ApplicationProto()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": {}, "applications": {},
} }

View File

@@ -10,7 +10,7 @@ client = ApplicationProto()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/"}, "match": {"uri": "/"},
@@ -112,7 +112,7 @@ def test_rewrite_location():
def check_location(rewrite, expect): def check_location(rewrite, expect):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {
@@ -141,7 +141,7 @@ def test_rewrite_share(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {
@@ -162,7 +162,7 @@ def test_rewrite_share(temp_dir):
index_path = f'{temp_dir}${{request_uri}}/index.html' index_path = f'{temp_dir}${{request_uri}}/index.html'
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/foo"}, "match": {"uri": "/foo"},
@@ -182,7 +182,7 @@ def test_rewrite_share(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"uri": "/foo"}, "match": {"uri": "/foo"},

View File

@@ -12,7 +12,7 @@ client = ApplicationPython()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": {"method": "GET"}, "match": {"method": "GET"},
@@ -322,7 +322,7 @@ def test_routes_pass_encode():
def check_pass(path, name): def check_pass(path, name):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": f'applications/{path}'}}, "listeners": {"*:8080": {"pass": f'applications/{path}'}},
"applications": { "applications": {
name: { name: {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -345,7 +345,7 @@ def test_routes_pass_encode():
def check_pass_error(path, name): def check_pass_error(path, name):
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"listeners": {"*:7080": {"pass": f'applications/{path}'}}, "listeners": {"*:8080": {"pass": f'applications/{path}'}},
"applications": { "applications": {
name: { name: {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -365,7 +365,7 @@ def test_routes_pass_encode():
def test_routes_absent(): def test_routes_absent():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7081": {"pass": "applications/empty"}}, "listeners": {"*:8081": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -378,19 +378,19 @@ def test_routes_absent():
} }
) )
assert client.get(port=7081)['status'] == 200, 'routes absent' assert client.get(port=8081)['status'] == 200, 'routes absent'
def test_routes_pass_invalid(): def test_routes_pass_invalid():
assert 'error' in client.conf( assert 'error' in client.conf(
{"pass": "routes/blah"}, 'listeners/*:7080' {"pass": "routes/blah"}, 'listeners/*:8080'
), 'routes invalid' ), 'routes invalid'
def test_route_empty(): def test_route_empty():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/main"}}, "listeners": {"*:8080": {"pass": "routes/main"}},
"routes": {"main": []}, "routes": {"main": []},
"applications": {}, "applications": {},
} }
@@ -437,14 +437,14 @@ def test_routes_route_pass():
"upstreams": { "upstreams": {
"one": { "one": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
"two": { "two": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
}, },
@@ -480,14 +480,14 @@ def test_routes_route_pass_invalid():
"upstreams": { "upstreams": {
"one": { "one": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
"two": { "two": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
}, },
@@ -512,10 +512,10 @@ def test_routes_action_unique(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/app"}, "*:8081": {"pass": "applications/app"},
}, },
"routes": [{"action": {"proxy": "http://127.0.0.1:7081"}}], "routes": [{"action": {"proxy": "http://127.0.0.1:8081"}}],
"applications": { "applications": {
"app": { "app": {
"type": client.get_application_type(), "type": client.get_application_type(),
@@ -528,12 +528,12 @@ def test_routes_action_unique(temp_dir):
) )
assert 'error' in client.conf( assert 'error' in client.conf(
{"proxy": "http://127.0.0.1:7081", "share": temp_dir}, {"proxy": "http://127.0.0.1:8081", "share": temp_dir},
'routes/0/action', 'routes/0/action',
), 'proxy share' ), 'proxy share'
assert 'error' in client.conf( assert 'error' in client.conf(
{ {
"proxy": "http://127.0.0.1:7081", "proxy": "http://127.0.0.1:8081",
"pass": "applications/app", "pass": "applications/app",
}, },
'routes/0/action', 'routes/0/action',
@@ -560,7 +560,7 @@ def test_routes_rules_two():
def test_routes_two(): def test_routes_two():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/first"}}, "listeners": {"*:8080": {"pass": "routes/first"}},
"routes": { "routes": {
"first": [ "first": [
{ {
@@ -606,14 +606,14 @@ def test_routes_match_host_ipv4():
route_match({"host": "127.0.0.1"}) route_match({"host": "127.0.0.1"})
host('127.0.0.1', 200) host('127.0.0.1', 200)
host('127.0.0.1:7080', 200) host('127.0.0.1:8080', 200)
def test_routes_match_host_ipv6(): def test_routes_match_host_ipv6():
route_match({"host": "[::1]"}) route_match({"host": "[::1]"})
host('[::1]', 200) host('[::1]', 200)
host('[::1]:7080', 200) host('[::1]:8080', 200)
def test_routes_match_host_positive_many(): def test_routes_match_host_positive_many():
@@ -649,7 +649,7 @@ def test_routes_match_host_case_insensitive():
def test_routes_match_host_port(): def test_routes_match_host_port():
route_match({"host": "example.com"}) route_match({"host": "example.com"})
host('example.com:7080', 200) host('example.com:8080', 200)
def test_routes_match_host_empty(): def test_routes_match_host_empty():
@@ -718,7 +718,7 @@ def test_routes_reconfigure():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/main"}}, "listeners": {"*:8080": {"pass": "routes/main"}},
"routes": {"main": [{"action": {"return": 200}}]}, "routes": {"main": [{"action": {"return": 200}}]},
"applications": {}, "applications": {},
} }
@@ -801,7 +801,7 @@ def test_routes_edit():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/main"}}, "listeners": {"*:8080": {"pass": "routes/main"}},
"routes": {"main": [{"action": {"return": 200}}]}, "routes": {"main": [{"action": {"return": 200}}]},
"applications": {}, "applications": {},
} }
@@ -817,7 +817,7 @@ def test_routes_edit():
assert client.get()['status'] == 200, 'routes edit GET 7' assert client.get()['status'] == 200, 'routes edit GET 7'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'listeners/*:7080' 'listeners/*:8080'
), 'route edit configure 8' ), 'route edit configure 8'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'routes/main' 'routes/main'
@@ -1646,14 +1646,14 @@ def test_routes_source_port():
def test_routes_source_addr(): def test_routes_source_addr():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"[::1]:7081": {"pass": "routes"}, "[::1]:8081": {"pass": "routes"},
}, },
'listeners', 'listeners',
), 'source listeners configure' ), 'source listeners configure'
def get_ipv6(): def get_ipv6():
return client.get(sock_type='ipv6', port=7081) return client.get(sock_type='ipv6', port=8081)
route_match({"source": "127.0.0.1"}) route_match({"source": "127.0.0.1"})
assert client.get()['status'] == 200, 'exact' assert client.get()['status'] == 200, 'exact'
@@ -1707,64 +1707,64 @@ def test_routes_source_addr():
def test_routes_source_ipv6(): def test_routes_source_ipv6():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"[::1]:7080": {"pass": "routes"}, "[::1]:8080": {"pass": "routes"},
"127.0.0.1:7081": {"pass": "routes"}, "127.0.0.1:8081": {"pass": "routes"},
}, },
'listeners', 'listeners',
), 'source listeners configure' ), 'source listeners configure'
route_match({"source": "::1"}) route_match({"source": "::1"})
assert client.get(sock_type='ipv6')['status'] == 200, 'exact' assert client.get(sock_type='ipv6')['status'] == 200, 'exact'
assert client.get(port=7081)['status'] == 404, 'exact ipv4' assert client.get(port=8081)['status'] == 404, 'exact ipv4'
route_match({"source": ["::1"]}) route_match({"source": ["::1"]})
assert client.get(sock_type='ipv6')['status'] == 200, 'exact 2' assert client.get(sock_type='ipv6')['status'] == 200, 'exact 2'
assert client.get(port=7081)['status'] == 404, 'exact 2 ipv4' assert client.get(port=8081)['status'] == 404, 'exact 2 ipv4'
route_match({"source": "!::1"}) route_match({"source": "!::1"})
assert client.get(sock_type='ipv6')['status'] == 404, 'exact neg' assert client.get(sock_type='ipv6')['status'] == 404, 'exact neg'
assert client.get(port=7081)['status'] == 200, 'exact neg ipv4' assert client.get(port=8081)['status'] == 200, 'exact neg ipv4'
route_match({"source": "::2"}) route_match({"source": "::2"})
assert client.get(sock_type='ipv6')['status'] == 404, 'exact 3' assert client.get(sock_type='ipv6')['status'] == 404, 'exact 3'
assert client.get(port=7081)['status'] == 404, 'exact 3 ipv4' assert client.get(port=8081)['status'] == 404, 'exact 3 ipv4'
route_match({"source": "::1-::1"}) route_match({"source": "::1-::1"})
assert client.get(sock_type='ipv6')['status'] == 200, 'range' assert client.get(sock_type='ipv6')['status'] == 200, 'range'
assert client.get(port=7081)['status'] == 404, 'range ipv4' assert client.get(port=8081)['status'] == 404, 'range ipv4'
route_match({"source": "::2-::2"}) route_match({"source": "::2-::2"})
assert client.get(sock_type='ipv6')['status'] == 404, 'range 2' assert client.get(sock_type='ipv6')['status'] == 404, 'range 2'
assert client.get(port=7081)['status'] == 404, 'range 2 ipv4' assert client.get(port=8081)['status'] == 404, 'range 2 ipv4'
route_match({"source": "::2-::3"}) route_match({"source": "::2-::3"})
assert client.get(sock_type='ipv6')['status'] == 404, 'range 3' assert client.get(sock_type='ipv6')['status'] == 404, 'range 3'
assert client.get(port=7081)['status'] == 404, 'range 3 ipv4' assert client.get(port=8081)['status'] == 404, 'range 3 ipv4'
route_match({"source": "::1-::2"}) route_match({"source": "::1-::2"})
assert client.get(sock_type='ipv6')['status'] == 200, 'range 4' assert client.get(sock_type='ipv6')['status'] == 200, 'range 4'
assert client.get(port=7081)['status'] == 404, 'range 4 ipv4' assert client.get(port=8081)['status'] == 404, 'range 4 ipv4'
route_match({"source": "::0-::2"}) route_match({"source": "::0-::2"})
assert client.get(sock_type='ipv6')['status'] == 200, 'range 5' assert client.get(sock_type='ipv6')['status'] == 200, 'range 5'
assert client.get(port=7081)['status'] == 404, 'range 5 ipv4' assert client.get(port=8081)['status'] == 404, 'range 5 ipv4'
route_match({"source": "::0-::1"}) route_match({"source": "::0-::1"})
assert client.get(sock_type='ipv6')['status'] == 200, 'range 6' assert client.get(sock_type='ipv6')['status'] == 200, 'range 6'
assert client.get(port=7081)['status'] == 404, 'range 6 ipv4' assert client.get(port=8081)['status'] == 404, 'range 6 ipv4'
def test_routes_source_cidr(): def test_routes_source_cidr():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"[::1]:7081": {"pass": "routes"}, "[::1]:8081": {"pass": "routes"},
}, },
'listeners', 'listeners',
), 'source listeners configure' ), 'source listeners configure'
def get_ipv6(): def get_ipv6():
return client.get(sock_type='ipv6', port=7081) return client.get(sock_type='ipv6', port=8081)
route_match({"source": "127.0.0.1/32"}) route_match({"source": "127.0.0.1/32"})
assert client.get()['status'] == 200, '32' assert client.get()['status'] == 200, '32'
@@ -1790,35 +1790,35 @@ def test_routes_source_cidr():
def test_routes_source_cidr_ipv6(): def test_routes_source_cidr_ipv6():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"[::1]:7080": {"pass": "routes"}, "[::1]:8080": {"pass": "routes"},
"127.0.0.1:7081": {"pass": "routes"}, "127.0.0.1:8081": {"pass": "routes"},
}, },
'listeners', 'listeners',
), 'source listeners configure' ), 'source listeners configure'
route_match({"source": "::1/128"}) route_match({"source": "::1/128"})
assert client.get(sock_type='ipv6')['status'] == 200, '128' assert client.get(sock_type='ipv6')['status'] == 200, '128'
assert client.get(port=7081)['status'] == 404, '128 ipv4' assert client.get(port=8081)['status'] == 404, '128 ipv4'
route_match({"source": "::0/128"}) route_match({"source": "::0/128"})
assert client.get(sock_type='ipv6')['status'] == 404, '128 2' assert client.get(sock_type='ipv6')['status'] == 404, '128 2'
assert client.get(port=7081)['status'] == 404, '128 ipv4' assert client.get(port=8081)['status'] == 404, '128 ipv4'
route_match({"source": "::0/127"}) route_match({"source": "::0/127"})
assert client.get(sock_type='ipv6')['status'] == 200, '127' assert client.get(sock_type='ipv6')['status'] == 200, '127'
assert client.get(port=7081)['status'] == 404, '127 ipv4' assert client.get(port=8081)['status'] == 404, '127 ipv4'
route_match({"source": "::0/32"}) route_match({"source": "::0/32"})
assert client.get(sock_type='ipv6')['status'] == 200, '32' assert client.get(sock_type='ipv6')['status'] == 200, '32'
assert client.get(port=7081)['status'] == 404, '32 ipv4' assert client.get(port=8081)['status'] == 404, '32 ipv4'
route_match({"source": "::0/1"}) route_match({"source": "::0/1"})
assert client.get(sock_type='ipv6')['status'] == 200, '1' assert client.get(sock_type='ipv6')['status'] == 200, '1'
assert client.get(port=7081)['status'] == 404, '1 ipv4' assert client.get(port=8081)['status'] == 404, '1 ipv4'
route_match({"source": "::/0"}) route_match({"source": "::/0"})
assert client.get(sock_type='ipv6')['status'] == 200, '0' assert client.get(sock_type='ipv6')['status'] == 200, '0'
assert client.get(port=7081)['status'] == 404, '0 ipv4' assert client.get(port=8081)['status'] == 404, '0 ipv4'
def test_routes_source_unix(temp_dir): def test_routes_source_unix(temp_dir):
@@ -1826,7 +1826,7 @@ def test_routes_source_unix(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": {"pass": "routes"}, "127.0.0.1:8081": {"pass": "routes"},
f'unix:{addr}': {"pass": "routes"}, f'unix:{addr}': {"pass": "routes"},
}, },
'listeners', 'listeners',
@@ -1843,7 +1843,7 @@ def test_routes_source_unix(temp_dir):
), 'unix ipv6 neg' ), 'unix ipv6 neg'
route_match({"source": "unix"}) route_match({"source": "unix"})
assert client.get(port=7081)['status'] == 404, 'unix ipv4' assert client.get(port=8081)['status'] == 404, 'unix ipv4'
assert client.get(sock_type='unix', addr=addr)['status'] == 200, 'unix' assert client.get(sock_type='unix', addr=addr)['status'] == 200, 'unix'
@@ -1916,7 +1916,7 @@ def test_routes_match_source_invalid():
route_match_invalid({"source": "2001::/129"}) route_match_invalid({"source": "2001::/129"})
route_match_invalid({"source": "::FFFFF"}) route_match_invalid({"source": "::FFFFF"})
route_match_invalid({"source": "[::1]:"}) route_match_invalid({"source": "[::1]:"})
route_match_invalid({"source": "[:::]:7080"}) route_match_invalid({"source": "[:::]:8080"})
route_match_invalid({"source": "*:"}) route_match_invalid({"source": "*:"})
route_match_invalid({"source": "*:1-a"}) route_match_invalid({"source": "*:1-a"})
route_match_invalid({"source": "*:65536"}) route_match_invalid({"source": "*:65536"})
@@ -1929,74 +1929,74 @@ def test_routes_match_source_none():
def test_routes_match_destination(): def test_routes_match_destination():
assert 'success' in client.conf( assert 'success' in client.conf(
{"*:7080": {"pass": "routes"}, "*:7081": {"pass": "routes"}}, {"*:8080": {"pass": "routes"}, "*:8081": {"pass": "routes"}},
'listeners', 'listeners',
), 'listeners configure' ), 'listeners configure'
route_match({"destination": "*:7080"}) route_match({"destination": "*:8080"})
assert client.get()['status'] == 200, 'dest' assert client.get()['status'] == 200, 'dest'
assert client.get(port=7081)['status'] == 404, 'dest 2' assert client.get(port=8081)['status'] == 404, 'dest 2'
route_match({"destination": ["127.0.0.1:7080"]}) route_match({"destination": ["127.0.0.1:8080"]})
assert client.get()['status'] == 200, 'dest 3' assert client.get()['status'] == 200, 'dest 3'
assert client.get(port=7081)['status'] == 404, 'dest 4' assert client.get(port=8081)['status'] == 404, 'dest 4'
route_match({"destination": "!*:7080"}) route_match({"destination": "!*:8080"})
assert client.get()['status'] == 404, 'dest neg' assert client.get()['status'] == 404, 'dest neg'
assert client.get(port=7081)['status'] == 200, 'dest neg 2' assert client.get(port=8081)['status'] == 200, 'dest neg 2'
route_match({"destination": ['!*:7080', '!*:7081']}) route_match({"destination": ['!*:8080', '!*:8081']})
assert client.get()['status'] == 404, 'dest neg 3' assert client.get()['status'] == 404, 'dest neg 3'
assert client.get(port=7081)['status'] == 404, 'dest neg 4' assert client.get(port=8081)['status'] == 404, 'dest neg 4'
route_match({"destination": ['!*:7081', '!*:7082']}) route_match({"destination": ['!*:8081', '!*:8082']})
assert client.get()['status'] == 200, 'dest neg 5' assert client.get()['status'] == 200, 'dest neg 5'
route_match({"destination": ['*:7080', '!*:7080']}) route_match({"destination": ['*:8080', '!*:8080']})
assert client.get()['status'] == 404, 'dest neg 6' assert client.get()['status'] == 404, 'dest neg 6'
route_match({"destination": ['127.0.0.1:7080', '*:7081', '!*:7080']}) route_match({"destination": ['127.0.0.1:8080', '*:8081', '!*:8080']})
assert client.get()['status'] == 404, 'dest neg 7' assert client.get()['status'] == 404, 'dest neg 7'
assert client.get(port=7081)['status'] == 200, 'dest neg 8' assert client.get(port=8081)['status'] == 200, 'dest neg 8'
route_match({"destination": ['!*:7081', '!*:7082', '*:7083']}) route_match({"destination": ['!*:8081', '!*:8082', '*:8083']})
assert client.get()['status'] == 404, 'dest neg 9' assert client.get()['status'] == 404, 'dest neg 9'
route_match({"destination": ['*:7081', '!127.0.0.1:7080', '*:7080']}) route_match({"destination": ['*:8081', '!127.0.0.1:8080', '*:8080']})
assert client.get()['status'] == 404, 'dest neg 10' assert client.get()['status'] == 404, 'dest neg 10'
assert client.get(port=7081)['status'] == 200, 'dest neg 11' assert client.get(port=8081)['status'] == 200, 'dest neg 11'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'routes/0/match/destination/0' 'routes/0/match/destination/0'
), 'remove destination rule' ), 'remove destination rule'
assert client.get()['status'] == 404, 'dest neg 12' assert client.get()['status'] == 404, 'dest neg 12'
assert client.get(port=7081)['status'] == 404, 'dest neg 13' assert client.get(port=8081)['status'] == 404, 'dest neg 13'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'routes/0/match/destination/0' 'routes/0/match/destination/0'
), 'remove destination rule 2' ), 'remove destination rule 2'
assert client.get()['status'] == 200, 'dest neg 14' assert client.get()['status'] == 200, 'dest neg 14'
assert client.get(port=7081)['status'] == 404, 'dest neg 15' assert client.get(port=8081)['status'] == 404, 'dest neg 15'
assert 'success' in client.conf_post( assert 'success' in client.conf_post(
"\"!127.0.0.1\"", 'routes/0/match/destination' "\"!127.0.0.1\"", 'routes/0/match/destination'
), 'add destination rule' ), 'add destination rule'
assert client.get()['status'] == 404, 'dest neg 16' assert client.get()['status'] == 404, 'dest neg 16'
assert client.get(port=7081)['status'] == 404, 'dest neg 17' assert client.get(port=8081)['status'] == 404, 'dest neg 17'
def test_routes_match_destination_proxy(): def test_routes_match_destination_proxy():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes/first"}, "*:8080": {"pass": "routes/first"},
"*:7081": {"pass": "routes/second"}, "*:8081": {"pass": "routes/second"},
}, },
"routes": { "routes": {
"first": [{"action": {"proxy": "http://127.0.0.1:7081"}}], "first": [{"action": {"proxy": "http://127.0.0.1:8081"}}],
"second": [ "second": [
{ {
"match": {"destination": ["127.0.0.1:7081"]}, "match": {"destination": ["127.0.0.1:8081"]},
"action": {"return": 200}, "action": {"return": 200},
} }
], ],

View File

@@ -11,8 +11,8 @@ def test_routes_match_scheme_tls():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": { "*:8081": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": 'default'}, "tls": {"certificate": 'default'},
}, },
@@ -26,4 +26,4 @@ def test_routes_match_scheme_tls():
), 'scheme configure' ), 'scheme configure'
assert client.get()['status'] == 200, 'http' assert client.get()['status'] == 200, 'http'
assert client.get_ssl(port=7081)['status'] == 201, 'https' assert client.get_ssl(port=8081)['status'] == 201, 'https'

View File

@@ -91,7 +91,7 @@ def test_ruby_application_server_port():
client.load('server_port') client.load('server_port')
assert ( assert (
client.get()['headers']['Server-Port'] == '7080' client.get()['headers']['Server-Port'] == '8080'
), 'Server-Port header' ), 'Server-Port header'

View File

@@ -460,7 +460,7 @@ def test_settings_log_route(findall, search_in_file, wait_for_record):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"match": { "match": {
@@ -487,7 +487,7 @@ def test_settings_log_route(findall, search_in_file, wait_for_record):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/main"}}, "listeners": {"*:8080": {"pass": "routes/main"}},
"routes": { "routes": {
"main": [ "main": [
{ {
@@ -516,7 +516,7 @@ def test_settings_log_route(findall, search_in_file, wait_for_record):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/first"}}, "listeners": {"*:8080": {"pass": "routes/first"}},
"routes": { "routes": {
"first": [ "first": [
{ {
@@ -541,7 +541,7 @@ def test_settings_log_route(findall, search_in_file, wait_for_record):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes/fall"}}, "listeners": {"*:8080": {"pass": "routes/fall"}},
"routes": { "routes": {
"fall": [ "fall": [
{ {

View File

@@ -26,7 +26,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{assets_dir}$uri'}}], "routes": [{"action": {"share": f'{assets_dir}$uri'}}],
"settings": { "settings": {
"http": { "http": {

View File

@@ -20,7 +20,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
} }
) )

View File

@@ -19,8 +19,8 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "routes"}, "*:8081": {"pass": "routes"},
}, },
"routes": [{"action": {"share": f'{assets_dir}$uri'}}], "routes": [{"action": {"share": f'{assets_dir}$uri'}}],
"applications": {}, "applications": {},
@@ -108,13 +108,13 @@ def test_static_fallback_proxy():
assert 'success' in client.conf( assert 'success' in client.conf(
[ [
{ {
"match": {"destination": "*:7081"}, "match": {"destination": "*:8081"},
"action": {"return": 200}, "action": {"return": 200},
}, },
{ {
"action": { "action": {
"share": "/blah", "share": "/blah",
"fallback": {"proxy": "http://127.0.0.1:7081"}, "fallback": {"proxy": "http://127.0.0.1:8081"},
} }
}, },
], ],
@@ -136,11 +136,11 @@ def test_static_fallback_proxy_loop(skip_alert):
) )
action_update( action_update(
{"share": "/blah", "fallback": {"proxy": "http://127.0.0.1:7080"}} {"share": "/blah", "fallback": {"proxy": "http://127.0.0.1:8080"}}
) )
client.get(no_recv=True) client.get(no_recv=True)
assert 'success' in client.conf_delete('listeners/*:7081') assert 'success' in client.conf_delete('listeners/*:8081')
client.get(read_timeout=1) client.get(read_timeout=1)
@@ -152,6 +152,6 @@ def test_static_fallback_invalid():
check_error({"share": "/blah", "fallback": ""}) check_error({"share": "/blah", "fallback": ""})
check_error({"return": 200, "fallback": {"share": "/blah"}}) check_error({"return": 200, "fallback": {"share": "/blah"}})
check_error( check_error(
{"proxy": "http://127.0.0.1:7081", "fallback": {"share": "/blah"}} {"proxy": "http://127.0.0.1:8081", "fallback": {"share": "/blah"}}
) )
check_error({"fallback": {"share": "/blah"}}) check_error({"fallback": {"share": "/blah"}})

View File

@@ -38,7 +38,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets/dir$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets/dir$uri'}}],
} }
) )

View File

@@ -17,7 +17,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
"applications": {}, "applications": {},
} }

View File

@@ -17,7 +17,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
} }
) )

View File

@@ -17,8 +17,8 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "routes"}, "*:8081": {"pass": "routes"},
}, },
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
"applications": {}, "applications": {},
@@ -124,14 +124,14 @@ def test_static_types_fallback(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
[ [
{ {
"match": {"destination": "*:7081"}, "match": {"destination": "*:8081"},
"action": {"return": 200}, "action": {"return": 200},
}, },
{ {
"action": { "action": {
"share": f'{temp_dir}/assets$uri', "share": f'{temp_dir}/assets$uri',
"types": ["!application/x-httpd-php"], "types": ["!application/x-httpd-php"],
"fallback": {"proxy": "http://127.0.0.1:7081"}, "fallback": {"proxy": "http://127.0.0.1:8081"},
} }
}, },
], ],
@@ -155,7 +155,7 @@ def test_static_types_index(temp_dir):
def test_static_types_custom_mime(temp_dir): def test_static_types_custom_mime(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
"applications": {}, "applications": {},
"settings": { "settings": {

View File

@@ -17,7 +17,7 @@ def setup_method_fixture(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}], "routes": [{"action": {"share": f'{temp_dir}/assets$uri'}}],
} }
) )

View File

@@ -39,9 +39,9 @@ def test_status_requests(skip_alert):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/empty"}, "*:8081": {"pass": "applications/empty"},
"*:7082": {"pass": "applications/blah"}, "*:8082": {"pass": "applications/blah"},
}, },
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": { "applications": {
@@ -60,7 +60,7 @@ def test_status_requests(skip_alert):
assert client.get()['status'] == 200 assert client.get()['status'] == 200
assert Status.get('/requests/total') == 1, '2xx' assert Status.get('/requests/total') == 1, '2xx'
assert client.get(port=7081)['status'] == 200 assert client.get(port=8081)['status'] == 200
assert Status.get('/requests/total') == 2, '2xx app' assert Status.get('/requests/total') == 2, '2xx app'
assert ( assert (
@@ -69,7 +69,7 @@ def test_status_requests(skip_alert):
) )
assert Status.get('/requests/total') == 3, '4xx' assert Status.get('/requests/total') == 3, '4xx'
assert client.get(port=7082)['status'] == 503 assert client.get(port=8082)['status'] == 503
assert Status.get('/requests/total') == 4, '5xx' assert Status.get('/requests/total') == 4, '5xx'
client.http( client.http(
@@ -85,7 +85,7 @@ Connection: close
) )
assert Status.get('/requests/total') == 6, 'pipeline' assert Status.get('/requests/total') == 6, 'pipeline'
sock = client.get(port=7081, no_recv=True) sock = client.get(port=8081, no_recv=True)
time.sleep(1) time.sleep(1)
@@ -98,8 +98,8 @@ def test_status_connections():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/delayed"}, "*:8081": {"pass": "applications/delayed"},
}, },
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": { "applications": {
@@ -136,7 +136,7 @@ def test_status_connections():
'X-Delay': '2', 'X-Delay': '2',
'Connection': 'close', 'Connection': 'close',
}, },
port=7081, port=8081,
start=True, start=True,
read_timeout=1, read_timeout=1,
) )
@@ -194,8 +194,8 @@ def test_status_applications():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "applications/restart"}, "*:8080": {"pass": "applications/restart"},
"*:7081": {"pass": "applications/delayed"}, "*:8081": {"pass": "applications/delayed"},
}, },
"routes": [], "routes": [],
"applications": { "applications": {
@@ -220,13 +220,13 @@ def test_status_proxy():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": {"pass": "applications/empty"}, "*:8081": {"pass": "applications/empty"},
}, },
"routes": [ "routes": [
{ {
"match": {"uri": "/"}, "match": {"uri": "/"},
"action": {"proxy": "http://127.0.0.1:7081"}, "action": {"proxy": "http://127.0.0.1:8081"},
} }
], ],
"applications": { "applications": {

View File

@@ -12,8 +12,8 @@ def test_status_tls_requests():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "routes"}, "*:8080": {"pass": "routes"},
"*:7081": { "*:8081": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": "default"}, "tls": {"certificate": "default"},
}, },
@@ -26,6 +26,6 @@ def test_status_tls_requests():
Status.init() Status.init()
assert client.get()['status'] == 200 assert client.get()['status'] == 200
assert client.get_ssl(port=7081)['status'] == 200 assert client.get_ssl(port=8081)['status'] == 200
assert Status.get('/requests/total') == 2 assert Status.get('/requests/total') == 2

View File

@@ -12,7 +12,7 @@ prerequisites = {'modules': {'python': 'any', 'openssl': 'any'}}
client = ApplicationTLS() client = ApplicationTLS()
def add_tls(application='empty', cert='default', port=7080): def add_tls(application='empty', cert='default', port=8080):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"pass": f"applications/{application}", "pass": f"applications/{application}",
@@ -85,7 +85,7 @@ basicConstraints = critical,CA:TRUE"""
f.write('') f.write('')
def remove_tls(application='empty', port=7080): def remove_tls(application='empty', port=8080):
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": f"applications/{application}"}, f'listeners/*:{port}' {"pass": f"applications/{application}"}, f'listeners/*:{port}'
) )
@@ -178,12 +178,12 @@ def test_tls_certificate_update():
add_tls() add_tls()
cert_old = ssl.get_server_certificate(('127.0.0.1', 7080)) cert_old = ssl.get_server_certificate(('127.0.0.1', 8080))
client.certificate() client.certificate()
assert cert_old != ssl.get_server_certificate( assert cert_old != ssl.get_server_certificate(
('127.0.0.1', 7080) ('127.0.0.1', 8080)
), 'update certificate' ), 'update certificate'
@@ -207,12 +207,12 @@ def test_tls_certificate_change():
add_tls() add_tls()
cert_old = ssl.get_server_certificate(('127.0.0.1', 7080)) cert_old = ssl.get_server_certificate(('127.0.0.1', 8080))
add_tls(cert='new') add_tls(cert='new')
assert cert_old != ssl.get_server_certificate( assert cert_old != ssl.get_server_certificate(
('127.0.0.1', 7080) ('127.0.0.1', 8080)
), 'change certificate' ), 'change certificate'
@@ -542,7 +542,7 @@ def test_tls_no_close_notify():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": { "*:8080": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": "default"}, "tls": {"certificate": "default"},
} }
@@ -576,7 +576,7 @@ def test_tls_keepalive_certificate_remove():
) )
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "applications/empty"}, 'listeners/*:7080' {"pass": "applications/empty"}, 'listeners/*:8080'
) )
assert 'success' in client.conf_delete('/certificates/default') assert 'success' in client.conf_delete('/certificates/default')
@@ -697,8 +697,8 @@ def test_tls_multi_listener():
client.certificate() client.certificate()
add_tls() add_tls()
add_tls(port=7081) add_tls(port=8081)
assert client.get_ssl()['status'] == 200, 'listener #1' assert client.get_ssl()['status'] == 200, 'listener #1'
assert client.get_ssl(port=7081)['status'] == 200, 'listener #2' assert client.get_ssl(port=8081)['status'] == 200, 'listener #2'

View File

@@ -15,7 +15,7 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": { "*:8080": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": "default"}, "tls": {"certificate": "default"},
} }
@@ -55,7 +55,7 @@ def test_tls_conf_command():
"certificate": "default", "certificate": "default",
"conf_commands": {"protocol": f'-{protocol}'}, "conf_commands": {"protocol": f'-{protocol}'},
}, },
'listeners/*:7080/tls', 'listeners/*:8080/tls',
), 'protocol disabled' ), 'protocol disabled'
sock.close() sock.close()
@@ -84,7 +84,7 @@ def test_tls_conf_command():
"cipherstring": f"{cipher[1]}:!{cipher[0]}", "cipherstring": f"{cipher[1]}:!{cipher[0]}",
}, },
}, },
'listeners/*:7080/tls', 'listeners/*:8080/tls',
), 'cipher disabled' ), 'cipher disabled'
if len(ciphers) > 1: if len(ciphers) > 1:
@@ -106,7 +106,7 @@ def test_tls_conf_command_invalid(skip_alert):
def check_conf_commands(conf_commands): def check_conf_commands(conf_commands):
assert 'error' in client.conf( assert 'error' in client.conf(
{"certificate": "default", "conf_commands": conf_commands}, {"certificate": "default", "conf_commands": conf_commands},
'listeners/*:7080/tls', 'listeners/*:8080/tls',
), 'ivalid conf_commands' ), 'ivalid conf_commands'
check_conf_commands([]) check_conf_commands([])

View File

@@ -26,7 +26,7 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": { "*:8080": {
"pass": "routes", "pass": "routes",
"tls": {"certificate": "default", "session": {}}, "tls": {"certificate": "default", "session": {}},
} }
@@ -45,11 +45,11 @@ def add_session(cache_size=None, timeout=None):
if timeout is not None: if timeout is not None:
session['timeout'] = timeout session['timeout'] = timeout
return client.conf(session, 'listeners/*:7080/tls/session') return client.conf(session, 'listeners/*:8080/tls/session')
def connect(ctx=None, session=None): def connect(ctx=None, session=None):
sock = socket.create_connection(('127.0.0.1', 7080)) sock = socket.create_connection(('127.0.0.1', 8080))
if ctx is None: if ctx is None:
ctx = Context(TLSv1_2_METHOD) ctx = Context(TLSv1_2_METHOD)

View File

@@ -14,7 +14,7 @@ client = ApplicationTLS()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": {}, "applications": {},
} }
@@ -24,7 +24,7 @@ def setup_method_fixture():
def add_tls(cert='default'): def add_tls(cert='default'):
assert 'success' in client.conf( assert 'success' in client.conf(
{"pass": "routes", "tls": {"certificate": cert}}, {"pass": "routes", "tls": {"certificate": cert}},
'listeners/*:7080', 'listeners/*:8080',
) )
@@ -141,7 +141,7 @@ def load_certs(bundles):
def remove_tls(): def remove_tls():
assert 'success' in client.conf({"pass": "routes"}, 'listeners/*:7080') assert 'success' in client.conf({"pass": "routes"}, 'listeners/*:8080')
def test_tls_sni(): def test_tls_sni():
@@ -289,7 +289,7 @@ def test_tls_sni_invalid():
def check_certificate(cert): def check_certificate(cert):
assert 'error' in client.conf( assert 'error' in client.conf(
{"pass": "routes", "tls": {"certificate": cert}}, {"pass": "routes", "tls": {"certificate": cert}},
'listeners/*:7080', 'listeners/*:8080',
) )
check_certificate('') check_certificate('')

View File

@@ -36,9 +36,9 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": listener_conf, "*:8080": listener_conf,
"*:7081": listener_conf, "*:8081": listener_conf,
"*:7082": listener_conf, "*:8082": listener_conf,
}, },
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
"applications": {}, "applications": {},
@@ -46,7 +46,7 @@ def setup_method_fixture():
), 'load application configuration' ), 'load application configuration'
def connect(ctx=None, session=None, port=7080): def connect(ctx=None, session=None, port=8080):
sock = socket.create_connection(('127.0.0.1', port)) sock = socket.create_connection(('127.0.0.1', port))
if ctx is None: if ctx is None:
@@ -72,7 +72,7 @@ def has_ticket(sess):
return _lib.SSL_SESSION_has_ticket(sess._session) return _lib.SSL_SESSION_has_ticket(sess._session)
def set_tickets(tickets=True, port=7080): def set_tickets(tickets=True, port=8080):
assert 'success' in client.conf( assert 'success' in client.conf(
{"cache_size": 0, "tickets": tickets}, {"cache_size": 0, "tickets": tickets},
f'listeners/*:{port}/tls/session', f'listeners/*:{port}/tls/session',
@@ -98,7 +98,7 @@ def test_tls_ticket():
assert not has_ticket(sess), 'tickets False' assert not has_ticket(sess), 'tickets False'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'listeners/*:7080/tls/session/tickets' 'listeners/*:8080/tls/session/tickets'
), 'tickets default configure' ), 'tickets default configure'
sess, _, _ = connect() sess, _, _ = connect()
@@ -118,13 +118,13 @@ def test_tls_ticket_string():
assert has_ticket(sess2), 'tickets string reconnect' assert has_ticket(sess2), 'tickets string reconnect'
assert reused, 'tickets string reused' assert reused, 'tickets string reused'
sess2, _, reused = connect(ctx, sess, port=7081) sess2, _, reused = connect(ctx, sess, port=8081)
assert has_ticket(sess2), 'connect True' assert has_ticket(sess2), 'connect True'
assert not reused, 'connect True not reused' assert not reused, 'connect True not reused'
set_tickets(TICKET2, port=7081) set_tickets(TICKET2, port=8081)
sess2, _, reused = connect(ctx, sess, port=7081) sess2, _, reused = connect(ctx, sess, port=8081)
assert has_ticket(sess2), 'wrong ticket' assert has_ticket(sess2), 'wrong ticket'
assert not reused, 'wrong ticket not reused' assert not reused, 'wrong ticket not reused'
@@ -137,7 +137,7 @@ def test_tls_ticket_string():
assert has_ticket(sess2), 'tickets string 80 reconnect' assert has_ticket(sess2), 'tickets string 80 reconnect'
assert reused, 'tickets string 80 reused' assert reused, 'tickets string 80 reused'
sess2, _, reused = connect(ctx, sess, port=7081) sess2, _, reused = connect(ctx, sess, port=8081)
assert has_ticket(sess2), 'wrong ticket 80' assert has_ticket(sess2), 'wrong ticket 80'
assert not reused, 'wrong ticket 80 not reused' assert not reused, 'wrong ticket 80 not reused'
@@ -153,34 +153,34 @@ def test_tls_ticket_array():
assert not has_ticket(sess), 'tickets array empty' assert not has_ticket(sess), 'tickets array empty'
set_tickets([TICKET, TICKET2]) set_tickets([TICKET, TICKET2])
set_tickets(TICKET, port=7081) set_tickets(TICKET, port=8081)
set_tickets(TICKET2, port=7082) set_tickets(TICKET2, port=8082)
sess, ctx, _ = connect() sess, ctx, _ = connect()
_, _, reused = connect(ctx, sess, port=7081) _, _, reused = connect(ctx, sess, port=8081)
assert not reused, 'not last ticket' assert not reused, 'not last ticket'
_, _, reused = connect(ctx, sess, port=7082) _, _, reused = connect(ctx, sess, port=8082)
assert reused, 'last ticket' assert reused, 'last ticket'
sess, ctx, _ = connect(port=7081) sess, ctx, _ = connect(port=8081)
_, _, reused = connect(ctx, sess) _, _, reused = connect(ctx, sess)
assert reused, 'first ticket' assert reused, 'first ticket'
sess, ctx, _ = connect(port=7082) sess, ctx, _ = connect(port=8082)
_, _, reused = connect(ctx, sess) _, _, reused = connect(ctx, sess)
assert reused, 'second ticket' assert reused, 'second ticket'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'listeners/*:7080/tls/session/tickets/0' 'listeners/*:8080/tls/session/tickets/0'
), 'removed first ticket' ), 'removed first ticket'
assert 'success' in client.conf_post( assert 'success' in client.conf_post(
f'"{TICKET}"', 'listeners/*:7080/tls/session/tickets' f'"{TICKET}"', 'listeners/*:8080/tls/session/tickets'
), 'add new ticket to the end of array' ), 'add new ticket to the end of array'
sess, ctx, _ = connect() sess, ctx, _ = connect()
_, _, reused = connect(ctx, sess, port=7082) _, _, reused = connect(ctx, sess, port=8082)
assert not reused, 'not last ticket 2' assert not reused, 'not last ticket 2'
_, _, reused = connect(ctx, sess, port=7081) _, _, reused = connect(ctx, sess, port=8081)
assert reused, 'last ticket 2' assert reused, 'last ticket 2'
@@ -188,7 +188,7 @@ def test_tls_ticket_invalid():
def check_tickets(tickets): def check_tickets(tickets):
assert 'error' in client.conf( assert 'error' in client.conf(
{"tickets": tickets}, {"tickets": tickets},
'listeners/*:7080/tls/session', 'listeners/*:8080/tls/session',
) )
check_tickets({}) check_tickets({})

View File

@@ -18,7 +18,7 @@ def test_unix_abstract_source():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"127.0.0.1:7080": {"pass": "routes"}, "127.0.0.1:8080": {"pass": "routes"},
f"unix:@{addr[1:]}": {"pass": "routes"}, f"unix:@{addr[1:]}": {"pass": "routes"},
}, },
"routes": [ "routes": [
@@ -44,8 +44,8 @@ def test_unix_abstract_source():
def test_unix_abstract_client_ip(): def test_unix_abstract_client_ip():
def get_xff(xff, sock_type='ipv4'): def get_xff(xff, sock_type='ipv4'):
address = { address = {
'ipv4': ('127.0.0.1', 7080), 'ipv4': ('127.0.0.1', 8080),
'ipv6': ('::1', 7081), 'ipv6': ('::1', 8081),
'unix': ('\0sock', None), 'unix': ('\0sock', None),
} }
(addr, port) = address[sock_type] (addr, port) = address[sock_type]
@@ -61,14 +61,14 @@ def test_unix_abstract_client_ip():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"127.0.0.1:7080": { "127.0.0.1:8080": {
"client_ip": { "client_ip": {
"header": "X-Forwarded-For", "header": "X-Forwarded-For",
"source": "unix", "source": "unix",
}, },
"pass": "applications/client_ip", "pass": "applications/client_ip",
}, },
"[::1]:7081": { "[::1]:8081": {
"client_ip": { "client_ip": {
"header": "X-Forwarded-For", "header": "X-Forwarded-For",
"source": "unix", "source": "unix",

View File

@@ -15,23 +15,23 @@ def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "upstreams/one"}, "*:8080": {"pass": "upstreams/one"},
"*:7090": {"pass": "upstreams/two"}, "*:8090": {"pass": "upstreams/two"},
"*:7081": {"pass": "routes/one"}, "*:8081": {"pass": "routes/one"},
"*:7082": {"pass": "routes/two"}, "*:8082": {"pass": "routes/two"},
"*:7083": {"pass": "routes/three"}, "*:8083": {"pass": "routes/three"},
}, },
"upstreams": { "upstreams": {
"one": { "one": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
"two": { "two": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
}, },
@@ -47,7 +47,7 @@ def setup_method_fixture():
client.cpu_count = os.cpu_count() client.cpu_count = os.cpu_count()
def get_resps(req=100, port=7080): def get_resps(req=100, port=8080):
resps = [0] resps = [0]
for _ in range(req): for _ in range(req):
@@ -64,7 +64,7 @@ def get_resps(req=100, port=7080):
return resps return resps
def get_resps_sc(req=100, port=7080): def get_resps_sc(req=100, port=8080):
to_send = b"""GET / HTTP/1.1 to_send = b"""GET / HTTP/1.1
Host: localhost Host: localhost
@@ -96,14 +96,14 @@ def test_upstreams_rr_no_weight():
assert abs(resps[0] - resps[1]) <= client.cpu_count, 'no weight' assert abs(resps[0] - resps[1]) <= client.cpu_count, 'no weight'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'upstreams/one/servers/127.0.0.1:7081' 'upstreams/one/servers/127.0.0.1:8081'
), 'no weight server remove' ), 'no weight server remove'
resps = get_resps(req=50) resps = get_resps(req=50)
assert resps[1] == 50, 'no weight 2' assert resps[1] == 50, 'no weight 2'
assert 'success' in client.conf( assert 'success' in client.conf(
{}, 'upstreams/one/servers/127.0.0.1:7081' {}, 'upstreams/one/servers/127.0.0.1:8081'
), 'no weight server revert' ), 'no weight server revert'
resps = get_resps() resps = get_resps()
@@ -111,7 +111,7 @@ def test_upstreams_rr_no_weight():
assert abs(resps[0] - resps[1]) <= client.cpu_count, 'no weight 3' assert abs(resps[0] - resps[1]) <= client.cpu_count, 'no weight 3'
assert 'success' in client.conf( assert 'success' in client.conf(
{}, 'upstreams/one/servers/127.0.0.1:7083' {}, 'upstreams/one/servers/127.0.0.1:8083'
), 'no weight server new' ), 'no weight server new'
resps = get_resps() resps = get_resps()
@@ -126,7 +126,7 @@ def test_upstreams_rr_no_weight():
def test_upstreams_rr_weight(): def test_upstreams_rr_weight():
assert 'success' in client.conf( assert 'success' in client.conf(
{"weight": 3}, 'upstreams/one/servers/127.0.0.1:7081' {"weight": 3}, 'upstreams/one/servers/127.0.0.1:8081'
), 'configure weight' ), 'configure weight'
resps = get_resps_sc() resps = get_resps_sc()
@@ -134,14 +134,14 @@ def test_upstreams_rr_weight():
assert resps[1] == 25, 'weight 3 1' assert resps[1] == 25, 'weight 3 1'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'upstreams/one/servers/127.0.0.1:7081/weight' 'upstreams/one/servers/127.0.0.1:8081/weight'
), 'configure weight remove' ), 'configure weight remove'
resps = get_resps_sc(req=10) resps = get_resps_sc(req=10)
assert resps[0] == 5, 'weight 0 0' assert resps[0] == 5, 'weight 0 0'
assert resps[1] == 5, 'weight 0 1' assert resps[1] == 5, 'weight 0 1'
assert 'success' in client.conf( assert 'success' in client.conf(
'1', 'upstreams/one/servers/127.0.0.1:7081/weight' '1', 'upstreams/one/servers/127.0.0.1:8081/weight'
), 'configure weight 1' ), 'configure weight 1'
resps = get_resps_sc() resps = get_resps_sc()
@@ -150,8 +150,8 @@ def test_upstreams_rr_weight():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": {"weight": 3}, "127.0.0.1:8081": {"weight": 3},
"127.0.0.1:7083": {"weight": 2}, "127.0.0.1:8083": {"weight": 2},
}, },
'upstreams/one/servers', 'upstreams/one/servers',
), 'configure weight 2' ), 'configure weight 2'
@@ -165,8 +165,8 @@ def test_upstreams_rr_weight_rational():
def set_weights(w1, w2): def set_weights(w1, w2):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": {"weight": w1}, "127.0.0.1:8081": {"weight": w1},
"127.0.0.1:7082": {"weight": w2}, "127.0.0.1:8082": {"weight": w2},
}, },
'upstreams/one/servers', 'upstreams/one/servers',
), 'configure weights' ), 'configure weights'
@@ -195,15 +195,15 @@ def test_upstreams_rr_weight_rational():
set_weights(0.25, 0.25) set_weights(0.25, 0.25)
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'upstreams/one/servers/127.0.0.1:7081/weight' 'upstreams/one/servers/127.0.0.1:8081/weight'
), 'delete weight' ), 'delete weight'
check_reqs(1, 0.25) check_reqs(1, 0.25)
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": {"weight": 0.1}, "127.0.0.1:8081": {"weight": 0.1},
"127.0.0.1:7082": {"weight": 1}, "127.0.0.1:8082": {"weight": 1},
"127.0.0.1:7083": {"weight": 0.9}, "127.0.0.1:8083": {"weight": 0.9},
}, },
'upstreams/one/servers', 'upstreams/one/servers',
), 'configure weights' ), 'configure weights'
@@ -221,7 +221,7 @@ def test_upstreams_rr_independent():
return sum_r return sum_r
resps = get_resps_sc(req=30, port=7090) resps = get_resps_sc(req=30, port=8090)
assert resps[0] == 15, 'dep two before 0' assert resps[0] == 15, 'dep two before 0'
assert resps[1] == 15, 'dep two before 1' assert resps[1] == 15, 'dep two before 1'
@@ -230,10 +230,10 @@ def test_upstreams_rr_independent():
assert resps[1] == 15, 'dep one before 1' assert resps[1] == 15, 'dep one before 1'
assert 'success' in client.conf( assert 'success' in client.conf(
'2', 'upstreams/two/servers/127.0.0.1:7081/weight' '2', 'upstreams/two/servers/127.0.0.1:8081/weight'
), 'configure dep weight' ), 'configure dep weight'
resps = get_resps_sc(req=30, port=7090) resps = get_resps_sc(req=30, port=8090)
assert resps[0] == 20, 'dep two 0' assert resps[0] == 20, 'dep two 0'
assert resps[1] == 10, 'dep two 1' assert resps[1] == 10, 'dep two 1'
@@ -242,13 +242,13 @@ def test_upstreams_rr_independent():
assert resps[1] == 15, 'dep one 1' assert resps[1] == 15, 'dep one 1'
assert 'success' in client.conf( assert 'success' in client.conf(
'1', 'upstreams/two/servers/127.0.0.1:7081/weight' '1', 'upstreams/two/servers/127.0.0.1:8081/weight'
), 'configure dep weight 1' ), 'configure dep weight 1'
r_one, r_two = [0, 0], [0, 0] r_one, r_two = [0, 0], [0, 0]
for _ in range(10): for _ in range(10):
r_one = sum_resps(r_one, get_resps(req=10)) r_one = sum_resps(r_one, get_resps(req=10))
r_two = sum_resps(r_two, get_resps(req=10, port=7090)) r_two = sum_resps(r_two, get_resps(req=10, port=8090))
assert sum(r_one) == 100, 'dep one mix sum' assert sum(r_one) == 100, 'dep one mix sum'
assert abs(r_one[0] - r_one[1]) <= client.cpu_count, 'dep one mix' assert abs(r_one[0] - r_one[1]) <= client.cpu_count, 'dep one mix'
@@ -261,25 +261,25 @@ def test_upstreams_rr_delay():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": "upstreams/one"}, "*:8080": {"pass": "upstreams/one"},
"*:7081": {"pass": "routes"}, "*:8081": {"pass": "routes"},
"*:7082": {"pass": "routes"}, "*:8082": {"pass": "routes"},
}, },
"upstreams": { "upstreams": {
"one": { "one": {
"servers": { "servers": {
"127.0.0.1:7081": {}, "127.0.0.1:8081": {},
"127.0.0.1:7082": {}, "127.0.0.1:8082": {},
}, },
}, },
}, },
"routes": [ "routes": [
{ {
"match": {"destination": "*:7081"}, "match": {"destination": "*:8081"},
"action": {"pass": "applications/delayed"}, "action": {"pass": "applications/delayed"},
}, },
{ {
"match": {"destination": "*:7082"}, "match": {"destination": "*:8082"},
"action": {"return": 201}, "action": {"return": 201},
}, },
], ],
@@ -351,14 +351,14 @@ Connection: close
assert client.get()['body'] == '' assert client.get()['body'] == ''
assert 'success' in client.conf( assert 'success' in client.conf(
{"127.0.0.1:7083": {"weight": 2}}, {"127.0.0.1:8083": {"weight": 2}},
'upstreams/one/servers', 'upstreams/one/servers',
), 'active req new server' ), 'active req new server'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'upstreams/one/servers/127.0.0.1:7083' 'upstreams/one/servers/127.0.0.1:8083'
), 'active req server remove' ), 'active req server remove'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'listeners/*:7080' 'listeners/*:8080'
), 'delete listener' ), 'delete listener'
assert 'success' in client.conf_delete( assert 'success' in client.conf_delete(
'upstreams/one' 'upstreams/one'
@@ -377,7 +377,7 @@ Connection: close
def test_upstreams_rr_bad_server(): def test_upstreams_rr_bad_server():
assert 'success' in client.conf( assert 'success' in client.conf(
{"weight": 1}, 'upstreams/one/servers/127.0.0.1:7084' {"weight": 1}, 'upstreams/one/servers/127.0.0.1:8084'
), 'configure bad server' ), 'configure bad server'
resps = get_resps_sc(req=30) resps = get_resps_sc(req=30)
@@ -409,7 +409,7 @@ def test_upstreams_rr_unix(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "upstreams/one"}, "*:8080": {"pass": "upstreams/one"},
f"unix:{addr_0}": {"pass": "routes/one"}, f"unix:{addr_0}": {"pass": "routes/one"},
f"unix:{addr_1}": {"pass": "routes/two"}, f"unix:{addr_1}": {"pass": "routes/two"},
}, },
@@ -430,15 +430,15 @@ def test_upstreams_rr_unix(temp_dir):
def test_upstreams_rr_ipv6(): def test_upstreams_rr_ipv6():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"*:7080": {"pass": "upstreams/one"}, "*:8080": {"pass": "upstreams/one"},
"[::1]:7081": {"pass": "routes/one"}, "[::1]:8081": {"pass": "routes/one"},
"[::1]:7082": {"pass": "routes/two"}, "[::1]:8082": {"pass": "routes/two"},
}, },
'listeners', 'listeners',
), 'configure listeners ipv6' ), 'configure listeners ipv6'
assert 'success' in client.conf( assert 'success' in client.conf(
{"[::1]:7081": {}, "[::1]:7082": {}}, 'upstreams/one/servers' {"[::1]:8081": {}, "[::1]:8082": {}}, 'upstreams/one/servers'
), 'configure servers ipv6' ), 'configure servers ipv6'
resps = get_resps_sc() resps = get_resps_sc()
@@ -454,13 +454,13 @@ def test_upstreams_rr_servers_empty():
assert client.get()['status'] == 502, 'servers empty' assert client.get()['status'] == 502, 'servers empty'
assert 'success' in client.conf( assert 'success' in client.conf(
{"127.0.0.1:7081": {"weight": 0}}, 'upstreams/one/servers' {"127.0.0.1:8081": {"weight": 0}}, 'upstreams/one/servers'
), 'configure servers empty one' ), 'configure servers empty one'
assert client.get()['status'] == 502, 'servers empty one' assert client.get()['status'] == 502, 'servers empty one'
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"127.0.0.1:7081": {"weight": 0}, "127.0.0.1:8081": {"weight": 0},
"127.0.0.1:7082": {"weight": 0}, "127.0.0.1:8082": {"weight": 0},
}, },
'upstreams/one/servers', 'upstreams/one/servers',
), 'configure servers empty two' ), 'configure servers empty two'
@@ -474,12 +474,12 @@ def test_upstreams_rr_invalid():
{}, 'upstreams/one/servers/127.0.0.1' {}, 'upstreams/one/servers/127.0.0.1'
), 'invalid address' ), 'invalid address'
assert 'error' in client.conf( assert 'error' in client.conf(
{}, 'upstreams/one/servers/127.0.0.1:7081/blah' {}, 'upstreams/one/servers/127.0.0.1:8081/blah'
), 'invalid server option' ), 'invalid server option'
def check_weight(w): def check_weight(w):
assert 'error' in client.conf( assert 'error' in client.conf(
w, 'upstreams/one/servers/127.0.0.1:7081/weight' w, 'upstreams/one/servers/127.0.0.1:8081/weight'
), 'invalid weight option' ), 'invalid weight option'
check_weight({}) check_weight({})

View File

@@ -16,7 +16,7 @@ client_python = ApplicationPython()
def setup_method_fixture(): def setup_method_fixture():
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [{"action": {"return": 200}}], "routes": [{"action": {"return": 200}}],
}, },
), 'configure routes' ), 'configure routes'
@@ -132,7 +132,7 @@ def test_variables_uri_no_cache(temp_dir):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {
@@ -163,7 +163,7 @@ def test_variables_host(search_in_file, wait_for_record):
check_host('localhost') check_host('localhost')
check_host('localhost1.', 'localhost1') check_host('localhost1.', 'localhost1')
check_host('localhost2:7080', 'localhost2') check_host('localhost2:8080', 'localhost2')
check_host('.localhost') check_host('.localhost')
check_host('www.localhost') check_host('www.localhost')
@@ -175,7 +175,7 @@ def test_variables_remote_addr(search_in_file, wait_for_record):
assert wait_for_record(r'^127\.0\.0\.1$', 'access.log') is not None assert wait_for_record(r'^127\.0\.0\.1$', 'access.log') is not None
assert 'success' in client.conf( assert 'success' in client.conf(
{"[::1]:7080": {"pass": "routes"}}, 'listeners' {"[::1]:8080": {"pass": "routes"}}, 'listeners'
) )
reg = r'^::1$' reg = r'^::1$'
@@ -447,7 +447,7 @@ def test_variables_response_header(temp_dir, wait_for_record):
assert 'success' in client.conf( assert 'success' in client.conf(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {

View File

@@ -91,7 +91,7 @@ replace unit.nginx.org/go => {replace_path}
ApplicationGo.prepare_env(script, name, static=static_build) ApplicationGo.prepare_env(script, name, static=static_build)
conf = { conf = {
"listeners": {"*:7080": {"pass": f"applications/{script}"}}, "listeners": {"*:8080": {"pass": f"applications/{script}"}},
"applications": { "applications": {
script: { script: {
"type": "external", "type": "external",

View File

@@ -97,7 +97,7 @@ class ApplicationJava(ApplicationProto):
script_path = f'{option.test_dir}/java/{script}/' script_path = f'{option.test_dir}/java/{script}/'
self._load_conf( self._load_conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{script}"}}, "listeners": {"*:8080": {"pass": f"applications/{script}"}},
"applications": { "applications": {
script: { script: {
"unit_jars": f'{option.current_dir}/build', "unit_jars": f'{option.current_dir}/build',

View File

@@ -44,7 +44,7 @@ class ApplicationNode(ApplicationProto):
self._load_conf( self._load_conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": f"applications/{quote(script, '')}"} "*:8080": {"pass": f"applications/{quote(script, '')}"}
}, },
"applications": { "applications": {
script: { script: {

View File

@@ -11,7 +11,7 @@ class ApplicationPerl(ApplicationProto):
self._load_conf( self._load_conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{script}"}}, "listeners": {"*:8080": {"pass": f"applications/{script}"}},
"applications": { "applications": {
script: { script: {
"type": self.get_application_type(), "type": self.get_application_type(),

View File

@@ -42,7 +42,7 @@ class ApplicationPHP(ApplicationProto):
self._load_conf( self._load_conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{script}"}}, "listeners": {"*:8080": {"pass": f"applications/{script}"}},
"applications": {script: app}, "applications": {script: app},
}, },
**kwargs, **kwargs,

View File

@@ -59,7 +59,7 @@ class ApplicationPython(ApplicationProto):
self._load_conf( self._load_conf(
{ {
"listeners": { "listeners": {
"*:7080": {"pass": f"applications/{quote(name, '')}"} "*:8080": {"pass": f"applications/{quote(name, '')}"}
}, },
"applications": {name: app}, "applications": {name: app},
}, },

View File

@@ -37,7 +37,7 @@ class ApplicationRuby(ApplicationProto):
self._load_conf( self._load_conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{script}"}}, "listeners": {"*:8080": {"pass": f"applications/{script}"}},
"applications": {script: app}, "applications": {script: app},
}, },
**kwargs, **kwargs,

View File

@@ -97,7 +97,7 @@ distinguished_name = req_distinguished_name
script_path = f'{option.test_dir}/python/{script}' script_path = f'{option.test_dir}/python/{script}'
self._load_conf( self._load_conf(
{ {
"listeners": {"*:7080": {"pass": f"applications/{name}"}}, "listeners": {"*:8080": {"pass": f"applications/{name}"}},
"applications": { "applications": {
name: { name: {
"type": "python", "type": "python",

View File

@@ -15,7 +15,7 @@ def check_chroot():
addr=f'{option.temp_dir}/control.unit.sock', addr=f'{option.temp_dir}/control.unit.sock',
body=json.dumps( body=json.dumps(
{ {
"listeners": {"*:7080": {"pass": "routes"}}, "listeners": {"*:8080": {"pass": "routes"}},
"routes": [ "routes": [
{ {
"action": { "action": {

View File

@@ -21,7 +21,7 @@ def check_isolation():
ApplicationGo().prepare_env('empty', 'app') ApplicationGo().prepare_env('empty', 'app')
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}}, "listeners": {"*:8080": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"type": "external", "type": "external",
@@ -35,7 +35,7 @@ def check_isolation():
elif 'python' in available['modules']: elif 'python' in available['modules']:
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}}, "listeners": {"*:8080": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"type": "python", "type": "python",
@@ -50,7 +50,7 @@ def check_isolation():
elif 'php' in available['modules']: elif 'php' in available['modules']:
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/phpinfo"}}, "listeners": {"*:8080": {"pass": "applications/phpinfo"}},
"applications": { "applications": {
"phpinfo": { "phpinfo": {
"type": "php", "type": "php",
@@ -67,7 +67,7 @@ def check_isolation():
ApplicationRuby().prepare_env('empty') ApplicationRuby().prepare_env('empty')
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}}, "listeners": {"*:8080": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"type": "ruby", "type": "ruby",
@@ -83,7 +83,7 @@ def check_isolation():
ApplicationJava().prepare_env('empty') ApplicationJava().prepare_env('empty')
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/empty"}}, "listeners": {"*:8080": {"pass": "applications/empty"}},
"applications": { "applications": {
"empty": { "empty": {
"unit_jars": f"{option.current_dir}/build", "unit_jars": f"{option.current_dir}/build",
@@ -100,7 +100,7 @@ def check_isolation():
ApplicationNode().prepare_env('basic') ApplicationNode().prepare_env('basic')
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/basic"}}, "listeners": {"*:8080": {"pass": "applications/basic"}},
"applications": { "applications": {
"basic": { "basic": {
"type": "external", "type": "external",
@@ -114,7 +114,7 @@ def check_isolation():
elif 'perl' in available['modules']: elif 'perl' in available['modules']:
conf = { conf = {
"listeners": {"*:7080": {"pass": "applications/body_empty"}}, "listeners": {"*:8080": {"pass": "applications/body_empty"}},
"applications": { "applications": {
"body_empty": { "body_empty": {
"type": "perl", "type": "perl",

Some files were not shown because too many files have changed in this diff Show More