mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-08-24 08:21:55 +00:00
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.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
challenge-teststring
|
@@ -7,6 +7,7 @@ services:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./certs:/etc/nginx/certs:ro
|
||||
- ./acme_root:/usr/share/nginx/html:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from ssl import CertificateError
|
||||
from requests import ConnectionError
|
||||
from requests.exceptions import SSLError
|
||||
|
||||
|
||||
@@ -32,3 +33,25 @@ def test_https_request_to_nohttps_vhost_goes_to_fallback_server(docker_compose,
|
||||
|
||||
r = nginxproxy.get("https://3.web.nginx-proxy.tld/port", verify=False)
|
||||
assert r.status_code == 503
|
||||
|
||||
|
||||
@pytest.mark.parametrize("subdomain,acme_should_work", [
|
||||
(1, True),
|
||||
(2, True),
|
||||
(3, False),
|
||||
])
|
||||
def test_acme_challenge_works(
|
||||
docker_compose, nginxproxy, acme_challenge_path, subdomain, acme_should_work
|
||||
):
|
||||
if acme_should_work:
|
||||
r = nginxproxy.get(
|
||||
f"https://{subdomain}.web.nginx-proxy.tld/{acme_challenge_path}",
|
||||
allow_redirects=False
|
||||
)
|
||||
assert r.status_code == 404
|
||||
else:
|
||||
with pytest.raises(ConnectionError):
|
||||
nginxproxy.get(
|
||||
f"https://{subdomain}.web.nginx-proxy.tld/{acme_challenge_path}",
|
||||
allow_redirects=False
|
||||
)
|
||||
|
Reference in New Issue
Block a user