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:
parent
787fa28799
commit
399e19e2dc
@ -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
10
test2/test_composev2.py
Normal 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
14
test2/test_composev2.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user