Fix tests after merge with upstream
* Use "sub." instead of "www." because the latter will be redirected to non-www
This commit is contained in:
parent
77c672f576
commit
7272649958
4 changed files with 10 additions and 10 deletions
|
@ -2,14 +2,14 @@ import pytest
|
||||||
|
|
||||||
@pytest.mark.parametrize("path", ["web1", "web2"])
|
@pytest.mark.parametrize("path", ["web1", "web2"])
|
||||||
def test_web1_http_redirects_to_https(docker_compose, nginxproxy, path):
|
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)
|
r = nginxproxy.get("http://sub.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
|
||||||
assert r.status_code == 301
|
assert r.status_code == 301
|
||||||
assert "Location" in r.headers
|
assert "Location" in r.headers
|
||||||
assert "https://www.nginx-proxy.tld/%s/port" % path == r.headers['Location']
|
assert "https://sub.nginx-proxy.tld/%s/port" % path == r.headers['Location']
|
||||||
|
|
||||||
@pytest.mark.parametrize("path,port", [("web1", 81), ("web2", 82)])
|
@pytest.mark.parametrize("path,port", [("web1", 81), ("web2", 82)])
|
||||||
def test_web1_https_is_forwarded(docker_compose, nginxproxy, path, port):
|
def test_web1_https_is_forwarded(docker_compose, nginxproxy, path, port):
|
||||||
r = nginxproxy.get("https://www.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
|
r = nginxproxy.get("https://sub.nginx-proxy.tld/%s/port" % path, allow_redirects=False)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert "answer from port %d\n" % port in r.text
|
assert "answer from port %d\n" % port in r.text
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ web1:
|
||||||
- "81"
|
- "81"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "81"
|
WEB_PORTS: "81"
|
||||||
VIRTUAL_HOST: "www.nginx-proxy.tld"
|
VIRTUAL_HOST: "sub.nginx-proxy.tld"
|
||||||
VIRTUAL_PATH: "/web1/"
|
VIRTUAL_PATH: "/web1/"
|
||||||
VIRTUAL_DEST: "/"
|
VIRTUAL_DEST: "/"
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ web2:
|
||||||
- "82"
|
- "82"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "82"
|
WEB_PORTS: "82"
|
||||||
VIRTUAL_HOST: "www.nginx-proxy.tld"
|
VIRTUAL_HOST: "sub.nginx-proxy.tld"
|
||||||
VIRTUAL_PATH: "/web2/"
|
VIRTUAL_PATH: "/web2/"
|
||||||
VIRTUAL_DEST: "/"
|
VIRTUAL_DEST: "/"
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
def test_root_redirects_to_web1(docker_compose, nginxproxy):
|
def test_root_redirects_to_web1(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://www.nginx-proxy.tld/port", allow_redirects=False)
|
r = nginxproxy.get("http://sub.nginx-proxy.tld/port", allow_redirects=False)
|
||||||
assert r.status_code == 301
|
assert r.status_code == 301
|
||||||
assert "Location" in r.headers
|
assert "Location" in r.headers
|
||||||
assert "http://www.nginx-proxy.tld/web1/port" == r.headers['Location']
|
assert "http://sub.nginx-proxy.tld/web1/port" == r.headers['Location']
|
||||||
|
|
||||||
def test_direct_access(docker_compose, nginxproxy):
|
def test_direct_access(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://www.nginx-proxy.tld/web1/port", allow_redirects=False)
|
r = nginxproxy.get("http://sub.nginx-proxy.tld/web1/port", allow_redirects=False)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert "answer from port 81\n" in r.text
|
assert "answer from port 81\n" in r.text
|
||||||
|
|
||||||
def test_root_is_forwarded(docker_compose, nginxproxy):
|
def test_root_is_forwarded(docker_compose, nginxproxy):
|
||||||
r = nginxproxy.get("http://www.nginx-proxy.tld/port", allow_redirects=True)
|
r = nginxproxy.get("http://sub.nginx-proxy.tld/port", allow_redirects=True)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert "answer from port 81\n" in r.text
|
assert "answer from port 81\n" in r.text
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ web1:
|
||||||
- "81"
|
- "81"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: "81"
|
WEB_PORTS: "81"
|
||||||
VIRTUAL_HOST: "www.nginx-proxy.tld"
|
VIRTUAL_HOST: "sub.nginx-proxy.tld"
|
||||||
VIRTUAL_PATH: "/web1/"
|
VIRTUAL_PATH: "/web1/"
|
||||||
VIRTUAL_DEST: "/"
|
VIRTUAL_DEST: "/"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue