1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 09:48:14 +00:00
nginx-proxy/test/test_ssl/test_cert_selection.py

26 lines
836 B
Python
Raw Normal View History

2024-12-07 20:15:44 +01:00
import json
import pytest
@pytest.mark.parametrize("host,expected_cert_ok,expected_cert", [
("nginx-proxy.tld", True, "nginx-proxy.tld"),
("web1.nginx-proxy.tld", True, "nginx-proxy.tld"),
("sub.web1.nginx-proxy.tld", False, ""),
("web2.nginx-proxy.tld", True, "web2.nginx-proxy.tld"),
])
def test_certificate_selection(
docker_compose,
nginxproxy,
host: str,
expected_cert_ok: bool,
expected_cert: str,
):
r = nginxproxy.get(f"http://{host}/nginx-proxy-debug")
assert r.status_code == 200
try:
jsonResponse = json.loads(r.text)
except ValueError as err:
pytest.fail("Failed to parse debug endpoint response as JSON:: %s" % err, pytrace=False)
assert jsonResponse["vhost"]["cert_ok"] == expected_cert_ok
assert jsonResponse["vhost"]["cert"] == expected_cert