mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 09:48:14 +00:00
tests: Remove extraction of nginx.tmpl
(now unnecessary)
This commit is contained in:
parent
486addd144
commit
92e1a6567e
@ -1,41 +1,9 @@
|
|||||||
import os
|
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||||
import docker
|
|
||||||
import logging
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
|
||||||
def nginx_tmpl():
|
|
||||||
"""
|
|
||||||
pytest fixture which extracts the the nginx config template from
|
|
||||||
the nginxproxy/nginx-proxy:test image
|
|
||||||
"""
|
|
||||||
script_dir = os.path.dirname(__file__)
|
|
||||||
logging.info("extracting nginx.tmpl from nginxproxy/nginx-proxy:test")
|
|
||||||
docker_client = docker.from_env()
|
|
||||||
print(
|
|
||||||
docker_client.containers.run(
|
|
||||||
image="nginxproxy/nginx-proxy:test",
|
|
||||||
remove=True,
|
|
||||||
volumes=["{current_dir}:{current_dir}".format(current_dir=script_dir)],
|
|
||||||
entrypoint="sh",
|
|
||||||
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(
|
|
||||||
current_dir=script_dir
|
|
||||||
),
|
|
||||||
stderr=True,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
yield
|
|
||||||
logging.info("removing nginx.tmpl")
|
|
||||||
os.remove(os.path.join(script_dir, "nginx.tmpl"))
|
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_virtual_host_is_503(nginx_tmpl, docker_compose, nginxproxy):
|
|
||||||
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
||||||
assert r.status_code == 503
|
assert r.status_code == 503
|
||||||
|
|
||||||
|
|
||||||
def test_forwards_to_whoami(nginx_tmpl, docker_compose, nginxproxy):
|
def test_forwards_to_whoami(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
whoami_container = docker_compose.containers.get("whoami")
|
whoami_container = docker_compose.containers.get("whoami")
|
||||||
|
@ -14,7 +14,7 @@ services:
|
|||||||
- nginx
|
- nginx
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
- ../../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: web
|
image: web
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import os
|
|
||||||
import docker
|
import docker
|
||||||
import logging
|
|
||||||
import pytest
|
import pytest
|
||||||
import re
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
|
|
||||||
@ -13,38 +10,12 @@ pytestmark = pytest.mark.skipif(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
|
||||||
def nginx_tmpl():
|
|
||||||
"""
|
|
||||||
pytest fixture which extracts the the nginx config template from
|
|
||||||
the nginxproxy/nginx-proxy:test image
|
|
||||||
"""
|
|
||||||
script_dir = os.path.dirname(__file__)
|
|
||||||
logging.info("extracting nginx.tmpl from nginxproxy/nginx-proxy:test")
|
|
||||||
docker_client = docker.from_env()
|
|
||||||
print(
|
|
||||||
docker_client.containers.run(
|
|
||||||
image="nginxproxy/nginx-proxy:test",
|
|
||||||
remove=True,
|
|
||||||
volumes=["{current_dir}:{current_dir}".format(current_dir=script_dir)],
|
|
||||||
entrypoint="sh",
|
|
||||||
command='-xc "cp /app/nginx.tmpl {current_dir} && chmod 777 {current_dir}/nginx.tmpl"'.format(
|
|
||||||
current_dir=script_dir
|
|
||||||
),
|
|
||||||
stderr=True,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
yield
|
|
||||||
logging.info("removing nginx.tmpl")
|
|
||||||
os.remove(os.path.join(script_dir, "nginx.tmpl"))
|
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_virtual_host_is_503(nginx_tmpl, docker_compose, nginxproxy):
|
|
||||||
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
r = nginxproxy.get("http://unknown.nginx.container.docker/")
|
||||||
assert r.status_code == 503
|
assert r.status_code == 503
|
||||||
|
|
||||||
|
|
||||||
def test_forwards_to_whoami(nginx_tmpl, docker_compose, nginxproxy):
|
def test_forwards_to_whoami(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
r = nginxproxy.get("http://whoami.nginx.container.docker/")
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
whoami_container = docker_compose.containers.get("whoami")
|
whoami_container = docker_compose.containers.get("whoami")
|
||||||
|
@ -11,7 +11,7 @@ services:
|
|||||||
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
command: -notify-sighup nginx -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
- ../../nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
|
||||||
- nginx_conf:/etc/nginx/conf.d
|
- nginx_conf:/etc/nginx/conf.d
|
||||||
|
|
||||||
web:
|
web:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user