From 250a01d2356b5f6d78244e9bd4bc8a6ad69427be Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Thu, 16 Feb 2017 23:27:28 +0100 Subject: [PATCH] TESTS: add tests for IPv6 support --- test2/test_ipv6.py | 35 +++++++++++++++++++++++++++++++++++ test2/test_ipv6.yml | 23 +++++++++++++++++++++++ test2/test_nominal.py | 19 ++++--------------- 3 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 test2/test_ipv6.py create mode 100644 test2/test_ipv6.yml diff --git a/test2/test_ipv6.py b/test2/test_ipv6.py new file mode 100644 index 0000000..36bf653 --- /dev/null +++ b/test2/test_ipv6.py @@ -0,0 +1,35 @@ +import pytest + + +def test_unknown_virtual_host_ipv4(docker_compose, nginxproxy): + r = nginxproxy.get("http://nginx-proxy/port") + assert r.status_code == 503 + + +def test_forwards_to_web1_ipv4(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" + + +def test_forwards_to_web2_ipv4(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" + + +def test_unknown_virtual_host_ipv6(docker_compose, nginxproxy): + r = nginxproxy.get("http://nginx-proxy/port", ipv6=True) + assert r.status_code == 503 + + +def test_forwards_to_web1_ipv6(docker_compose, nginxproxy): + r = nginxproxy.get("http://web1.nginx-proxy.tld/port", ipv6=True) + assert r.status_code == 200 + assert r.text == "answer from port 81\n" + + +def test_forwards_to_web2_ipv6(docker_compose, nginxproxy): + r = nginxproxy.get("http://web2.nginx-proxy.tld/port", ipv6=True) + assert r.status_code == 200 + assert r.text == "answer from port 82\n" diff --git a/test2/test_ipv6.yml b/test2/test_ipv6.yml new file mode 100644 index 0000000..c734660 --- /dev/null +++ b/test2/test_ipv6.yml @@ -0,0 +1,23 @@ +web1: + image: web + expose: + - "81" + environment: + WEB_PORTS: 81 + VIRTUAL_HOST: web1.nginx-proxy.tld + +web2: + image: web + expose: + - "82" + environment: + WEB_PORTS: 82 + VIRTUAL_HOST: web2.nginx-proxy.tld + + +sut: + image: jwilder/nginx-proxy:test + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + environment: + ENABLE_IPV6: "true" diff --git a/test2/test_nominal.py b/test2/test_nominal.py index 6ee41a6..cce7c94 100644 --- a/test2/test_nominal.py +++ b/test2/test_nominal.py @@ -1,4 +1,5 @@ import pytest +from requests import ConnectionError def test_unknown_virtual_host(docker_compose, nginxproxy): @@ -18,18 +19,6 @@ def test_forwards_to_web2(docker_compose, nginxproxy): assert r.text == "answer from port 82\n" -def test_unknown_virtual_host_ipv6(docker_compose, nginxproxy): - r = nginxproxy.get("http://nginx-proxy/port", ipv6=True) - assert r.status_code == 503 - - -def test_forwards_to_web1_ipv6(docker_compose, nginxproxy): - r = nginxproxy.get("http://web1.nginx-proxy.tld/port", ipv6=True) - assert r.status_code == 200 - assert r.text == "answer from port 81\n" - - -def test_forwards_to_web2_ipv6(docker_compose, nginxproxy): - r = nginxproxy.get("http://web2.nginx-proxy.tld/port", ipv6=True) - assert r.status_code == 200 - assert r.text == "answer from port 82\n" +def test_ipv6_is_disabled_by_default(docker_compose, nginxproxy): + with pytest.raises(ConnectionError): + nginxproxy.get("http://nginx-proxy/port", ipv6=True)