nginx-proxy-auto-docker/test/test_ssl/test_virtual_path.py
Robin Windey 7272649958
Fix tests after merge with upstream
* Use "sub." instead of "www." because the latter will be redirected to non-www
2022-10-07 15:40:44 +02:00

15 lines
698 B
Python

import pytest
@pytest.mark.parametrize("path", ["web1", "web2"])
def test_web1_http_redirects_to_https(docker_compose, nginxproxy, path):
r = nginxproxy.get("http://sub.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
assert r.status_code == 301
assert "Location" in r.headers
assert "https://sub.nginx-proxy.tld/%s/port" % path == r.headers['Location']
@pytest.mark.parametrize("path,port", [("web1", 81), ("web2", 82)])
def test_web1_https_is_forwarded(docker_compose, nginxproxy, path, port):
r = nginxproxy.get("https://sub.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
assert r.status_code == 200
assert "answer from port %d\n" % port in r.text