diff --git a/test/test_listen_port.py b/test/test_listen_port.py new file mode 100644 index 0000000..25f4c98 --- /dev/null +++ b/test/test_listen_port.py @@ -0,0 +1,8 @@ +import pytest + + +@pytest.mark.parametrize("subdomain", ["foo", "bar"]) +def test_web1_http_custom_port(docker_compose, nginxproxy, subdomain): + r = nginxproxy.get("http://%s.nginx-proxy.tld:8080/port" % subdomain, allow_redirects=False) + assert r.status_code == 200 + assert "answer from port 81\n" in r.text diff --git a/test/test_listen_port.yml b/test/test_listen_port.yml new file mode 100644 index 0000000..6ae307a --- /dev/null +++ b/test/test_listen_port.yml @@ -0,0 +1,16 @@ +web1: + image: web + expose: + - "81" + environment: + WEB_PORTS: "81" + VIRTUAL_HOST: "*.nginx-proxy.tld" + +sut: + image: jwilder/nginx-proxy:test + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - ../lib/ssl/dhparam.pem:/etc/nginx/dhparam/dhparam.pem:ro + - ./certs:/etc/nginx/certs:ro + environment: + LISTEN_PORT: 8080 diff --git a/test/test_ssl/test_listen_port_ssl.py b/test/test_ssl/test_listen_port_ssl.py new file mode 100644 index 0000000..76ef90f --- /dev/null +++ b/test/test_ssl/test_listen_port_ssl.py @@ -0,0 +1,15 @@ +import pytest + +@pytest.mark.parametrize("subdomain", ["foo", "bar"]) +def test_web1_http_redirects_to_https(docker_compose, nginxproxy, subdomain): + r = nginxproxy.get("http://%s.nginx-proxy.tld:8080/" % subdomain, allow_redirects=False) + assert r.status_code == 301 + assert "Location" in r.headers + assert "https://%s.nginx-proxy.tld:8443/" % subdomain == r.headers['Location'] + + +@pytest.mark.parametrize("subdomain", ["foo", "bar"]) +def test_web1_https_is_forwarded(docker_compose, nginxproxy, subdomain): + r = nginxproxy.get("https://%s.nginx-proxy.tld:8443/port" % subdomain, allow_redirects=False) + assert r.status_code == 200 + assert "answer from port 81\n" in r.text diff --git a/test/test_ssl/test_listen_port_ssl.yml b/test/test_ssl/test_listen_port_ssl.yml new file mode 100644 index 0000000..de24a36 --- /dev/null +++ b/test/test_ssl/test_listen_port_ssl.yml @@ -0,0 +1,17 @@ +web1: + image: web + expose: + - "81" + environment: + WEB_PORTS: "81" + VIRTUAL_HOST: "*.nginx-proxy.tld" + +sut: + image: jwilder/nginx-proxy:test + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - ../lib/ssl/dhparam.pem:/etc/nginx/dhparam/dhparam.pem:ro + - ./certs:/etc/nginx/certs:ro + environment: + LISTEN_PORT: 8080 + LISTEN_PORT_SSL: 8443