test_http3-global-enabled.py 1.0 KB

123456789101112131415161718192021
  1. import re
  2. # Python Requests is not able to do native http3 requests.
  3. # We only check for directives which should enable http3.
  4. def test_http3_global_enabled_ALTSVC_header(docker_compose, nginxproxy):
  5. r = nginxproxy.get("http://http3-global-enabled.nginx-proxy.tld/headers")
  6. assert r.status_code == 200
  7. assert "Host: http3-global-enabled.nginx-proxy.tld" in r.text
  8. assert "alt-svc" in r.headers
  9. assert r.headers["alt-svc"] == 'h3=":443"; ma=86400;'
  10. def test_http3_global_enabled_config(docker_compose, nginxproxy):
  11. conf = nginxproxy.get_conf().decode('ASCII')
  12. r = nginxproxy.get("http://http3-global-enabled.nginx-proxy.tld")
  13. assert r.status_code == 200
  14. assert re.search(r"listen 443 quic reuseport\;", conf)
  15. assert re.search(r"(?s)http3-global-enabled\.nginx-proxy\.tld;.*listen 443 quic", conf)
  16. assert re.search(r"(?s)http3-global-enabled\.nginx-proxy\.tld;.*http3 on\;", conf)
  17. assert re.search(r"(?s)http3-global-enabled\.nginx-proxy\.tld;.*add_header alt-svc \'h3=\":443\"; ma=86400;\'", conf)