Przeglądaj źródła

test: configurable external ports w/ VIRTUAL_HOST_MULTIPORTS

Nicolas Duchon 1 miesiąc temu
rodzic
commit
53280552af

+ 71 - 0
test/test_external_ports/test_virtual-host-multiport.py‎

@@ -0,0 +1,71 @@
+def test_web1_has_custom_http_and_https_ports(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web1.nginx-proxy.tld:8080/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web1.nginx-proxy.tld:8443/port'
+    
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 81\n" in r2.text
+
+def test_web1_subpath_has_same_ports_as_root_path(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web1.nginx-proxy.tld:8080/subpath/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web1.nginx-proxy.tld:8443/subpath/port'
+    
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 881\n" in r2.text
+
+def test_web2_has_default_http_port_and_custom_https_port(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web2.nginx-proxy.tld/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web2.nginx-proxy.tld:8443/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 82\n" in r2.text
+
+def test_web2_subpath_has_same_ports_as_root_path(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web2.nginx-proxy.tld/subpath/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web2.nginx-proxy.tld:8443/subpath/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 882\n" in r2.text
+
+def test_web3_has_custom_http_port_and_default_https_port(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web3.nginx-proxy.tld:8080/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web3.nginx-proxy.tld/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 83\n" in r2.text
+
+def test_web3_subpath_has_same_ports_as_root_path(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web3.nginx-proxy.tld:8080/subpath/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web3.nginx-proxy.tld/subpath/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 883\n" in r2.text
+
+def test_web4_has_default_http_and_https_ports(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web4.nginx-proxy.tld/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web4.nginx-proxy.tld/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 84\n" in r2.text
+
+def test_web4_subpath_has_same_ports_as_root_path(docker_compose, nginxproxy):
+    r1 = nginxproxy.get("http://web4.nginx-proxy.tld/subpath/port", allow_redirects=False)
+    assert r1.status_code == 301
+    assert r1.headers['Location'] == 'https://web4.nginx-proxy.tld/subpath/port'
+
+    r2 = nginxproxy.get(r1.headers['Location'], allow_redirects=False)
+    assert r2.status_code == 200
+    assert "answer from port 884\n" in r2.text

+ 43 - 0
test/test_external_ports/test_virtual-host-multiport.yml

@@ -0,0 +1,43 @@
+services:
+  web:
+    image: web
+    expose:
+      - "81"
+      - "82"
+      - "83"
+      - "84"
+      - "881"
+      - "882"
+      - "883"
+      - "884"
+    environment:
+      WEB_PORTS: "81 82 83 84 881 882 883 884"
+      VIRTUAL_HOST_MULTIPORTS: |-
+        web1.nginx-proxy.tld:
+          external_http_port: 8080
+          external_https_port: 8443
+          "/":
+            port: 81
+          "/subpath":
+            dest: "/"
+            port: 881
+        web2.nginx-proxy.tld:
+          external_https_port: 8443
+          "/":
+            port: 82
+          "/subpath":
+            dest: "/"
+            port: 882
+        web3.nginx-proxy.tld:
+          external_http_port: 8080
+          "/":
+            port: 83
+          "/subpath":
+            dest: "/"
+            port: 883
+        web4.nginx-proxy.tld:
+          "/":
+            port: 84
+          "/subpath":
+            dest: "/"
+            port: 884