test_virtual-host.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. def test_web1_has_custom_http_and_https_ports(docker_compose, nginxproxy):
  2. r1 = nginxproxy.get("http://web1.nginx-proxy.tld:8080/port", allow_redirects=False)
  3. assert r1.status_code == 301
  4. assert r1.headers['Location'] == 'https://web1.nginx-proxy.tld:8443/port'
  5. r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
  6. assert r2.status_code == 200
  7. assert "answer from port 81\n" in r2.text
  8. def test_web2_has_default_http_port_and_custom_https_port(docker_compose, nginxproxy):
  9. r1 = nginxproxy.get("http://web2.nginx-proxy.tld/port", allow_redirects=False)
  10. assert r1.status_code == 301
  11. assert r1.headers['Location'] == 'https://web2.nginx-proxy.tld:8443/port'
  12. r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
  13. assert r2.status_code == 200
  14. assert "answer from port 82\n" in r2.text
  15. def test_web3_has_custom_http_port_and_default_https_port(docker_compose, nginxproxy):
  16. r1 = nginxproxy.get("http://web3.nginx-proxy.tld:8080/port", allow_redirects=False)
  17. assert r1.status_code == 301
  18. assert r1.headers['Location'] == 'https://web3.nginx-proxy.tld/port'
  19. r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
  20. assert r2.status_code == 200
  21. assert "answer from port 83\n" in r2.text
  22. def test_web4_has_default_http_and_https_ports(docker_compose, nginxproxy):
  23. r1 = nginxproxy.get("http://web4.nginx-proxy.tld/port", allow_redirects=False)
  24. assert r1.status_code == 301
  25. assert r1.headers['Location'] == 'https://web4.nginx-proxy.tld/port'
  26. r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
  27. assert r2.status_code == 200
  28. assert "answer from port 84\n" in r2.text