diff --git a/test/conftest.py b/test/conftest.py index 0df348b..7925ad3 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -6,16 +6,19 @@ import shlex import socket import subprocess import time -from typing import List +from typing import Iterator, List, Optional import backoff -import docker +import docker.errors import pytest import requests -from _pytest._code.code import ReprExceptionInfo -from packaging.version import Version +from _pytest.fixtures import FixtureRequest +from docker import DockerClient from docker.models.containers import Container -from requests.packages.urllib3.util.connection import HAS_IPV6 +from docker.models.networks import Network +from packaging.version import Version +from requests import Response +from urllib3.util.connection import HAS_IPV6 logging.basicConfig(level=logging.INFO) logging.getLogger('backoff').setLevel(logging.INFO) @@ -40,8 +43,9 @@ test_container = 'nginx-proxy-pytest' # ############################################################################### + @contextlib.contextmanager -def ipv6(force_ipv6=True): +def ipv6(force_ipv6: bool = True): """ Meant to be used as a context manager to force IPv6 sockets: @@ -59,10 +63,10 @@ def ipv6(force_ipv6=True): FORCE_CONTAINER_IPV6 = False -class requests_for_docker(object): +class RequestsForDocker: """ Proxy for calling methods of the requests module. - When a HTTP response failed due to HTTP Error 404 or 502, retry a few times. + When an HTTP response failed due to HTTP Error 404 or 502, retry a few times. Provides method `get_conf` to extract the nginx-proxy configuration content. """ def __init__(self): @@ -71,7 +75,7 @@ class requests_for_docker(object): self.session.verify = CA_ROOT_CERTIFICATE @staticmethod - def get_nginx_proxy_containers() -> List[Container]: + def get_nginx_proxy_container() -> Container: """ Return list of containers """ @@ -80,69 +84,69 @@ class requests_for_docker(object): pytest.fail("Too many running nginxproxy/nginx-proxy:test containers", pytrace=False) elif len(nginx_proxy_containers) == 0: pytest.fail("No running nginxproxy/nginx-proxy:test container", pytrace=False) - return nginx_proxy_containers + return nginx_proxy_containers.pop() - def get_conf(self): + def get_conf(self) -> bytes: """ Return the nginx config file """ - nginx_proxy_containers = self.get_nginx_proxy_containers() - return get_nginx_conf_from_container(nginx_proxy_containers[0]) + nginx_proxy_container = self.get_nginx_proxy_container() + return get_nginx_conf_from_container(nginx_proxy_container) def get_ip(self) -> str: """ Return the nginx container ip address """ - nginx_proxy_containers = self.get_nginx_proxy_containers() - return container_ip(nginx_proxy_containers[0]) + nginx_proxy_container = self.get_nginx_proxy_container() + return container_ip(nginx_proxy_container) - def get(self, *args, **kwargs): + def get(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _get(*args, **kwargs): - return self.session.get(*args, **kwargs) + def _get(*_args, **_kwargs): + return self.session.get(*_args, **_kwargs) return _get(*args, **kwargs) - def post(self, *args, **kwargs): + def post(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _post(*args, **kwargs): - return self.session.post(*args, **kwargs) + def _post(*_args, **_kwargs): + return self.session.post(*_args, **_kwargs) return _post(*args, **kwargs) - def put(self, *args, **kwargs): + def put(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _put(*args, **kwargs): - return self.session.put(*args, **kwargs) + def _put(*_args, **_kwargs): + return self.session.put(*_args, **_kwargs) return _put(*args, **kwargs) - def head(self, *args, **kwargs): + def head(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _head(*args, **kwargs): - return self.session.head(*args, **kwargs) + def _head(*_args, **_kwargs): + return self.session.head(*_args, **_kwargs) return _head(*args, **kwargs) - def delete(self, *args, **kwargs): + def delete(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _delete(*args, **kwargs): - return self.session.delete(*args, **kwargs) + def _delete(*_args, **_kwargs): + return self.session.delete(*_args, **_kwargs) return _delete(*args, **kwargs) - def options(self, *args, **kwargs): + def options(self, *args, **kwargs) -> Response: with ipv6(kwargs.pop('ipv6', False)): @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None) - def _options(*args, **kwargs): - return self.session.options(*args, **kwargs) + def _options(*_args, **_kwargs): + return self.session.options(*_args, **_kwargs) return _options(*args, **kwargs) def __getattr__(self, name): return getattr(requests, name) -def container_ip(container: Container): +def container_ip(container: Container) -> str: """ return the IP address of a container. @@ -171,7 +175,7 @@ def container_ip(container: Container): return net_info[network_name]["IPAddress"] -def container_ipv6(container): +def container_ipv6(container: Container) -> str: """ return the IPv6 address of a container. """ @@ -188,7 +192,7 @@ def container_ipv6(container): return net_info[network_name]["GlobalIPv6Address"] -def nginx_proxy_dns_resolver(domain_name): +def nginx_proxy_dns_resolver(domain_name: str) -> Optional[str]: """ if "nginx-proxy" if found in host, return the ip address of the docker container issued from the docker image nginxproxy/nginx-proxy:test. @@ -200,18 +204,18 @@ def nginx_proxy_dns_resolver(domain_name): if 'nginx-proxy' in domain_name: nginxproxy_containers = docker_client.containers.list(filters={"status": "running", "ancestor": "nginxproxy/nginx-proxy:test"}) if len(nginxproxy_containers) == 0: - log.warn(f"no container found from image nginxproxy/nginx-proxy:test while resolving {domain_name!r}") + log.warning(f"no container found from image nginxproxy/nginx-proxy:test while resolving {domain_name!r}") exited_nginxproxy_containers = docker_client.containers.list(filters={"status": "exited", "ancestor": "nginxproxy/nginx-proxy:test"}) if len(exited_nginxproxy_containers) > 0: exited_nginxproxy_container_logs = exited_nginxproxy_containers[0].logs() - log.warn(f"nginxproxy/nginx-proxy:test container might have exited unexpectedly. Container logs: " + "\n" + exited_nginxproxy_container_logs.decode()) - return + log.warning(f"nginxproxy/nginx-proxy:test container might have exited unexpectedly. Container logs: " + "\n" + exited_nginxproxy_container_logs.decode()) + return None nginxproxy_container = nginxproxy_containers[0] ip = container_ip(nginxproxy_container) log.info(f"resolving domain name {domain_name!r} as IP address {ip} of nginx-proxy container {nginxproxy_container.name}") return ip -def docker_container_dns_resolver(domain_name): +def docker_container_dns_resolver(domain_name: str) -> Optional[str]: """ if domain name is of the form "XXX.container.docker" or "anything.XXX.container.docker", return the ip address of the docker container named XXX. @@ -224,15 +228,15 @@ def docker_container_dns_resolver(domain_name): match = re.search(r'(^|.+\.)(?P[^.]+)\.container\.docker$', domain_name) if not match: log.debug(f"{domain_name!r} does not match") - return + return None container_name = match.group('container') log.debug(f"looking for container {container_name!r}") try: container = docker_client.containers.get(container_name) except docker.errors.NotFound: - log.warn(f"container named {container_name!r} not found while resolving {domain_name!r}") - return + log.warning(f"container named {container_name!r} not found while resolving {domain_name!r}") + return None log.debug(f"container {container.name!r} found ({container.short_id})") ip = container_ip(container) @@ -252,7 +256,7 @@ def monkey_patch_urllib_dns_resolver(): logging.getLogger('DNS').debug(f"resolving domain name {repr(args)}") _args = list(args) - # Fail early when querying IP directly and it is forced ipv6 when not supported, + # Fail early when querying IP directly, and it is forced ipv6 when not supported, # Otherwise a pytest container not using the host network fails to pass `test_raw-ip-vhost`. if FORCE_CONTAINER_IPV6 and not HAS_IPV6: pytest.skip("This system does not support IPv6") @@ -274,19 +278,12 @@ def monkey_patch_urllib_dns_resolver(): socket.getaddrinfo = new_getaddrinfo return prv_getaddrinfo + def restore_urllib_dns_resolver(getaddrinfo_func): socket.getaddrinfo = getaddrinfo_func -def remove_all_containers(): - for container in docker_client.containers.list(all=True): - if PYTEST_RUNNING_IN_CONTAINER and container.name == test_container: - continue # pytest is running within a Docker container, so we do not want to remove that particular container - logging.info(f"removing container {container.name}") - container.remove(v=True, force=True) - - -def get_nginx_conf_from_container(container): +def get_nginx_conf_from_container(container: Container) -> bytes: """ return the nginx /etc/nginx/conf.d/default.conf file content from a container """ @@ -301,20 +298,20 @@ def get_nginx_conf_from_container(container): return conffile.read() -def docker_compose_up(compose_file='docker-compose.yml'): +def docker_compose_up(compose_file: str): logging.info(f'{DOCKER_COMPOSE} -f {compose_file} up -d') try: subprocess.check_output(shlex.split(f'{DOCKER_COMPOSE} -f {compose_file} up -d'), stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - pytest.fail(f"Error while runninng '{DOCKER_COMPOSE} -f {compose_file} up -d':\n{e.output}", pytrace=False) + pytest.fail(f"Error while running '{DOCKER_COMPOSE} -f {compose_file} up -d':\n{e.output}", pytrace=False) -def docker_compose_down(compose_file='docker-compose.yml'): +def docker_compose_down(compose_file: str): logging.info(f'{DOCKER_COMPOSE} -f {compose_file} down -v') try: subprocess.check_output(shlex.split(f'{DOCKER_COMPOSE} -f {compose_file} down -v'), stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: - pytest.fail(f"Error while runninng '{DOCKER_COMPOSE} -f {compose_file} down -v':\n{e.output}", pytrace=False) + pytest.fail(f"Error while running '{DOCKER_COMPOSE} -f {compose_file} down -v':\n{e.output}", pytrace=False) def wait_for_nginxproxy_to_be_ready(): @@ -333,7 +330,7 @@ def wait_for_nginxproxy_to_be_ready(): @pytest.fixture -def docker_compose_file(request): +def docker_compose_file(request: FixtureRequest) -> Iterator[Optional[str]]: """Fixture naming the docker compose file to consider. If a YAML file exists with the same name as the test module (with the `.py` extension replaced @@ -343,25 +340,28 @@ def docker_compose_file(request): Tests can override this fixture to specify a custom location. """ test_module_dir = os.path.dirname(request.module.__file__) - yml_file = os.path.join(test_module_dir, request.module.__name__ + '.yml') - yaml_file = os.path.join(test_module_dir, request.module.__name__ + '.yaml') + yml_file = os.path.join(test_module_dir, f"{request.module.__name__}.yml") + yaml_file = os.path.join(test_module_dir, f"{request.module.__name__}.yaml") default_file = os.path.join(test_module_dir, 'docker-compose.yml') + docker_compose_file = None + if os.path.isfile(yml_file): docker_compose_file = yml_file elif os.path.isfile(yaml_file): docker_compose_file = yaml_file - else: + elif os.path.isfile(default_file): docker_compose_file = default_file - if not os.path.isfile(docker_compose_file): + if docker_compose_file is None: logging.error("Could not find any docker compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__)) + else: + logging.debug(f"using docker compose file {docker_compose_file}") - logging.debug(f"using docker compose file {docker_compose_file}") - return docker_compose_file + yield docker_compose_file -def connect_to_network(network): +def connect_to_network(network: Network) -> Optional[Network]: """ If we are running from a container, connect our container to the given network @@ -371,8 +371,8 @@ def connect_to_network(network): try: my_container = docker_client.containers.get(test_container) except docker.errors.NotFound: - logging.warn(f"container {test_container} not found") - return + logging.warning(f"container {test_container} not found") + return None # figure out our container networks my_networks = list(my_container.attrs["NetworkSettings"]["Networks"].keys()) @@ -389,7 +389,7 @@ def connect_to_network(network): return network -def disconnect_from_network(network=None): +def disconnect_from_network(network: Network = None): """ If we are running from a container, disconnect our container from the given network. @@ -399,7 +399,7 @@ def disconnect_from_network(network=None): try: my_container = docker_client.containers.get(test_container) except docker.errors.NotFound: - logging.warn(f"container {test_container} not found") + logging.warning(f"container {test_container} not found") return # figure out our container networks @@ -411,7 +411,7 @@ def disconnect_from_network(network=None): network.disconnect(my_container) -def connect_to_all_networks(): +def connect_to_all_networks() -> List[Network]: """ If we are running from a container, connect our container to all current docker networks. @@ -427,6 +427,7 @@ def connect_to_all_networks(): class DockerComposer(contextlib.AbstractContextManager): def __init__(self): + self._networks = None self._docker_compose_file = None def __exit__(self, *exc_info): @@ -440,13 +441,12 @@ class DockerComposer(contextlib.AbstractContextManager): docker_compose_down(self._docker_compose_file) self._docker_compose_file = None - def compose(self, docker_compose_file): + def compose(self, docker_compose_file: Optional[str]): if docker_compose_file == self._docker_compose_file: return self._down() if docker_compose_file is None: return - remove_all_containers() docker_compose_up(docker_compose_file) self._networks = connect_to_all_networks() wait_for_nginxproxy_to_be_ready() @@ -462,14 +462,14 @@ class DockerComposer(contextlib.AbstractContextManager): @pytest.fixture(scope="module") -def docker_composer(): +def docker_composer() -> Iterator[DockerComposer]: with DockerComposer() as d: yield d @pytest.fixture -def ca_root_certificate(): - return CA_ROOT_CERTIFICATE +def ca_root_certificate() -> Iterator[str]: + yield CA_ROOT_CERTIFICATE @pytest.fixture @@ -480,7 +480,7 @@ def monkey_patched_dns(): @pytest.fixture -def docker_compose(monkey_patched_dns, docker_composer, docker_compose_file): +def docker_compose(monkey_patched_dns, docker_composer, docker_compose_file) -> Iterator[DockerClient]: """Ensures containers described in a docker compose file are started. A custom docker compose file name can be specified by overriding the `docker_compose_file` @@ -493,12 +493,12 @@ def docker_compose(monkey_patched_dns, docker_composer, docker_compose_file): yield docker_client -@pytest.fixture() -def nginxproxy(): +@pytest.fixture +def nginxproxy() -> Iterator[RequestsForDocker]: """ Provides the `nginxproxy` object that can be used in the same way the requests module is: - r = nginxproxy.get("http://foo.com") + r = nginxproxy.get("https://foo.com") The difference is that in case an HTTP requests has status code 404 or 502 (which mostly indicates that nginx has just reloaded), we retry up to 30 times the query. @@ -507,15 +507,15 @@ def nginxproxy(): made against containers to use the containers IPv6 address when set to `True`. If IPv6 is not supported by the system or docker, that particular test will be skipped. """ - yield requests_for_docker() + yield RequestsForDocker() -@pytest.fixture() -def acme_challenge_path(): +@pytest.fixture +def acme_challenge_path() -> Iterator[str]: """ Provides fake Let's Encrypt ACME challenge path used in certain tests """ - return ".well-known/acme-challenge/test-filename" + yield ".well-known/acme-challenge/test-filename" ############################################################################### # @@ -523,14 +523,13 @@ def acme_challenge_path(): # ############################################################################### -# pytest hook to display additionnal stuff in test report +# pytest hook to display additional stuff in test report def pytest_runtest_logreport(report): if report.failed: - if isinstance(report.longrepr, ReprExceptionInfo): - test_containers = docker_client.containers.list(all=True, filters={"ancestor": "nginxproxy/nginx-proxy:test"}) - for container in test_containers: - report.longrepr.addsection('nginx-proxy logs', container.logs()) - report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container)) + test_containers = docker_client.containers.list(all=True, filters={"ancestor": "nginxproxy/nginx-proxy:test"}) + for container in test_containers: + report.longrepr.addsection('nginx-proxy logs', container.logs().decode()) + report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container).decode()) # Py.test `incremental` marker, see http://stackoverflow.com/a/12579625/107049 diff --git a/test/pytest.sh b/test/pytest.sh index 9cbe750..30e40de 100755 --- a/test/pytest.sh +++ b/test/pytest.sh @@ -3,7 +3,7 @@ # # # This script is meant to run the test suite from a Docker container. # # # -# This is usefull when you want to run the test suite from Mac or # +# This is useful when you want to run the test suite from Mac or # # Docker Toolbox. # # # ############################################################################### diff --git a/test/requirements/python-requirements.txt b/test/requirements/python-requirements.txt index be22342..e909603 100644 --- a/test/requirements/python-requirements.txt +++ b/test/requirements/python-requirements.txt @@ -1,4 +1,6 @@ backoff==2.2.1 docker==7.1.0 +packaging==24.2 pytest==8.3.4 requests==2.32.3 +urllib3==2.3.0 diff --git a/test/requirements/web/webserver.py b/test/requirements/web/webserver.py index c4750bd..3b584ed 100755 --- a/test/requirements/web/webserver.py +++ b/test/requirements/web/webserver.py @@ -28,7 +28,7 @@ class Handler(http.server.SimpleHTTPRequestHandler): self.send_header("Content-Type", "text/plain") self.end_headers() - if (len(response_body)): + if len(response_body): self.wfile.write(response_body.encode()) if __name__ == '__main__': diff --git a/test/stress_tests/README.md b/test/stress_tests/README.md deleted file mode 100644 index ca20cc1..0000000 --- a/test/stress_tests/README.md +++ /dev/null @@ -1 +0,0 @@ -This directory contains tests that showcase scenarios known to break the expected behavior of nginx-proxy. \ No newline at end of file diff --git a/test/test_acme_http_challenge_location/acme_root/.well-known/acme-challenge/test-filename b/test/test_acme-http-challenge-location/acme_root/.well-known/acme-challenge/test-filename similarity index 100% rename from test/test_acme_http_challenge_location/acme_root/.well-known/acme-challenge/test-filename rename to test/test_acme-http-challenge-location/acme_root/.well-known/acme-challenge/test-filename diff --git a/test/test_acme_http_challenge_location/certs/nginx-proxy.tld.crt b/test/test_acme-http-challenge-location/certs/nginx-proxy.tld.crt similarity index 100% rename from test/test_acme_http_challenge_location/certs/nginx-proxy.tld.crt rename to test/test_acme-http-challenge-location/certs/nginx-proxy.tld.crt diff --git a/test/test_acme_http_challenge_location/certs/nginx-proxy.tld.key b/test/test_acme-http-challenge-location/certs/nginx-proxy.tld.key similarity index 100% rename from test/test_acme_http_challenge_location/certs/nginx-proxy.tld.key rename to test/test_acme-http-challenge-location/certs/nginx-proxy.tld.key diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_disabled.py b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-disabled.py similarity index 98% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_disabled.py rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-disabled.py index acbc8fe..ae12fa6 100644 --- a/test/test_acme_http_challenge_location/test_acme_challenge_location_disabled.py +++ b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-disabled.py @@ -1,6 +1,3 @@ -import pytest - - def test_redirect_acme_challenge_location_disabled(docker_compose, nginxproxy, acme_challenge_path): r = nginxproxy.get( f"http://web1.nginx-proxy.tld/{acme_challenge_path}", diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_disabled.yml b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-disabled.yml similarity index 100% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_disabled.yml rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-disabled.yml diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_enabled_is_default.py b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-enabled-is-default.py similarity index 98% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_enabled_is_default.py rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-enabled-is-default.py index fd06e84..88cb07d 100644 --- a/test/test_acme_http_challenge_location/test_acme_challenge_location_enabled_is_default.py +++ b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-enabled-is-default.py @@ -1,6 +1,3 @@ -import pytest - - def test_redirect_acme_challenge_location_enabled(docker_compose, nginxproxy, acme_challenge_path): r = nginxproxy.get( f"http://web1.nginx-proxy.tld/{acme_challenge_path}", diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_enabled_is_default.yml b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-enabled-is-default.yml similarity index 100% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_enabled_is_default.yml rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-enabled-is-default.yml diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_legacy.py b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-legacy.py similarity index 96% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_legacy.py rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-legacy.py index d2051d0..ed9f25a 100644 --- a/test/test_acme_http_challenge_location/test_acme_challenge_location_legacy.py +++ b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-legacy.py @@ -1,6 +1,3 @@ -import pytest - - def test_redirect_acme_challenge_location_legacy(docker_compose, nginxproxy, acme_challenge_path): r = nginxproxy.get( f"http://web1.nginx-proxy.tld/{acme_challenge_path}", diff --git a/test/test_acme_http_challenge_location/test_acme_challenge_location_legacy.yml b/test/test_acme-http-challenge-location/test_acme-http-challenge-location-legacy.yml similarity index 100% rename from test/test_acme_http_challenge_location/test_acme_challenge_location_legacy.yml rename to test/test_acme-http-challenge-location/test_acme-http-challenge-location-legacy.yml diff --git a/test/test_build.py b/test/test_build/test_build.py similarity index 90% rename from test/test_build.py rename to test/test_build/test_build.py index 4052d1e..3931fcd 100644 --- a/test/test_build.py +++ b/test/test_build/test_build.py @@ -1,22 +1,25 @@ """ Test that nginx-proxy-tester can build successfully """ -import pytest -import docker +import pathlib import re -import os + +import docker +import pytest + client = docker.from_env() @pytest.fixture(scope = "session") def docker_build(request): # Define Dockerfile path - dockerfile_path = os.path.join(os.path.dirname(__file__), "requirements/") + current_file_path = pathlib.Path(__file__) + dockerfile_path = current_file_path.parent.parent.joinpath("requirements") dockerfile_name = "Dockerfile-nginx-proxy-tester" # Build the Docker image image, logs = client.images.build( - path = dockerfile_path, + path = dockerfile_path.as_posix(), dockerfile = dockerfile_name, rm = True, # Remove intermediate containers tag = "nginx-proxy-tester-ci", # Tag for the built image diff --git a/test/test_custom-error-page/test_custom-error-page.py b/test/test_custom-error-page/test_custom-error-page.py index 32cb0b5..6317aea 100644 --- a/test/test_custom-error-page/test_custom-error-page.py +++ b/test/test_custom-error-page/test_custom-error-page.py @@ -1,4 +1,3 @@ -import pytest import re diff --git a/test/test_custom/test_defaults-location.py b/test/test_custom/test_defaults-location.py index 5af359d..94d0fa1 100644 --- a/test/test_custom/test_defaults-location.py +++ b/test/test_custom/test_defaults-location.py @@ -1,5 +1,3 @@ -import pytest - def test_custom_default_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") assert r.status_code == 503 diff --git a/test/test_custom/test_defaults-location.yml b/test/test_custom/test_defaults-location.yml index 6247a25..e08bcd4 100644 --- a/test/test_custom/test_defaults-location.yml +++ b/test/test_custom/test_defaults-location.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example web2: @@ -19,7 +19,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example web3: @@ -27,5 +27,5 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: web3.nginx-proxy.example diff --git a/test/test_custom/test_defaults.py b/test/test_custom/test_defaults.py index c9cb2df..dc0fec9 100644 --- a/test/test_custom/test_defaults.py +++ b/test/test_custom/test_defaults.py @@ -1,5 +1,3 @@ -import pytest - def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") assert r.status_code == 503 diff --git a/test/test_custom/test_defaults.yml b/test/test_custom/test_defaults.yml index 9733b55..cc7a2aa 100644 --- a/test/test_custom/test_defaults.yml +++ b/test/test_custom/test_defaults.yml @@ -10,7 +10,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example web2: @@ -18,5 +18,5 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example diff --git a/test/test_custom/test_location-per-vhost.py b/test/test_custom/test_location-per-vhost.py index 8218ed0..20d033a 100644 --- a/test/test_custom/test_location-per-vhost.py +++ b/test/test_custom/test_location-per-vhost.py @@ -1,5 +1,3 @@ -import pytest - def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") assert r.status_code == 503 diff --git a/test/test_custom/test_location-per-vhost.yml b/test/test_custom/test_location-per-vhost.yml index ef0380a..6a6ce0c 100644 --- a/test/test_custom/test_location-per-vhost.yml +++ b/test/test_custom/test_location-per-vhost.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example web2: @@ -19,7 +19,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example regex: @@ -27,5 +27,5 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$ diff --git a/test/test_custom/test_per-vhost.py b/test/test_custom/test_per-vhost.py index 7394472..24dd437 100644 --- a/test/test_custom/test_per-vhost.py +++ b/test/test_custom/test_per-vhost.py @@ -1,5 +1,3 @@ -import pytest - def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") assert r.status_code == 503 diff --git a/test/test_custom/test_per-vhost.yml b/test/test_custom/test_per-vhost.yml index c01ba05..da5f468 100644 --- a/test/test_custom/test_per-vhost.yml +++ b/test/test_custom/test_per-vhost.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example web2: @@ -19,7 +19,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example regex: @@ -27,5 +27,5 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$ diff --git a/test/test_custom/test_proxy-wide.py b/test/test_custom/test_proxy-wide.py index c9cb2df..dc0fec9 100644 --- a/test/test_custom/test_proxy-wide.py +++ b/test/test_custom/test_proxy-wide.py @@ -1,5 +1,3 @@ -import pytest - def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") assert r.status_code == 503 diff --git a/test/test_custom/test_proxy-wide.yml b/test/test_custom/test_proxy-wide.yml index 8c81782..199c517 100644 --- a/test/test_custom/test_proxy-wide.yml +++ b/test/test_custom/test_proxy-wide.yml @@ -10,7 +10,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example web2: @@ -18,5 +18,5 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example diff --git a/test/test_debug_endpoint/test_global.py b/test/test_debug-endpoint/test_global.py similarity index 99% rename from test/test_debug_endpoint/test_global.py rename to test/test_debug-endpoint/test_global.py index aaa7b1f..cf0f8b7 100644 --- a/test/test_debug_endpoint/test_global.py +++ b/test/test_debug-endpoint/test_global.py @@ -1,6 +1,8 @@ import json + import pytest + def test_debug_endpoint_is_enabled_globally(docker_compose, nginxproxy): r = nginxproxy.get("http://enabled.debug.nginx-proxy.example/nginx-proxy-debug") assert r.status_code == 200 diff --git a/test/test_debug_endpoint/test_global.yml b/test/test_debug-endpoint/test_global.yml similarity index 92% rename from test/test_debug_endpoint/test_global.yml rename to test/test_debug-endpoint/test_global.yml index 1797038..5fd2d81 100644 --- a/test/test_debug_endpoint/test_global.yml +++ b/test/test_debug-endpoint/test_global.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: enabled.debug.nginx-proxy.example debug_stripped: @@ -19,7 +19,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST_MULTIPORTS: |- stripped.debug.nginx-proxy.example: "/1": @@ -48,7 +48,7 @@ services: expose: - "84" environment: - WEB_PORTS: 84 + WEB_PORTS: "84" VIRTUAL_HOST: ~^regexp.*\.debug.nginx-proxy.example debug_disabled: @@ -56,7 +56,7 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: disabled.debug.nginx-proxy.example labels: com.github.nginx-proxy.nginx-proxy.debug-endpoint: "false" diff --git a/test/test_debug_endpoint/test_per_container.py b/test/test_debug-endpoint/test_per-container.py similarity index 99% rename from test/test_debug_endpoint/test_per_container.py rename to test/test_debug-endpoint/test_per-container.py index 16c680c..ffc4db1 100644 --- a/test/test_debug_endpoint/test_per_container.py +++ b/test/test_debug-endpoint/test_per-container.py @@ -1,6 +1,8 @@ import json + import pytest + def test_debug_endpoint_is_disabled_globally(docker_compose, nginxproxy): r = nginxproxy.get("http://disabled1.debug.nginx-proxy.example/nginx-proxy-debug") assert r.status_code == 404 diff --git a/test/test_debug_endpoint/test_per_container.yml b/test/test_debug-endpoint/test_per-container.yml similarity index 90% rename from test/test_debug_endpoint/test_per_container.yml rename to test/test_debug-endpoint/test_per-container.yml index 56c975c..5992e24 100644 --- a/test/test_debug_endpoint/test_per_container.yml +++ b/test/test_debug-endpoint/test_per-container.yml @@ -9,7 +9,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: disabled1.debug.nginx-proxy.example debug_disabled2: @@ -17,7 +17,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: disabled2.debug.nginx-proxy.example @@ -26,7 +26,7 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: enabled.debug.nginx-proxy.example labels: com.github.nginx-proxy.nginx-proxy.debug-endpoint: "true" diff --git a/test/test_default-host.py b/test/test_default-host/test_default-host.py similarity index 92% rename from test/test_default-host.py rename to test/test_default-host/test_default-host.py index 90809a5..560baf7 100644 --- a/test/test_default-host.py +++ b/test/test_default-host/test_default-host.py @@ -1,6 +1,3 @@ -import pytest - - def test_fallback_on_default(docker_compose, nginxproxy): r = nginxproxy.get("http://unknown.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_default-host.yml b/test/test_default-host/test_default-host.yml similarity index 94% rename from test/test_default-host.yml rename to test/test_default-host/test_default-host.yml index 61b2504..0c0d24c 100644 --- a/test/test_default-host.yml +++ b/test/test_default-host/test_default-host.yml @@ -5,7 +5,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.tld # WHEN nginx-proxy runs with DEFAULT_HOST set to web1.tld diff --git a/test/test_DOCKER_HOST_unix_socket.py b/test/test_docker-unix-socket/test_docker-unix-socket.py similarity index 97% rename from test/test_DOCKER_HOST_unix_socket.py rename to test/test_docker-unix-socket/test_docker-unix-socket.py index b31da16..c7e7211 100644 --- a/test/test_DOCKER_HOST_unix_socket.py +++ b/test/test_docker-unix-socket/test_docker-unix-socket.py @@ -1,5 +1,3 @@ -import pytest - def test_unknown_virtual_host(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/port") assert r.status_code == 503 diff --git a/test/test_DOCKER_HOST_unix_socket.yml b/test/test_docker-unix-socket/test_docker-unix-socket.yml similarity index 89% rename from test/test_DOCKER_HOST_unix_socket.yml rename to test/test_docker-unix-socket/test_docker-unix-socket.yml index 1c410dc..b86d94c 100644 --- a/test/test_DOCKER_HOST_unix_socket.yml +++ b/test/test_docker-unix-socket/test_docker-unix-socket.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.tld web2: @@ -12,7 +12,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.tld sut: diff --git a/test/test_dockergen/.gitignore b/test/test_dockergen/.gitignore deleted file mode 100644 index 98c0b06..0000000 --- a/test/test_dockergen/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nginx.tmpl \ No newline at end of file diff --git a/test/test_dockergen/test_dockergen.yml b/test/test_dockergen/test_dockergen.yml index 9b96bb2..f046dbe 100644 --- a/test/test_dockergen/test_dockergen.yml +++ b/test/test_dockergen/test_dockergen.yml @@ -19,7 +19,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: whoami.nginx.container.docker volumes: diff --git a/test/test_enable_http_on_missing_cert.py b/test/test_enable-http-on-missing-cert/test_enable-http-on-missing-cert.py similarity index 98% rename from test/test_enable_http_on_missing_cert.py rename to test/test_enable-http-on-missing-cert/test_enable-http-on-missing-cert.py index cdedc8a..cda948c 100644 --- a/test/test_enable_http_on_missing_cert.py +++ b/test/test_enable-http-on-missing-cert/test_enable-http-on-missing-cert.py @@ -1,6 +1,3 @@ -import pytest - - def test_nohttp_missing_cert_disabled(docker_compose, nginxproxy): r = nginxproxy.get("http://nohttp-missing-cert-disabled.nginx-proxy.tld/", allow_redirects=False) assert r.status_code == 503 diff --git a/test/test_enable_http_on_missing_cert.yml b/test/test_enable-http-on-missing-cert/test_enable-http-on-missing-cert.yml similarity index 100% rename from test/test_enable_http_on_missing_cert.yml rename to test/test_enable-http-on-missing-cert/test_enable-http-on-missing-cert.yml diff --git a/test/test_events.py b/test/test_events/test_events.py similarity index 93% rename from test/test_events.py rename to test/test_events/test_events.py index 9b99e93..e137c87 100644 --- a/test/test_events.py +++ b/test/test_events/test_events.py @@ -7,7 +7,7 @@ import pytest from docker.errors import NotFound -@pytest.fixture() +@pytest.fixture def web1(docker_compose): """ pytest fixture creating a web container with `VIRTUAL_HOST=web1.nginx-proxy` listening on port 81. @@ -22,7 +22,7 @@ def web1(docker_compose): }, ports={"81/tcp": None} ) - docker_compose.networks.get("test_default").connect(container) + docker_compose.networks.get("test_events-net").connect(container) sleep(2) # give it some time to initialize and for docker-gen to detect it yield container try: @@ -30,7 +30,7 @@ def web1(docker_compose): except NotFound: pass -@pytest.fixture() +@pytest.fixture def web2(docker_compose): """ pytest fixture creating a web container with `VIRTUAL_HOST=nginx-proxy`, `VIRTUAL_PATH=/web2/` and `VIRTUAL_DEST=/` listening on port 82. @@ -47,7 +47,7 @@ def web2(docker_compose): }, ports={"82/tcp": None} ) - docker_compose.networks.get("test_default").connect(container) + docker_compose.networks.get("test_events-net").connect(container) sleep(2) # give it some time to initialize and for docker-gen to detect it yield container try: diff --git a/test/test_events.yml b/test/test_events/test_events.yml similarity index 72% rename from test/test_events.yml rename to test/test_events/test_events.yml index e0d0fbb..b8a6274 100644 --- a/test/test_events.yml +++ b/test/test_events/test_events.yml @@ -1,3 +1,7 @@ +networks: + default: + name: test_events-net + services: nginxproxy: image: nginxproxy/nginx-proxy:test diff --git a/test/test_fallback.data/custom-fallback.conf b/test/test_fallback/test_fallback.data/custom-fallback.conf similarity index 100% rename from test/test_fallback.data/custom-fallback.conf rename to test/test_fallback/test_fallback.data/custom-fallback.conf diff --git a/test/test_fallback.data/custom-fallback.yml b/test/test_fallback/test_fallback.data/custom-fallback.yml similarity index 100% rename from test/test_fallback.data/custom-fallback.yml rename to test/test_fallback/test_fallback.data/custom-fallback.yml diff --git a/test/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.crt diff --git a/test/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/nodefault.certs/http-only.nginx-proxy.test.key diff --git a/test/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.crt diff --git a/test/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/nodefault.certs/https-and-http.nginx-proxy.test.key diff --git a/test/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.crt diff --git a/test/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/nodefault.certs/https-only.nginx-proxy.test.key diff --git a/test/test_fallback.data/nodefault.yml b/test/test_fallback/test_fallback.data/nodefault.yml similarity index 100% rename from test/test_fallback.data/nodefault.yml rename to test/test_fallback/test_fallback.data/nodefault.yml diff --git a/test/test_fallback.data/nohttp-on-app.yml b/test/test_fallback/test_fallback.data/nohttp-on-app.yml similarity index 100% rename from test/test_fallback.data/nohttp-on-app.yml rename to test/test_fallback/test_fallback.data/nohttp-on-app.yml diff --git a/test/test_fallback.data/nohttp-with-missing-cert.yml b/test/test_fallback/test_fallback.data/nohttp-with-missing-cert.yml similarity index 100% rename from test/test_fallback.data/nohttp-with-missing-cert.yml rename to test/test_fallback/test_fallback.data/nohttp-with-missing-cert.yml diff --git a/test/test_fallback.data/nohttp.yml b/test/test_fallback/test_fallback.data/nohttp.yml similarity index 100% rename from test/test_fallback.data/nohttp.yml rename to test/test_fallback/test_fallback.data/nohttp.yml diff --git a/test/test_fallback.data/nohttps-on-app.yml b/test/test_fallback/test_fallback.data/nohttps-on-app.yml similarity index 100% rename from test/test_fallback.data/nohttps-on-app.yml rename to test/test_fallback/test_fallback.data/nohttps-on-app.yml diff --git a/test/test_fallback.data/nohttps.yml b/test/test_fallback/test_fallback.data/nohttps.yml similarity index 100% rename from test/test_fallback.data/nohttps.yml rename to test/test_fallback/test_fallback.data/nohttps.yml diff --git a/test/test_fallback.data/untrusteddefault.yml b/test/test_fallback/test_fallback.data/untrusteddefault.yml similarity index 100% rename from test/test_fallback.data/untrusteddefault.yml rename to test/test_fallback/test_fallback.data/untrusteddefault.yml diff --git a/test/test_fallback.data/withdefault.certs/default.crt b/test/test_fallback/test_fallback.data/withdefault.certs/default.crt similarity index 100% rename from test/test_fallback.data/withdefault.certs/default.crt rename to test/test_fallback/test_fallback.data/withdefault.certs/default.crt diff --git a/test/test_fallback.data/withdefault.certs/default.key b/test/test_fallback/test_fallback.data/withdefault.certs/default.key similarity index 100% rename from test/test_fallback.data/withdefault.certs/default.key rename to test/test_fallback/test_fallback.data/withdefault.certs/default.key diff --git a/test/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.crt diff --git a/test/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/withdefault.certs/http-only.nginx-proxy.test.key diff --git a/test/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.crt diff --git a/test/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/withdefault.certs/https-and-http.nginx-proxy.test.key diff --git a/test/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.crt b/test/test_fallback/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.crt similarity index 100% rename from test/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.crt rename to test/test_fallback/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.crt diff --git a/test/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.key b/test/test_fallback/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.key similarity index 100% rename from test/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.key rename to test/test_fallback/test_fallback.data/withdefault.certs/https-only.nginx-proxy.test.key diff --git a/test/test_fallback.data/withdefault.yml b/test/test_fallback/test_fallback.data/withdefault.yml similarity index 100% rename from test/test_fallback.data/withdefault.yml rename to test/test_fallback/test_fallback.data/withdefault.yml diff --git a/test/test_fallback.py b/test/test_fallback/test_fallback.py similarity index 100% rename from test/test_fallback.py rename to test/test_fallback/test_fallback.py diff --git a/test/test_headers/test_http.yml b/test/test_headers/test_http.yml index bc18b86..eaef1aa 100644 --- a/test/test_headers/test_http.yml +++ b/test/test_headers/test_http.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld web-server-tokens-off: @@ -12,7 +12,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld SERVER_TOKENS: "off" diff --git a/test/test_headers/test_https.yml b/test/test_headers/test_https.yml index cd9a513..182c47b 100644 --- a/test/test_headers/test_https.yml +++ b/test/test_headers/test_https.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld web-server-tokens-off: @@ -12,7 +12,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld SERVER_TOKENS: "off" diff --git a/test/test_host-network-mode/test_host-network-mode.py b/test/test_host-network-mode/test_host-network-mode.py index 0c21348..c80fbf0 100644 --- a/test/test_host-network-mode/test_host-network-mode.py +++ b/test/test_host-network-mode/test_host-network-mode.py @@ -1,6 +1,3 @@ -import pytest - - def test_forwards_to_bridge_network_container(docker_compose, nginxproxy): r = nginxproxy.get("http://bridge-network.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_host-network-mode/test_proxy-host-network-mode.py b/test/test_host-network-mode/test_proxy-host-network-mode.py index 330334b..0c8bf65 100644 --- a/test/test_host-network-mode/test_proxy-host-network-mode.py +++ b/test/test_host-network-mode/test_proxy-host-network-mode.py @@ -1,6 +1,3 @@ -import pytest - - def test_forwards_to_host_network_container_1(docker_compose, nginxproxy): r = nginxproxy.get("http://host-network-1.nginx-proxy.tld:8888/port") assert r.status_code == 200 diff --git a/test/test_htpasswd/test_htpasswd_regex_virtual_host.py b/test/test_htpasswd/test_htpasswd-regex-virtual-host.py similarity index 97% rename from test/test_htpasswd/test_htpasswd_regex_virtual_host.py rename to test/test_htpasswd/test_htpasswd-regex-virtual-host.py index 1b169d0..b82055f 100644 --- a/test/test_htpasswd/test_htpasswd_regex_virtual_host.py +++ b/test/test_htpasswd/test_htpasswd-regex-virtual-host.py @@ -1,5 +1,3 @@ -import pytest - def test_htpasswd_regex_virtual_host_is_restricted(docker_compose, nginxproxy): r = nginxproxy.get("http://regex.htpasswd.nginx-proxy.example/port") assert r.status_code == 401 diff --git a/test/test_htpasswd/test_htpasswd_regex_virtual_host.yml b/test/test_htpasswd/test_htpasswd-regex-virtual-host.yml similarity index 93% rename from test/test_htpasswd/test_htpasswd_regex_virtual_host.yml rename to test/test_htpasswd/test_htpasswd-regex-virtual-host.yml index 8eb9012..8ea4111 100644 --- a/test/test_htpasswd/test_htpasswd_regex_virtual_host.yml +++ b/test/test_htpasswd/test_htpasswd-regex-virtual-host.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: ~^regex.*\.nginx-proxy\.example$ sut: diff --git a/test/test_htpasswd/test_htpasswd_virtual_host.py b/test/test_htpasswd/test_htpasswd-virtual-host.py similarity index 97% rename from test/test_htpasswd/test_htpasswd_virtual_host.py rename to test/test_htpasswd/test_htpasswd-virtual-host.py index aff3a62..cfb9934 100644 --- a/test/test_htpasswd/test_htpasswd_virtual_host.py +++ b/test/test_htpasswd/test_htpasswd-virtual-host.py @@ -1,5 +1,3 @@ -import pytest - def test_htpasswd_virtual_host_is_restricted(docker_compose, nginxproxy): r = nginxproxy.get("http://htpasswd.nginx-proxy.tld/port") assert r.status_code == 401 diff --git a/test/test_htpasswd/test_htpasswd_virtual_host.yml b/test/test_htpasswd/test_htpasswd-virtual-host.yml similarity index 93% rename from test/test_htpasswd/test_htpasswd_virtual_host.yml rename to test/test_htpasswd/test_htpasswd-virtual-host.yml index 5848194..a2cda6e 100644 --- a/test/test_htpasswd/test_htpasswd_virtual_host.yml +++ b/test/test_htpasswd/test_htpasswd-virtual-host.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: htpasswd.nginx-proxy.tld sut: diff --git a/test/test_htpasswd/test_htpasswd_virtual_path.py b/test/test_htpasswd/test_htpasswd-virtual-path.py similarity index 97% rename from test/test_htpasswd/test_htpasswd_virtual_path.py rename to test/test_htpasswd/test_htpasswd-virtual-path.py index 262b314..da5b4fb 100644 --- a/test/test_htpasswd/test_htpasswd_virtual_path.py +++ b/test/test_htpasswd/test_htpasswd-virtual-path.py @@ -1,5 +1,3 @@ -import pytest - def test_htpasswd_virtual_path_is_restricted(docker_compose, nginxproxy): r = nginxproxy.get("http://htpasswd.nginx-proxy.tld/foo/port") assert r.status_code == 401 diff --git a/test/test_htpasswd/test_htpasswd_virtual_path.yml b/test/test_htpasswd/test_htpasswd-virtual-path.yml similarity index 93% rename from test/test_htpasswd/test_htpasswd_virtual_path.yml rename to test/test_htpasswd/test_htpasswd-virtual-path.yml index 65fc278..457cdc5 100644 --- a/test/test_htpasswd/test_htpasswd_virtual_path.yml +++ b/test/test_htpasswd/test_htpasswd-virtual-path.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: htpasswd.nginx-proxy.tld VIRTUAL_PATH: /foo/ VIRTUAL_DEST: / diff --git a/test/test_http_port.py b/test/test_http-port/test_http-port.py similarity index 100% rename from test/test_http_port.py rename to test/test_http-port/test_http-port.py diff --git a/test/test_http_port.yml b/test/test_http-port/test_http-port.yml similarity index 100% rename from test/test_http_port.yml rename to test/test_http-port/test_http-port.yml diff --git a/test/test_http2/test_http2_global_disabled.py b/test/test_http2/test_http2-global-disabled.py similarity index 95% rename from test/test_http2/test_http2_global_disabled.py rename to test/test_http2/test_http2-global-disabled.py index 42e102d..e099603 100644 --- a/test/test_http2/test_http2_global_disabled.py +++ b/test/test_http2/test_http2-global-disabled.py @@ -1,6 +1,6 @@ -import pytest import re + def test_http2_global_disabled_config(docker_compose, nginxproxy): conf = nginxproxy.get_conf().decode('ASCII') r = nginxproxy.get("http://http2-global-disabled.nginx-proxy.tld") diff --git a/test/test_http2/test_http2_global_disabled.yml b/test/test_http2/test_http2-global-disabled.yml similarity index 93% rename from test/test_http2/test_http2_global_disabled.yml rename to test/test_http2/test_http2-global-disabled.yml index 5dffa19..c13cd68 100644 --- a/test/test_http2/test_http2_global_disabled.yml +++ b/test/test_http2/test_http2-global-disabled.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http2-global-disabled.nginx-proxy.tld sut: diff --git a/test/test_http3/test_http3_global_disabled.py b/test/test_http3/test_http3-global-disabled.py similarity index 83% rename from test/test_http3/test_http3_global_disabled.py rename to test/test_http3/test_http3-global-disabled.py index 508823e..4f9d60a 100644 --- a/test/test_http3/test_http3_global_disabled.py +++ b/test/test_http3/test_http3-global-disabled.py @@ -1,8 +1,8 @@ -import pytest import re - #Python Requests is not able to do native http3 requests. - #We only check for directives which should enable http3. + +# Python Requests is not able to do native http3 requests. +# We only check for directives which should enable http3. def test_http3_global_disabled_ALTSVC_header(docker_compose, nginxproxy): r = nginxproxy.get("http://http3-global-disabled.nginx-proxy.tld/headers") diff --git a/test/test_http3/test_http3_global_disabled.yml b/test/test_http3/test_http3-global-disabled.yml similarity index 93% rename from test/test_http3/test_http3_global_disabled.yml rename to test/test_http3/test_http3-global-disabled.yml index 5b83119..1650fca 100644 --- a/test/test_http3/test_http3_global_disabled.yml +++ b/test/test_http3/test_http3-global-disabled.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http3-global-disabled.nginx-proxy.tld sut: diff --git a/test/test_http3/test_http3_global_enabled.py b/test/test_http3/test_http3-global-enabled.py similarity index 87% rename from test/test_http3/test_http3_global_enabled.py rename to test/test_http3/test_http3-global-enabled.py index c678ab6..0efc2e3 100644 --- a/test/test_http3/test_http3_global_enabled.py +++ b/test/test_http3/test_http3-global-enabled.py @@ -1,8 +1,8 @@ -import pytest import re - #Python Requests is not able to do native http3 requests. - #We only check for directives which should enable http3. + +# Python Requests is not able to do native http3 requests. +# We only check for directives which should enable http3. def test_http3_global_enabled_ALTSVC_header(docker_compose, nginxproxy): r = nginxproxy.get("http://http3-global-enabled.nginx-proxy.tld/headers") diff --git a/test/test_http3/test_http3_global_enabled.yml b/test/test_http3/test_http3-global-enabled.yml similarity index 93% rename from test/test_http3/test_http3_global_enabled.yml rename to test/test_http3/test_http3-global-enabled.yml index 0825469..a77bca2 100644 --- a/test/test_http3/test_http3_global_enabled.yml +++ b/test/test_http3/test_http3-global-enabled.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http3-global-enabled.nginx-proxy.tld sut: diff --git a/test/test_http3/test_http3_vhost.py b/test/test_http3/test_http3-vhost.py similarity index 95% rename from test/test_http3/test_http3_vhost.py rename to test/test_http3/test_http3-vhost.py index 93a217c..85d90d2 100644 --- a/test/test_http3/test_http3_vhost.py +++ b/test/test_http3/test_http3-vhost.py @@ -1,8 +1,8 @@ -import pytest import re - #Python Requests is not able to do native http3 requests. - #We only check for directives which should enable http3. + +# Python Requests is not able to do native http3 requests. +# We only check for directives which should enable http3. def test_http3_vhost_enabled_ALTSVC_header(docker_compose, nginxproxy): r = nginxproxy.get("http://http3-vhost-enabled.nginx-proxy.tld/headers") diff --git a/test/test_http3/test_http3_vhost.yml b/test/test_http3/test_http3-vhost.yml similarity index 91% rename from test/test_http3/test_http3_vhost.yml rename to test/test_http3/test_http3-vhost.yml index 1d5cdf2..a1a2007 100644 --- a/test/test_http3/test_http3_vhost.yml +++ b/test/test_http3/test_http3-vhost.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http3-vhost-enabled.nginx-proxy.tld labels: com.github.nginx-proxy.nginx-proxy.http3.enable: "true" @@ -14,7 +14,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http3-vhost-disabled.nginx-proxy.tld labels: com.github.nginx-proxy.nginx-proxy.http3.enable: "false" @@ -24,7 +24,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: http3-vhost-default-disabled.nginx-proxy.tld sut: diff --git a/test/test_internal/test_internal-per-vhost.py b/test/test_internal/test_internal-per-vhost.py index e64cc62..04649e2 100644 --- a/test/test_internal/test_internal-per-vhost.py +++ b/test/test_internal/test_internal-per-vhost.py @@ -1,5 +1,3 @@ -import pytest - def test_network_web1(docker_compose, nginxproxy): r = nginxproxy.get("http://web1.nginx-proxy.example/port") assert r.status_code == 200 diff --git a/test/test_internal/test_internal-per-vhost.yml b/test/test_internal/test_internal-per-vhost.yml index f01c7cf..2148149 100644 --- a/test/test_internal/test_internal-per-vhost.yml +++ b/test/test_internal/test_internal-per-vhost.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example NETWORK_ACCESS: internal @@ -13,7 +13,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example sut: diff --git a/test/test_internal/test_internal-per-vpath.py b/test/test_internal/test_internal-per-vpath.py index def806c..f788fa5 100644 --- a/test/test_internal/test_internal-per-vpath.py +++ b/test/test_internal/test_internal-per-vpath.py @@ -1,5 +1,3 @@ -import pytest - def test_network_web1(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy.example/web1/port") assert r.status_code == 200 diff --git a/test/test_internal/test_internal-per-vpath.yml b/test/test_internal/test_internal-per-vpath.yml index f8e03d6..c587cec 100644 --- a/test/test_internal/test_internal-per-vpath.yml +++ b/test/test_internal/test_internal-per-vpath.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: nginx-proxy.example VIRTUAL_PATH: /web1/ VIRTUAL_DEST: / @@ -15,7 +15,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: nginx-proxy.example VIRTUAL_PATH: /web2/ VIRTUAL_DEST: / diff --git a/test/test_ipv6/test_ipv6_prefer_ipv4_network.py b/test/test_ipv6/test_ipv6-prefer-ipv4-network.py similarity index 97% rename from test/test_ipv6/test_ipv6_prefer_ipv4_network.py rename to test/test_ipv6/test_ipv6-prefer-ipv4-network.py index 9a11fac..f11c797 100644 --- a/test/test_ipv6/test_ipv6_prefer_ipv4_network.py +++ b/test/test_ipv6/test_ipv6-prefer-ipv4-network.py @@ -1,6 +1,3 @@ -import pytest - - def test_forwards_to_ipv4_only_network(docker_compose, nginxproxy): r = nginxproxy.get("http://ipv4only.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_ipv6/test_ipv6_prefer_ipv4_network.yml b/test/test_ipv6/test_ipv6-prefer-ipv4-network.yml similarity index 97% rename from test/test_ipv6/test_ipv6_prefer_ipv4_network.yml rename to test/test_ipv6/test_ipv6-prefer-ipv4-network.yml index 2021856..bca828e 100644 --- a/test/test_ipv6/test_ipv6_prefer_ipv4_network.yml +++ b/test/test_ipv6/test_ipv6-prefer-ipv4-network.yml @@ -16,7 +16,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: ipv4only.nginx-proxy.tld networks: ipv4net: diff --git a/test/test_ipv6/test_ipv6_prefer_ipv6_network.py b/test/test_ipv6/test_ipv6-prefer-ipv6-network.py similarity index 97% rename from test/test_ipv6/test_ipv6_prefer_ipv6_network.py rename to test/test_ipv6/test_ipv6-prefer-ipv6-network.py index 09a8dde..3e1988d 100644 --- a/test/test_ipv6/test_ipv6_prefer_ipv6_network.py +++ b/test/test_ipv6/test_ipv6-prefer-ipv6-network.py @@ -1,6 +1,3 @@ -import pytest - - def test_forwards_to_ipv4_only_network(docker_compose, nginxproxy): r = nginxproxy.get("http://ipv4only.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_ipv6/test_ipv6_prefer_ipv6_network.yml b/test/test_ipv6/test_ipv6-prefer-ipv6-network.yml similarity index 97% rename from test/test_ipv6/test_ipv6_prefer_ipv6_network.yml rename to test/test_ipv6/test_ipv6-prefer-ipv6-network.yml index b12eb0d..1832932 100644 --- a/test/test_ipv6/test_ipv6_prefer_ipv6_network.yml +++ b/test/test_ipv6/test_ipv6-prefer-ipv6-network.yml @@ -16,7 +16,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: ipv4only.nginx-proxy.tld networks: ipv4net: diff --git a/test/test_ipv6/test_ipv6.py b/test/test_ipv6/test_ipv6.py index 36bf653..3cfd2b2 100644 --- a/test/test_ipv6/test_ipv6.py +++ b/test/test_ipv6/test_ipv6.py @@ -1,6 +1,3 @@ -import pytest - - def test_unknown_virtual_host_ipv4(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/port") assert r.status_code == 503 diff --git a/test/test_ipv6/test_ipv6.yml b/test/test_ipv6/test_ipv6.yml index d7276a6..b937e26 100644 --- a/test/test_ipv6/test_ipv6.yml +++ b/test/test_ipv6/test_ipv6.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.tld networks: - net1 @@ -21,7 +21,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.tld networks: - net1 diff --git a/test/test_keepalive.py b/test/test_keepalive/test_keepalive.py similarity index 100% rename from test/test_keepalive.py rename to test/test_keepalive/test_keepalive.py diff --git a/test/test_keepalive.yml b/test/test_keepalive/test_keepalive.yml similarity index 92% rename from test/test_keepalive.yml rename to test/test_keepalive/test_keepalive.yml index 9631eca..2cdfe93 100644 --- a/test/test_keepalive.yml +++ b/test/test_keepalive/test_keepalive.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test labels: com.github.nginx-proxy.nginx-proxy.keepalive: "disabled" @@ -14,7 +14,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: keepalive-enabled.nginx-proxy.test labels: com.github.nginx-proxy.nginx-proxy.keepalive: "64" @@ -27,7 +27,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: keepalive-auto.nginx-proxy.test sut: diff --git a/test/test_loadbalancing.py b/test/test_loadbalancing/test_loadbalancing.py similarity index 95% rename from test/test_loadbalancing.py rename to test/test_loadbalancing/test_loadbalancing.py index 4b43aa5..08f8537 100644 --- a/test/test_loadbalancing.py +++ b/test/test_loadbalancing/test_loadbalancing.py @@ -1,16 +1,16 @@ -import pytest -import re - -def test_loadbalance_hash(docker_compose, nginxproxy): - conf = nginxproxy.get_conf().decode('ASCII') - r1 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld") - r2 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld") - assert re.search(r"hash \$remote_addr\;", conf) - assert r1.status_code == 200 - assert r2.text == r1.text - -def test_loadbalance_roundrobin(docker_compose, nginxproxy): - r1 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld") - r2 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld") - assert r1.status_code == 200 - assert r2.text != r1.text +import re + + +def test_loadbalance_hash(docker_compose, nginxproxy): + conf = nginxproxy.get_conf().decode('ASCII') + r1 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld") + r2 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld") + assert re.search(r"hash \$remote_addr\;", conf) + assert r1.status_code == 200 + assert r2.text == r1.text + +def test_loadbalance_roundrobin(docker_compose, nginxproxy): + r1 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld") + r2 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld") + assert r1.status_code == 200 + assert r2.text != r1.text diff --git a/test/test_loadbalancing.yml b/test/test_loadbalancing/test_loadbalancing.yml similarity index 88% rename from test/test_loadbalancing.yml rename to test/test_loadbalancing/test_loadbalancing.yml index b8f42eb..b041f1f 100644 --- a/test/test_loadbalancing.yml +++ b/test/test_loadbalancing/test_loadbalancing.yml @@ -1,27 +1,27 @@ -services: - loadbalance-hash: - image: web - expose: - - "81" - environment: - WEB_PORTS: 81 - VIRTUAL_HOST: loadbalance-enabled.nginx-proxy.tld - labels: - com.github.nginx-proxy.nginx-proxy.loadbalance: "hash $$remote_addr;" - deploy: - replicas: 2 - - loadbalance-roundrobin: - image: web - expose: - - "82" - environment: - WEB_PORTS: 82 - VIRTUAL_HOST: loadbalance-disabled.nginx-proxy.tld - deploy: - replicas: 2 - - sut: - image: nginxproxy/nginx-proxy:test - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro +services: + loadbalance-hash: + image: web + expose: + - "81" + environment: + WEB_PORTS: "81" + VIRTUAL_HOST: loadbalance-enabled.nginx-proxy.tld + labels: + com.github.nginx-proxy.nginx-proxy.loadbalance: "hash $$remote_addr;" + deploy: + replicas: 2 + + loadbalance-roundrobin: + image: web + expose: + - "82" + environment: + WEB_PORTS: "82" + VIRTUAL_HOST: loadbalance-disabled.nginx-proxy.tld + deploy: + replicas: 2 + + sut: + image: nginxproxy/nginx-proxy:test + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro diff --git a/test/test_location-override.py b/test/test_location-override/test_location-override.py similarity index 100% rename from test/test_location-override.py rename to test/test_location-override/test_location-override.py diff --git a/test/test_location-override.yml b/test/test_location-override/test_location-override.yml similarity index 94% rename from test/test_location-override.yml rename to test/test_location-override/test_location-override.yml index f36b206..c7a0812 100644 --- a/test/test_location-override.yml +++ b/test/test_location-override/test_location-override.yml @@ -3,7 +3,7 @@ services: image: nginxproxy/nginx-proxy:test volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - - ./test_location-override.vhost.d:/etc/nginx/vhost.d:ro + - ./vhost.d:/etc/nginx/vhost.d:ro explicit-root: image: web diff --git a/test/test_location-override.vhost.d/explicit-nonroot.nginx-proxy.test_8d960560c82f4e6c8b1b0f03eb30a1afd00e5696_location_override b/test/test_location-override/vhost.d/explicit-nonroot.nginx-proxy.test_8d960560c82f4e6c8b1b0f03eb30a1afd00e5696_location_override similarity index 100% rename from test/test_location-override.vhost.d/explicit-nonroot.nginx-proxy.test_8d960560c82f4e6c8b1b0f03eb30a1afd00e5696_location_override rename to test/test_location-override/vhost.d/explicit-nonroot.nginx-proxy.test_8d960560c82f4e6c8b1b0f03eb30a1afd00e5696_location_override diff --git a/test/test_location-override.vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override b/test/test_location-override/vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override similarity index 100% rename from test/test_location-override.vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override rename to test/test_location-override/vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override diff --git a/test/test_location-override.vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_location_override b/test/test_location-override/vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_location_override similarity index 100% rename from test/test_location-override.vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_location_override rename to test/test_location-override/vhost.d/explicit-root-hash-and-nohash.nginx-proxy.test_location_override diff --git a/test/test_location-override.vhost.d/explicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override b/test/test_location-override/vhost.d/explicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override similarity index 100% rename from test/test_location-override.vhost.d/explicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override rename to test/test_location-override/vhost.d/explicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override diff --git a/test/test_location-override.vhost.d/explicit-root-nohash.nginx-proxy.test_location_override b/test/test_location-override/vhost.d/explicit-root-nohash.nginx-proxy.test_location_override similarity index 100% rename from test/test_location-override.vhost.d/explicit-root-nohash.nginx-proxy.test_location_override rename to test/test_location-override/vhost.d/explicit-root-nohash.nginx-proxy.test_location_override diff --git a/test/test_location-override.vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override b/test/test_location-override/vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override similarity index 100% rename from test/test_location-override.vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override rename to test/test_location-override/vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override diff --git a/test/test_location-override.vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_location_override b/test/test_location-override/vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_location_override similarity index 100% rename from test/test_location-override.vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_location_override rename to test/test_location-override/vhost.d/implicit-root-hash-and-nohash.nginx-proxy.test_location_override diff --git a/test/test_location-override.vhost.d/implicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override b/test/test_location-override/vhost.d/implicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override similarity index 100% rename from test/test_location-override.vhost.d/implicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override rename to test/test_location-override/vhost.d/implicit-root-hash.nginx-proxy.test_42099b4af021e53fd8fd4e056c2568d7c2e3ffa8_location_override diff --git a/test/test_location-override.vhost.d/implicit-root-nohash.nginx-proxy.test_location_override b/test/test_location-override/vhost.d/implicit-root-nohash.nginx-proxy.test_location_override similarity index 100% rename from test/test_location-override.vhost.d/implicit-root-nohash.nginx-proxy.test_location_override rename to test/test_location-override/vhost.d/implicit-root-nohash.nginx-proxy.test_location_override diff --git a/test/test_logs/test_log_disabled.py b/test/test_logs/test_log-disabled.py similarity index 97% rename from test/test_logs/test_log_disabled.py rename to test/test_logs/test_log-disabled.py index 2870b90..364d88b 100644 --- a/test/test_logs/test_log_disabled.py +++ b/test/test_logs/test_log-disabled.py @@ -1,5 +1,3 @@ -import pytest - def test_log_disabled(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy.test/port") assert r.status_code == 200 diff --git a/test/test_logs/test_log_disabled.yml b/test/test_logs/test_log-disabled.yml similarity index 93% rename from test/test_logs/test_log_disabled.yml rename to test/test_logs/test_log-disabled.yml index 05000ef..780a66a 100644 --- a/test/test_logs/test_log_disabled.yml +++ b/test/test_logs/test_log-disabled.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: nginx-proxy.test sut: diff --git a/test/test_logs/test_log_format.py b/test/test_logs/test_log-format.py similarity index 97% rename from test/test_logs/test_log_format.py rename to test/test_logs/test_log-format.py index 589f0c7..872605e 100644 --- a/test/test_logs/test_log_format.py +++ b/test/test_logs/test_log-format.py @@ -1,5 +1,3 @@ -import pytest - def test_log_format(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy.test/port") assert r.status_code == 200 diff --git a/test/test_logs/test_log_format.yml b/test/test_logs/test_log-format.yml similarity index 95% rename from test/test_logs/test_log_format.yml rename to test/test_logs/test_log-format.yml index 211ae31..a6b78f2 100644 --- a/test/test_logs/test_log_format.yml +++ b/test/test_logs/test_log-format.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: nginx-proxy.test sut: diff --git a/test/test_logs/test_log_json_format.py b/test/test_logs/test_log-json-format.py similarity index 97% rename from test/test_logs/test_log_json_format.py rename to test/test_logs/test_log-json-format.py index 2d158cb..7f50cdc 100644 --- a/test/test_logs/test_log_json_format.py +++ b/test/test_logs/test_log-json-format.py @@ -1,5 +1,3 @@ -import pytest - def test_log_json_format(docker_compose, nginxproxy): log_conf = [line for line in nginxproxy.get_conf().decode('ASCII').splitlines() if "log_format vhost escape=" in line] assert "{\"time_local\":\"$time_iso8601\"," in log_conf[0] diff --git a/test/test_logs/test_log_json_format.yml b/test/test_logs/test_log-json-format.yml similarity index 94% rename from test/test_logs/test_log_json_format.yml rename to test/test_logs/test_log-json-format.yml index 71810b3..39556e1 100644 --- a/test/test_logs/test_log_json_format.yml +++ b/test/test_logs/test_log-json-format.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: nginx-proxy.test sut: diff --git a/test/test_logs/test_log_json.py b/test/test_logs/test_log-json.py similarity index 97% rename from test/test_logs/test_log_json.py rename to test/test_logs/test_log-json.py index 1a04b22..5c53f72 100644 --- a/test/test_logs/test_log_json.py +++ b/test/test_logs/test_log-json.py @@ -1,5 +1,3 @@ -import pytest - def test_log_json(docker_compose, nginxproxy): log_conf = [line for line in nginxproxy.get_conf().decode('ASCII').splitlines() if "log_format vhost escape=" in line] assert "{\"time_local\":\"$time_iso8601\"," in log_conf[0] diff --git a/test/test_logs/test_log_json.yml b/test/test_logs/test_log-json.yml similarity index 92% rename from test/test_logs/test_log_json.yml rename to test/test_logs/test_log-json.yml index 75bb42e..8c05cb6 100644 --- a/test/test_logs/test_log_json.yml +++ b/test/test_logs/test_log-json.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: nginx-proxy.test sut: diff --git a/test/test_multiple-hosts.py b/test/test_multiple-hosts/test_multiple-hosts.py similarity index 97% rename from test/test_multiple-hosts.py rename to test/test_multiple-hosts/test_multiple-hosts.py index 76e7de6..211930c 100644 --- a/test/test_multiple-hosts.py +++ b/test/test_multiple-hosts/test_multiple-hosts.py @@ -1,6 +1,3 @@ -import pytest - - def test_unknown_virtual_host_is_503(docker_compose, nginxproxy): r = nginxproxy.get("http://unknown.nginx-proxy.tld/port") assert r.status_code == 503 diff --git a/test/test_multiple-hosts.yml b/test/test_multiple-hosts/test_multiple-hosts.yml similarity index 91% rename from test/test_multiple-hosts.yml rename to test/test_multiple-hosts/test_multiple-hosts.yml index d9cb661..bd0b433 100644 --- a/test/test_multiple-hosts.yml +++ b/test/test_multiple-hosts/test_multiple-hosts.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: webA.nginx-proxy.tld,webB.nginx-proxy.tld sut: diff --git a/test/test_multiple-networks.py b/test/test_multiple-networks/test_multiple-networks.py similarity index 86% rename from test/test_multiple-networks.py rename to test/test_multiple-networks/test_multiple-networks.py index 9d48cbe..daf2b0f 100644 --- a/test/test_multiple-networks.py +++ b/test/test_multiple-networks/test_multiple-networks.py @@ -1,7 +1,5 @@ import re -import pytest - def test_unknown_virtual_host(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy/") @@ -23,6 +21,5 @@ def test_multipath(docker_compose, nginxproxy): assert r.text == "answer from port 83\n" cfg = nginxproxy.get_conf().decode() lines = cfg.splitlines() - web3_server_lines = [l for l in lines - if re.search(r'(?m)^\s*server\s+[^\s]*:83;\s*$', l)] + web3_server_lines = [l for l in lines if re.search(r'(?m)^\s*server\s+\S*:83;\s*$', l)] assert len(web3_server_lines) == 1 diff --git a/test/test_multiple-networks.yml b/test/test_multiple-networks/test_multiple-networks.yml similarity index 90% rename from test/test_multiple-networks.yml rename to test/test_multiple-networks/test_multiple-networks.yml index edc12ab..1b947c7 100644 --- a/test/test_multiple-networks.yml +++ b/test/test_multiple-networks/test_multiple-networks.yml @@ -20,7 +20,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example networks: - net1 @@ -30,7 +30,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.example networks: - net2 @@ -40,7 +40,7 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: web3.nginx-proxy.test networks: - net3a diff --git a/test/test_multiports/test_multiports-base-json.py b/test/test_multiports/test_multiports-base-json.py index 7f1ef0f..cab5df8 100644 --- a/test/test_multiports/test_multiports-base-json.py +++ b/test/test_multiports/test_multiports-base-json.py @@ -1,6 +1,3 @@ -import pytest - - def test_virtual_host_is_dropped_when_using_multiports(docker_compose, nginxproxy): r = nginxproxy.get("http://notskipped.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_multiports/test_multiports-base-yaml.py b/test/test_multiports/test_multiports-base-yaml.py index 7f1ef0f..cab5df8 100644 --- a/test/test_multiports/test_multiports-base-yaml.py +++ b/test/test_multiports/test_multiports-base-yaml.py @@ -1,6 +1,3 @@ -import pytest - - def test_virtual_host_is_dropped_when_using_multiports(docker_compose, nginxproxy): r = nginxproxy.get("http://notskipped.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_multiports/test_multiports-invalid-syntax.py b/test/test_multiports/test_multiports-invalid-syntax.py index ed1c773..ceb7436 100644 --- a/test/test_multiports/test_multiports-invalid-syntax.py +++ b/test/test_multiports/test_multiports-invalid-syntax.py @@ -1,4 +1,3 @@ -import pytest import re diff --git a/test/test_multiports/test_multiports-merge.py b/test/test_multiports/test_multiports-merge.py index f5aa697..ff423a7 100644 --- a/test/test_multiports/test_multiports-merge.py +++ b/test/test_multiports/test_multiports-merge.py @@ -1,5 +1,4 @@ import backoff -import pytest def test_multiports_and_legacy_configs_should_be_merged(docker_compose, nginxproxy): diff --git a/test/test_nominal.py b/test/test_nominal/test_nominal.py similarity index 100% rename from test/test_nominal.py rename to test/test_nominal/test_nominal.py diff --git a/test/test_nominal.yml b/test/test_nominal/test_nominal.yml similarity index 92% rename from test/test_nominal.yml rename to test/test_nominal/test_nominal.yml index e6b81a8..5e3a846 100644 --- a/test/test_nominal.yml +++ b/test/test_nominal/test_nominal.yml @@ -11,7 +11,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.tld networks: - net1 @@ -21,7 +21,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: web2.nginx-proxy.tld networks: - net1 diff --git a/test/test_ports/test_default-80.py b/test/test_ports/test_default-80.py index 74c2f9f..67b1a08 100644 --- a/test/test_ports/test_default-80.py +++ b/test/test_ports/test_default-80.py @@ -1,6 +1,3 @@ -import pytest - - def test_answer_is_served_from_port_80_by_default(docker_compose, nginxproxy): r = nginxproxy.get("http://web.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_ports/test_single-port-not-80.py b/test/test_ports/test_single-port-not-80.py index ee86eca..771d835 100644 --- a/test/test_ports/test_single-port-not-80.py +++ b/test/test_ports/test_single-port-not-80.py @@ -1,6 +1,3 @@ -import pytest - - def test_answer_is_served_from_exposed_port_even_if_not_80(docker_compose, nginxproxy): r = nginxproxy.get("http://web.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_ports/test_VIRTUAL_PORT-single-different-from-single-port.py b/test/test_ports/test_virtual-port-single-different-from-single-port.py similarity index 95% rename from test/test_ports/test_VIRTUAL_PORT-single-different-from-single-port.py rename to test/test_ports/test_virtual-port-single-different-from-single-port.py index 4008166..b61850a 100644 --- a/test/test_ports/test_VIRTUAL_PORT-single-different-from-single-port.py +++ b/test/test_ports/test_virtual-port-single-different-from-single-port.py @@ -1,4 +1,3 @@ -import pytest import re diff --git a/test/test_ports/test_VIRTUAL_PORT-single-different-from-single-port.yml b/test/test_ports/test_virtual-port-single-different-from-single-port.yml similarity index 100% rename from test/test_ports/test_VIRTUAL_PORT-single-different-from-single-port.yml rename to test/test_ports/test_virtual-port-single-different-from-single-port.yml diff --git a/test/test_ports/test_VIRTUAL_PORT.py b/test/test_ports/test_virtual-port.py similarity index 92% rename from test/test_ports/test_VIRTUAL_PORT.py rename to test/test_ports/test_virtual-port.py index 3c95ba6..9c2d152 100644 --- a/test/test_ports/test_VIRTUAL_PORT.py +++ b/test/test_ports/test_virtual-port.py @@ -1,6 +1,3 @@ -import pytest - - def test_answer_is_served_from_chosen_port(docker_compose, nginxproxy): r = nginxproxy.get("http://web.nginx-proxy.tld/port") assert r.status_code == 200 diff --git a/test/test_ports/test_VIRTUAL_PORT.yml b/test/test_ports/test_virtual-port.yml similarity index 100% rename from test/test_ports/test_VIRTUAL_PORT.yml rename to test/test_ports/test_virtual-port.yml diff --git a/test/test_raw-ip-vhost.py b/test/test_raw-ip-vhost/test_raw-ip-vhost.py similarity index 97% rename from test/test_raw-ip-vhost.py rename to test/test_raw-ip-vhost/test_raw-ip-vhost.py index aaff852..4884402 100644 --- a/test/test_raw-ip-vhost.py +++ b/test/test_raw-ip-vhost/test_raw-ip-vhost.py @@ -1,6 +1,3 @@ -import pytest - - def test_raw_ipv4_vhost_forwards_to_web1(docker_compose, nginxproxy): r = nginxproxy.get("http://172.20.0.4") assert r.status_code == 200 diff --git a/test/test_raw-ip-vhost.yml b/test/test_raw-ip-vhost/test_raw-ip-vhost.yml similarity index 94% rename from test/test_raw-ip-vhost.yml rename to test/test_raw-ip-vhost/test_raw-ip-vhost.yml index 687449e..d5d9863 100644 --- a/test/test_raw-ip-vhost.yml +++ b/test/test_raw-ip-vhost/test_raw-ip-vhost.yml @@ -13,7 +13,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: "172.20.0.4" networks: net1: @@ -26,7 +26,7 @@ services: expose: - "82" environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: "[fd00::4]" networks: net1: diff --git a/test/test_server-down/test_load-balancing.py b/test/test_server-down/test_load-balancing.py index b65d0a1..6caa9e5 100644 --- a/test/test_server-down/test_load-balancing.py +++ b/test/test_server-down/test_load-balancing.py @@ -1,5 +1,3 @@ -import pytest - def test_web_has_no_server_down(docker_compose, nginxproxy): conf = nginxproxy.get_conf().decode('ASCII') r = nginxproxy.get("http://web.nginx-proxy.tld/port") diff --git a/test/test_server-down/test_load-balancing.yml b/test/test_server-down/test_load-balancing.yml index a778157..7818963 100644 --- a/test/test_server-down/test_load-balancing.yml +++ b/test/test_server-down/test_load-balancing.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web.nginx-proxy.tld web2: @@ -12,7 +12,7 @@ services: expose: - "82" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: web.nginx-proxy.tld web3: @@ -20,7 +20,7 @@ services: expose: - "83" environment: - WEB_PORTS: 83 + WEB_PORTS: "83" VIRTUAL_HOST: web.nginx-proxy.tld network_mode: "none" diff --git a/test/test_server-down/test_no-server-down.py b/test/test_server-down/test_no-server-down.py index a98ed56..4fe9b1d 100644 --- a/test/test_server-down/test_no-server-down.py +++ b/test/test_server-down/test_no-server-down.py @@ -1,5 +1,3 @@ -import pytest - def test_web_has_no_server_down(docker_compose, nginxproxy): conf = nginxproxy.get_conf().decode('ASCII') r = nginxproxy.get("http://web.nginx-proxy.tld/port") diff --git a/test/test_server-down/test_no-server-down.yml b/test/test_server-down/test_no-server-down.yml index 3ad3668..9a67d8b 100644 --- a/test/test_server-down/test_no-server-down.yml +++ b/test/test_server-down/test_no-server-down.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web.nginx-proxy.tld sut: diff --git a/test/test_server-down/test_server-down.py b/test/test_server-down/test_server-down.py index 995cd7d..a5b33c3 100644 --- a/test/test_server-down/test_server-down.py +++ b/test/test_server-down/test_server-down.py @@ -1,5 +1,3 @@ -import pytest - def test_web_has_server_down(docker_compose, nginxproxy): conf = nginxproxy.get_conf().decode('ASCII') r = nginxproxy.get("http://web.nginx-proxy.tld/port") diff --git a/test/test_server-down/test_server-down.yml b/test/test_server-down/test_server-down.yml index 07dff85..c2f03b4 100644 --- a/test/test_server-down/test_server-down.yml +++ b/test/test_server-down/test_server-down.yml @@ -4,7 +4,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web.nginx-proxy.tld network_mode: "none" diff --git a/test/test_ssl/test_cert_selection.py b/test/test_ssl/test_cert-selection.py similarity index 99% rename from test/test_ssl/test_cert_selection.py rename to test/test_ssl/test_cert-selection.py index 78c074d..c736dab 100644 --- a/test/test_ssl/test_cert_selection.py +++ b/test/test_ssl/test_cert-selection.py @@ -1,4 +1,5 @@ import json + import pytest diff --git a/test/test_ssl/test_cert_selection.yml b/test/test_ssl/test_cert-selection.yml similarity index 100% rename from test/test_ssl/test_cert_selection.yml rename to test/test_ssl/test_cert-selection.yml diff --git a/test/test_ssl/test_hsts.py b/test/test_ssl/test_hsts.py index 890c4ad..2007e0e 100644 --- a/test/test_ssl/test_hsts.py +++ b/test/test_ssl/test_hsts.py @@ -1,6 +1,3 @@ -import pytest - - def test_web1_HSTS_default(docker_compose, nginxproxy): r = nginxproxy.get("https://web1.nginx-proxy.tld/port", allow_redirects=False) assert "answer from port 81\n" in r.text diff --git a/test/test_ssl/test_https_port.py b/test/test_ssl/test_https-port.py similarity index 99% rename from test/test_ssl/test_https_port.py rename to test/test_ssl/test_https-port.py index ebe305f..6a42f2d 100644 --- a/test/test_ssl/test_https_port.py +++ b/test/test_ssl/test_https-port.py @@ -1,5 +1,6 @@ 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) diff --git a/test/test_ssl/test_https_port.yml b/test/test_ssl/test_https-port.yml similarity index 100% rename from test/test_ssl/test_https_port.yml rename to test/test_ssl/test_https-port.yml diff --git a/test/test_ssl/test_nohttp.py b/test/test_ssl/test_nohttp.py index 032f60f..23aef78 100644 --- a/test/test_ssl/test_nohttp.py +++ b/test/test_ssl/test_nohttp.py @@ -1,7 +1,3 @@ -import pytest -import requests - - def test_web2_http_is_connection_refused(docker_compose, nginxproxy): r = nginxproxy.get("http://web2.nginx-proxy.tld/", allow_redirects=False) assert r.status_code == 503 diff --git a/test/test_ssl/test_nohttps.py b/test/test_ssl/test_nohttps.py index 23e8224..3efacbb 100644 --- a/test/test_ssl/test_nohttps.py +++ b/test/test_ssl/test_nohttps.py @@ -1,6 +1,7 @@ import pytest from requests import ConnectionError + def test_http_is_forwarded(docker_compose, nginxproxy): r = nginxproxy.get("http://web.nginx-proxy.tld/port", allow_redirects=False) assert r.status_code == 200 diff --git a/test/test_ssl/test_noredirect.py b/test/test_ssl/test_noredirect.py index 1d956d1..41147f4 100644 --- a/test/test_ssl/test_noredirect.py +++ b/test/test_ssl/test_noredirect.py @@ -1,6 +1,3 @@ -import pytest - - def test_web3_http_is_forwarded(docker_compose, nginxproxy): r = nginxproxy.get("http://web3.nginx-proxy.tld/port", allow_redirects=False) assert r.status_code == 200 diff --git a/test/test_ssl/test_virtual_path.py b/test/test_ssl/test_virtual-path.py similarity index 99% rename from test/test_ssl/test_virtual_path.py rename to test/test_ssl/test_virtual-path.py index 72ac433..7dae669 100644 --- a/test/test_ssl/test_virtual_path.py +++ b/test/test_ssl/test_virtual-path.py @@ -1,6 +1,7 @@ import pytest from requests import ConnectionError + @pytest.mark.parametrize("path", ["web1", "web2"]) def test_web1_http_redirects_to_https(docker_compose, nginxproxy, path): r = nginxproxy.get("http://www.nginx-proxy.tld/%s/port" % path, allow_redirects=False) diff --git a/test/test_ssl/test_virtual_path.yml b/test/test_ssl/test_virtual-path.yml similarity index 100% rename from test/test_ssl/test_virtual_path.yml rename to test/test_ssl/test_virtual-path.yml diff --git a/test/test_trust-downstream-proxy/test_default.py b/test/test_trust-downstream-proxy/test_default.py index f56c406..b02bdae 100644 --- a/test/test_trust-downstream-proxy/test_default.py +++ b/test/test_trust-downstream-proxy/test_default.py @@ -1,6 +1,7 @@ -import pytest import re +import pytest + @pytest.mark.parametrize('url,header,input,want', [ ('http://web.nginx-proxy.tld/headers', 'X-Forwarded-Proto', None, 'http'), diff --git a/test/test_trust-downstream-proxy/test_default.yml b/test/test_trust-downstream-proxy/test_default.yml index a6a7676..8baceb6 100644 --- a/test/test_trust-downstream-proxy/test_default.yml +++ b/test/test_trust-downstream-proxy/test_default.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld HTTPS_METHOD: noredirect diff --git a/test/test_trust-downstream-proxy/test_disabled.py b/test/test_trust-downstream-proxy/test_disabled.py index 88c8054..201069c 100644 --- a/test/test_trust-downstream-proxy/test_disabled.py +++ b/test/test_trust-downstream-proxy/test_disabled.py @@ -1,6 +1,7 @@ -import pytest import re +import pytest + @pytest.mark.parametrize('url,header,input,want', [ ('http://web.nginx-proxy.tld/headers', 'X-Forwarded-Proto', None, 'http'), diff --git a/test/test_trust-downstream-proxy/test_disabled.yml b/test/test_trust-downstream-proxy/test_disabled.yml index 36ca154..6927457 100644 --- a/test/test_trust-downstream-proxy/test_disabled.yml +++ b/test/test_trust-downstream-proxy/test_disabled.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld HTTPS_METHOD: noredirect diff --git a/test/test_trust-downstream-proxy/test_enabled.py b/test/test_trust-downstream-proxy/test_enabled.py index f56c406..b02bdae 100644 --- a/test/test_trust-downstream-proxy/test_enabled.py +++ b/test/test_trust-downstream-proxy/test_enabled.py @@ -1,6 +1,7 @@ -import pytest import re +import pytest + @pytest.mark.parametrize('url,header,input,want', [ ('http://web.nginx-proxy.tld/headers', 'X-Forwarded-Proto', None, 'http'), diff --git a/test/test_trust-downstream-proxy/test_enabled.yml b/test/test_trust-downstream-proxy/test_enabled.yml index 800ff6d..7e2420a 100644 --- a/test/test_trust-downstream-proxy/test_enabled.yml +++ b/test/test_trust-downstream-proxy/test_enabled.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld HTTPS_METHOD: noredirect diff --git a/test/stress_tests/test_unreachable_network/README.md b/test/test_unreachable-network/README.md similarity index 100% rename from test/stress_tests/test_unreachable_network/README.md rename to test/test_unreachable-network/README.md diff --git a/test/stress_tests/test_unreachable_network/test_unreachable_net.py b/test/test_unreachable-network/test_unreachable-network.py similarity index 100% rename from test/stress_tests/test_unreachable_network/test_unreachable_net.py rename to test/test_unreachable-network/test_unreachable-network.py diff --git a/test/stress_tests/test_unreachable_network/docker-compose.yml b/test/test_unreachable-network/test_unreachable-network.yml similarity index 91% rename from test/stress_tests/test_unreachable_network/docker-compose.yml rename to test/test_unreachable-network/test_unreachable-network.yml index b6407e1..d1c29cb 100644 --- a/test/stress_tests/test_unreachable_network/docker-compose.yml +++ b/test/test_unreachable-network/test_unreachable-network.yml @@ -18,7 +18,7 @@ services: expose: - 81 environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: webA.nginx-proxy webB: @@ -28,5 +28,5 @@ services: expose: - 82 environment: - WEB_PORTS: 82 + WEB_PORTS: "82" VIRTUAL_HOST: webB.nginx-proxy diff --git a/test/test_upstream-name/test_predictable-name.py b/test/test_upstream-name/test_predictable-name.py index 7e19646..67ade3b 100644 --- a/test/test_upstream-name/test_predictable-name.py +++ b/test/test_upstream-name/test_predictable-name.py @@ -1,4 +1,3 @@ -import pytest import re diff --git a/test/test_upstream-name/test_predictable-name.yml b/test/test_upstream-name/test_predictable-name.yml index 3f8bd7a..aed479a 100644 --- a/test/test_upstream-name/test_predictable-name.yml +++ b/test/test_upstream-name/test_predictable-name.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld sut: diff --git a/test/test_upstream-name/test_sha1-name.py b/test/test_upstream-name/test_sha1-name.py index 663ca28..8993440 100644 --- a/test/test_upstream-name/test_sha1-name.py +++ b/test/test_upstream-name/test_sha1-name.py @@ -1,4 +1,3 @@ -import pytest import re diff --git a/test/test_upstream-name/test_sha1-name.yml b/test/test_upstream-name/test_sha1-name.yml index 5c3f048..22a97d6 100644 --- a/test/test_upstream-name/test_sha1-name.yml +++ b/test/test_upstream-name/test_sha1-name.yml @@ -4,7 +4,7 @@ services: expose: - "80" environment: - WEB_PORTS: 80 + WEB_PORTS: "80" VIRTUAL_HOST: web.nginx-proxy.tld sut: diff --git a/test/test_vhost-empty-string.py b/test/test_vhost-empty-string/test_vhost-empty-string.py similarity index 100% rename from test/test_vhost-empty-string.py rename to test/test_vhost-empty-string/test_vhost-empty-string.py diff --git a/test/test_vhost-empty-string.yml b/test/test_vhost-empty-string/test_vhost-empty-string.yml similarity index 100% rename from test/test_vhost-empty-string.yml rename to test/test_vhost-empty-string/test_vhost-empty-string.yml diff --git a/test/test_vhost-in-multiple-networks.py b/test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.py similarity index 91% rename from test/test_vhost-in-multiple-networks.py rename to test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.py index 02ef19e..6b30b53 100644 --- a/test/test_vhost-in-multiple-networks.py +++ b/test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.py @@ -1,6 +1,8 @@ -import pytest import logging -import time +from time import sleep + +import pytest + def test_forwards_to_web1(docker_compose, nginxproxy): r = nginxproxy.get("http://web1.nginx-proxy.example/port") @@ -11,11 +13,11 @@ def test_nginx_config_remains_the_same_after_restart(docker_compose, nginxproxy) """ Restarts the Web container and returns nginx-proxy config after restart """ - def get_conf_after_web_container_restart(): + def get_conf_after_web_container_restart() -> bytes: web_containers = docker_compose.containers.list(filters={"ancestor": "web:latest"}) assert len(web_containers) == 1 web_containers[0].restart() - time.sleep(3) + sleep(3) return nginxproxy.get_conf() diff --git a/test/test_vhost-in-multiple-networks.yml b/test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.yml similarity index 94% rename from test/test_vhost-in-multiple-networks.yml rename to test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.yml index 16b82e4..01edd72 100644 --- a/test/test_vhost-in-multiple-networks.yml +++ b/test/test_vhost-in-multiple-networks/test_vhost-in-multiple-networks.yml @@ -16,7 +16,7 @@ services: expose: - "81" environment: - WEB_PORTS: 81 + WEB_PORTS: "81" VIRTUAL_HOST: web1.nginx-proxy.example networks: - net1 diff --git a/test/test_virtual-path/test_custom_conf.py b/test/test_virtual-path/test_custom-conf.py similarity index 99% rename from test/test_virtual-path/test_custom_conf.py rename to test/test_virtual-path/test_custom-conf.py index eec149f..48a89b3 100644 --- a/test/test_virtual-path/test_custom_conf.py +++ b/test/test_virtual-path/test_custom-conf.py @@ -1,5 +1,6 @@ import pytest + def test_default_root_response(docker_compose, nginxproxy): r = nginxproxy.get("http://nginx-proxy.test/") assert r.status_code == 418 diff --git a/test/test_virtual-path/test_custom_conf.yml b/test/test_virtual-path/test_custom-conf.yml similarity index 100% rename from test/test_virtual-path/test_custom_conf.yml rename to test/test_virtual-path/test_custom-conf.yml diff --git a/test/test_virtual-path/test_forwarding.py b/test/test_virtual-path/test_forwarding.py index 062dd6c..9035ad9 100644 --- a/test/test_virtual-path/test_forwarding.py +++ b/test/test_virtual-path/test_forwarding.py @@ -1,5 +1,3 @@ -import pytest - def test_root_redirects_to_web1(docker_compose, nginxproxy): r = nginxproxy.get("http://www.nginx-proxy.tld/port", allow_redirects=False) assert r.status_code == 301 diff --git a/test/test_virtual-path/test_location_precedence.py b/test/test_virtual-path/test_location-precedence.py similarity index 98% rename from test/test_virtual-path/test_location_precedence.py rename to test/test_virtual-path/test_location-precedence.py index 415c6c1..9d4d1ec 100644 --- a/test/test_virtual-path/test_location_precedence.py +++ b/test/test_virtual-path/test_location-precedence.py @@ -1,5 +1,3 @@ -import pytest - def test_location_precedence_case1(docker_compose, nginxproxy): r = nginxproxy.get(f"http://foo.nginx-proxy.test/web1/port") assert r.status_code == 200 diff --git a/test/test_virtual-path/test_location_precedence.yml b/test/test_virtual-path/test_location-precedence.yml similarity index 100% rename from test/test_virtual-path/test_location_precedence.yml rename to test/test_virtual-path/test_location-precedence.yml diff --git a/test/test_virtual-path/test_virtual_paths.py b/test/test_virtual-path/test_virtual-paths.py similarity index 94% rename from test/test_virtual-path/test_virtual_paths.py rename to test/test_virtual-path/test_virtual-paths.py index a91a8dd..a8cd276 100644 --- a/test/test_virtual-path/test_virtual_paths.py +++ b/test/test_virtual-path/test_virtual-paths.py @@ -3,6 +3,7 @@ from time import sleep import pytest from docker.errors import NotFound + @pytest.mark.parametrize("stub,expected_port", [ ("nginx-proxy.test/web1", 81), ("nginx-proxy.test/web2", 82), @@ -22,7 +23,7 @@ def test_invalid_path(docker_compose, nginxproxy, stub): r = nginxproxy.get(f"http://{stub}/port") assert r.status_code in [404, 503] -@pytest.fixture() +@pytest.fixture def web4(docker_compose): """ pytest fixture creating a web container with `VIRTUAL_HOST=nginx-proxy.test`, `VIRTUAL_PATH=/web4/` and `VIRTUAL_DEST=/` listening on port 84. @@ -39,7 +40,7 @@ def web4(docker_compose): }, ports={"84/tcp": None} ) - docker_compose.networks.get("test_virtual-path_default").connect(container) + docker_compose.networks.get("test_virtual-path-net").connect(container) sleep(2) # give it some time to initialize and for docker-gen to detect it yield container try: diff --git a/test/test_virtual-path/test_virtual_paths.yml b/test/test_virtual-path/test_virtual-paths.yml similarity index 93% rename from test/test_virtual-path/test_virtual_paths.yml rename to test/test_virtual-path/test_virtual-paths.yml index 6e51b02..00e7fbe 100644 --- a/test/test_virtual-path/test_virtual_paths.yml +++ b/test/test_virtual-path/test_virtual-paths.yml @@ -1,3 +1,7 @@ +networks: + default: + name: "test_virtual-path-net" + services: foo: image: web diff --git a/test/test_wildcard_host.py b/test/test_wildcard-host/test_wildcard-host.py similarity index 100% rename from test/test_wildcard_host.py rename to test/test_wildcard-host/test_wildcard-host.py diff --git a/test/test_wildcard_host.yml b/test/test_wildcard-host/test_wildcard-host.yml similarity index 100% rename from test/test_wildcard_host.yml rename to test/test_wildcard-host/test_wildcard-host.yml