mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-07-01 22:35:45 +00:00
tests: standardize file structure & naming
This commit is contained in:
32
test/test_wildcard-host/test_wildcard-host.py
Normal file
32
test/test_wildcard-host/test_wildcard-host.py
Normal file
@ -0,0 +1,32 @@
|
||||
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(f"http://{host}/port")
|
||||
assert r.status_code == 200
|
||||
assert r.text == f"answer from port {expected_port}\n"
|
||||
|
||||
|
||||
@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(f"http://{host}/port")
|
||||
assert r.status_code == 503, r.text
|
37
test/test_wildcard-host/test_wildcard-host.yml
Normal file
37
test/test_wildcard-host/test_wildcard-host.yml
Normal file
@ -0,0 +1,37 @@
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
- "81"
|
||||
environment:
|
||||
WEB_PORTS: "81"
|
||||
VIRTUAL_HOST: "*.nginx-proxy.test"
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
- "82"
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: "test.nginx-proxy.*"
|
||||
|
||||
web3:
|
||||
image: web
|
||||
expose:
|
||||
- "83"
|
||||
environment:
|
||||
WEB_PORTS: "83"
|
||||
VIRTUAL_HOST: ~^web3\..*\.nginx-proxy\.regexp
|
||||
|
||||
web4:
|
||||
image: web
|
||||
expose:
|
||||
- "84"
|
||||
environment:
|
||||
WEB_PORTS: "84"
|
||||
VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker compose variable interpolation
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
Reference in New Issue
Block a user