1
0
mirror of https://github.com/nginx-proxy/nginx-proxy synced 2025-02-05 05:41:39 +01:00
nginx-proxy/test/test_virtual-path/test_custom-conf.py
2024-12-24 16:22:20 +01:00

40 lines
1.2 KiB
Python

import pytest
def test_default_root_response(docker_compose, nginxproxy):
r = nginxproxy.get("http://nginx-proxy.test/")
assert r.status_code == 418
@pytest.mark.parametrize("stub,header", [
("nginx-proxy.test/web1", "bar"),
("foo.nginx-proxy.test", "f00"),
])
def test_custom_applies(docker_compose, nginxproxy, stub, header):
r = nginxproxy.get(f"http://{stub}/port")
assert r.status_code == 200
assert "X-test" in r.headers
assert header == r.headers["X-test"]
@pytest.mark.parametrize("stub,code", [
("nginx-proxy.test/foo", 418),
("nginx-proxy.test/web2", 200),
("nginx-proxy.test/web3", 200),
("bar.nginx-proxy.test", 503),
])
def test_custom_does_not_apply(docker_compose, nginxproxy, stub, code):
r = nginxproxy.get(f"http://{stub}/port")
assert r.status_code == code
assert "X-test" not in r.headers
@pytest.mark.parametrize("stub,port", [
("nginx-proxy.test/web1", 81),
("nginx-proxy.test/web2", 82),
("nginx-proxy.test/web3", 83),
("nginx-proxy.test/alt", 83),
])
def test_alternate(docker_compose, nginxproxy, stub, port):
r = nginxproxy.get(f"http://{stub}/port")
assert r.status_code == 200
assert r.text == f"answer from port {port}\n"