2024-12-30 13:41:47 +01:00
|
|
|
import platform
|
|
|
|
|
2016-12-10 00:53:23 +01:00
|
|
|
import pytest
|
2017-02-16 23:27:28 +01:00
|
|
|
from requests import ConnectionError
|
2016-12-10 00:53:23 +01:00
|
|
|
|
2017-02-14 01:39:08 +01:00
|
|
|
|
2016-12-10 00:53:23 +01:00
|
|
|
def test_unknown_virtual_host(docker_compose, nginxproxy):
|
|
|
|
r = nginxproxy.get("http://nginx-proxy/port")
|
|
|
|
assert r.status_code == 503
|
|
|
|
|
2017-02-14 01:39:08 +01:00
|
|
|
|
2016-12-10 00:53:23 +01:00
|
|
|
def test_forwards_to_web1(docker_compose, nginxproxy):
|
|
|
|
r = nginxproxy.get("http://web1.nginx-proxy.tld/port")
|
|
|
|
assert r.status_code == 200
|
|
|
|
assert r.text == "answer from port 81\n"
|
|
|
|
|
2017-02-14 01:39:08 +01:00
|
|
|
|
2016-12-10 00:53:23 +01:00
|
|
|
def test_forwards_to_web2(docker_compose, nginxproxy):
|
|
|
|
r = nginxproxy.get("http://web2.nginx-proxy.tld/port")
|
|
|
|
assert r.status_code == 200
|
|
|
|
assert r.text == "answer from port 82\n"
|
2017-02-14 01:39:08 +01:00
|
|
|
|
|
|
|
|
2024-12-30 13:41:47 +01:00
|
|
|
@pytest.mark.skipif(
|
|
|
|
platform.system() == "Darwin",
|
|
|
|
reason="This test rely on being able to directly contact the container's IP"
|
|
|
|
)
|
2017-02-16 23:27:28 +01:00
|
|
|
def test_ipv6_is_disabled_by_default(docker_compose, nginxproxy):
|
|
|
|
with pytest.raises(ConnectionError):
|
|
|
|
nginxproxy.get("http://nginx-proxy/port", ipv6=True)
|
2022-01-11 22:53:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_container_version_is_displayed(docker_compose, nginxproxy):
|
|
|
|
conf = nginxproxy.get_conf().decode('ASCII')
|
|
|
|
assert "# nginx-proxy version : test" in conf
|