1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-22 11:56:31 +00:00

TESTS: add support for compose syntax v2

This commit is contained in:
Thomas LEVEIL 2017-01-26 01:30:17 +01:00
parent 787fa28799
commit 399e19e2dc
3 changed files with 31 additions and 1 deletions

View File

@ -90,7 +90,13 @@ def monkey_patch_urllib_dns_resolver():
log.debug("resolving domain name %s" % repr(args)) log.debug("resolving domain name %s" % repr(args))
if 'nginx-proxy' in args[0]: if 'nginx-proxy' in args[0]:
docker_client = docker.from_env() docker_client = docker.from_env()
ip = docker_client.containers(filters={"status": "running", "ancestor": "jwilder/nginx-proxy:test"})[0]["NetworkSettings"]["Networks"]["bridge"]["IPAddress"] net_info = docker_client.containers(filters={"status": "running", "ancestor": "jwilder/nginx-proxy:test"})[0]["NetworkSettings"]["Networks"]
if "bridge" in net_info:
ip = net_info["bridge"]["IPAddress"]
else:
# not default bridge network, fallback on first network defined
network_name = net_info.keys()[0]
ip = net_info[network_name]["IPAddress"]
log.info("resolving domain name %r as IP address is %s" % (args[0], ip)) log.info("resolving domain name %r as IP address is %s" % (args[0], ip))
return [ return [
(socket.AF_INET, socket.SOCK_STREAM, 6, '', (ip, args[1])), (socket.AF_INET, socket.SOCK_STREAM, 6, '', (ip, args[1])),

10
test2/test_composev2.py Normal file
View File

@ -0,0 +1,10 @@
import pytest
def test_unknown_virtual_host(docker_compose, nginxproxy):
r = nginxproxy.get("http://nginx-proxy/")
assert r.status_code == 503
def test_forwards_to_whoami(docker_compose, nginxproxy):
r = nginxproxy.get("http://web.nginx-proxy.local/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"

14
test2/test_composev2.yml Normal file
View File

@ -0,0 +1,14 @@
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
web:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.local