2
0

test_per-vhost.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy):
  2. r = nginxproxy.get("http://nginx-proxy/")
  3. assert r.status_code == 503
  4. assert "X-test" not in r.headers
  5. assert "X-test-2" not in r.headers
  6. def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
  7. r = nginxproxy.get("http://web1.nginx-proxy.example/port")
  8. assert r.status_code == 200
  9. assert r.text == "answer from port 81\n"
  10. assert "X-test" in r.headers
  11. assert "X-test-2" not in r.headers
  12. assert "f00" == r.headers["X-test"]
  13. def test_custom_conf_applies_to_regex(docker_compose, nginxproxy):
  14. r = nginxproxy.get("http://foo.nginx-proxy.regex/port")
  15. assert r.status_code == 200
  16. assert r.text == "answer from port 83\n"
  17. assert "X-test" in r.headers
  18. assert "X-test-2" not in r.headers
  19. assert "bar" == r.headers["X-test"]
  20. def test_custom_conf_applies_to_wildcard(docker_compose, nginxproxy):
  21. r = nginxproxy.get("http://foo.nginx-proxy.example/port")
  22. assert r.status_code == 200
  23. assert r.text == "answer from port 84\n"
  24. # we should get the config from *.nginx-proxy.example.conf
  25. assert "X-test-2" in r.headers
  26. assert "baz" == r.headers["X-test-2"]
  27. # but not the config from web1.nginx-proxy.example.conf
  28. assert "X-test" not in r.headers
  29. def test_custom_conf_does_not_apply_to_web2(docker_compose, nginxproxy):
  30. r = nginxproxy.get("http://web2.nginx-proxy.example/port")
  31. assert r.status_code == 200
  32. assert r.text == "answer from port 82\n"
  33. assert "X-test" not in r.headers
  34. assert "X-test-2" not in r.headers