1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 17:58:16 +00:00
nginx-proxy/test/test_ssl/test_https_port.py
Povilas Kanapickas d6c38a0bab tests: Add tests for how Let's Encrypt ACME challenge is handled
At the moment no changes to functionality are done, only the current
behavior is captured.
2024-05-06 13:07:04 +03:00

29 lines
1.2 KiB
Python

import pytest
@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_http_redirects_to_https(docker_compose, nginxproxy, subdomain):
r = nginxproxy.get("http://%s.nginx-proxy.tld:8080/" % subdomain, allow_redirects=False)
assert r.status_code == 301
assert "Location" in r.headers
assert "https://%s.nginx-proxy.tld:8443/" % subdomain == r.headers['Location']
@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_https_is_forwarded(docker_compose, nginxproxy, subdomain):
r = nginxproxy.get("https://%s.nginx-proxy.tld:8443/port" % subdomain, allow_redirects=False)
assert r.status_code == 200
assert "answer from port 81\n" in r.text
def test_nonstandardport_Host_header(docker_compose, nginxproxy):
r = nginxproxy.get("https://web.nginx-proxy.tld:8443/headers")
assert r.status_code == 200
assert "Host: web.nginx-proxy.tld:8443" in r.text
@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_acme_challenge_works(docker_compose, nginxproxy, acme_challenge_path, subdomain):
r = nginxproxy.get(
f"http://{subdomain}.nginx-proxy.tld:8080/{acme_challenge_path}",
allow_redirects=False
)
assert r.status_code == 200
assert "challenge-teststring\n" in r.text