test_virtual_path.py 698 B

123456789101112131415
  1. import pytest
  2. @pytest.mark.parametrize("path", ["web1", "web2"])
  3. def test_web1_http_redirects_to_https(docker_compose, nginxproxy, path):
  4. r = nginxproxy.get("http://www.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
  5. assert r.status_code == 301
  6. assert "Location" in r.headers
  7. assert "https://www.nginx-proxy.tld/%s/port" % path == r.headers['Location']
  8. @pytest.mark.parametrize("path,port", [("web1", 81), ("web2", 82)])
  9. def test_web1_https_is_forwarded(docker_compose, nginxproxy, path, port):
  10. r = nginxproxy.get("https://www.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
  11. assert r.status_code == 200
  12. assert "answer from port %d\n" % port in r.text