test_nohttp.py 718 B

12345678910111213141516171819
  1. import pytest
  2. import requests
  3. def test_web2_http_is_connection_refused(docker_compose, nginxproxy):
  4. with pytest.raises(requests.exceptions.RequestException, match="Connection refused"):
  5. nginxproxy.get("http://web2.nginx-proxy.tld/")
  6. def test_web2_https_is_forwarded(docker_compose, nginxproxy):
  7. r = nginxproxy.get("https://web2.nginx-proxy.tld/port", allow_redirects=False)
  8. assert r.status_code == 200
  9. assert "answer from port 82\n" in r.text
  10. def test_web2_HSTS_policy_is_active(docker_compose, nginxproxy):
  11. r = nginxproxy.get("https://web2.nginx-proxy.tld/port", allow_redirects=False)
  12. assert "answer from port 82\n" in r.text
  13. assert "Strict-Transport-Security" in r.headers