1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-25 21:36:30 +00:00
nginx-proxy/test2/test_wildcard_host.py

33 lines
1.1 KiB
Python
Raw Normal View History

import pytest
@pytest.mark.parametrize("host,expected_port", [
("f00.nginx-proxy.test", 81),
("bar.nginx-proxy.test", 81),
("test.nginx-proxy.f00", 82),
("test.nginx-proxy.bar", 82),
("web3.123.nginx-proxy.regexp", 83),
("web3.ABC.nginx-proxy.regexp", 83),
("web3.123.ABC.nginx-proxy.regexp", 83),
("web3.123-ABC.nginx-proxy.regexp", 83),
("web3.whatever.nginx-proxy.regexp-to-infinity-and-beyond", 83),
("web4.123.nginx-proxy.regexp", 84),
("web4.ABC.nginx-proxy.regexp", 84),
("web4.123.ABC.nginx-proxy.regexp", 84),
("web4.123-ABC.nginx-proxy.regexp", 84),
("web4.whatever.nginx-proxy.regexp", 84),
])
def test_wildcard_prefix(docker_compose, nginxproxy, host, expected_port):
r = nginxproxy.get("http://%s/port" % host)
assert r.status_code == 200
assert r.text == "answer from port %s\n" % expected_port
@pytest.mark.parametrize("host", [
"unexpected.nginx-proxy.tld",
"web4.whatever.nginx-proxy.regexp-to-infinity-and-beyond"
])
def test_non_matching_host_is_503(docker_compose, nginxproxy, host):
r = nginxproxy.get("http://%s/port" % host)
assert r.status_code == 503, r.text