test_hsts.py 894 B

12345678910111213141516171819
  1. import pytest
  2. def test_web1_HSTS_default(docker_compose, nginxproxy):
  3. r = nginxproxy.get("https://web1.nginx-proxy.tld/port", allow_redirects=False)
  4. assert "answer from port 81\n" in r.text
  5. assert "Strict-Transport-Security" in r.headers
  6. assert "max-age=31536000" == r.headers["Strict-Transport-Security"]
  7. def test_web2_HSTS_off(docker_compose, nginxproxy):
  8. r = nginxproxy.get("https://web2.nginx-proxy.tld/port", allow_redirects=False)
  9. assert "answer from port 81\n" in r.text
  10. assert "Strict-Transport-Security" not in r.headers
  11. def test_web3_HSTS_custom(docker_compose, nginxproxy):
  12. r = nginxproxy.get("https://web3.nginx-proxy.tld/port", allow_redirects=False)
  13. assert "answer from port 81\n" in r.text
  14. assert "Strict-Transport-Security" in r.headers
  15. assert "max-age=86400; includeSubDomains; preload" == r.headers["Strict-Transport-Security"]