Skip to content

Commit

Permalink
tests: 308 redirect of non get requests
Browse files Browse the repository at this point in the history
  • Loading branch information
buchdag committed Aug 18, 2021
1 parent a3dcccb commit 404d66e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ def test_unknown_virtual_host_is_503(docker_compose, nginxproxy):
assert r.status_code == 503


def test_http_web_is_301(docker_compose, nginxproxy):
def test_http_get_web_is_301(docker_compose, nginxproxy):
r = nginxproxy.get("http://web.nginx-proxy/port", allow_redirects=False)
assert r.status_code == 301


def test_http_post_web_is_308(docker_compose, nginxproxy):
r = nginxproxy.post("http://web.nginx-proxy/port", allow_redirects=False)
assert r.status_code == 308


def test_https_web_is_200(docker_compose, nginxproxy):
r = nginxproxy.get("https://web.nginx-proxy/port")
assert r.status_code == 200
Expand Down
9 changes: 8 additions & 1 deletion test/test_ssl/test_https_port.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import pytest

@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_http_redirects_to_https(docker_compose, nginxproxy, subdomain):
def test_web1_http_get_301_redirects_to_https(docker_compose, nginxproxy, subdomain):
r = nginxproxy.get("http://%s.nginx-proxy.tld:8080/" % subdomain, allow_redirects=False)
assert r.status_code == 301
assert "Location" in r.headers
assert "https://%s.nginx-proxy.tld:8443/" % subdomain == r.headers['Location']

@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_http_post_308_redirects_to_https(docker_compose, nginxproxy, subdomain):
r = nginxproxy.post("http://%s.nginx-proxy.tld:8080/" % subdomain, allow_redirects=False)
assert r.status_code == 308
assert "Location" in r.headers
assert "https://%s.nginx-proxy.tld:8443/" % subdomain == r.headers['Location']

@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_https_is_forwarded(docker_compose, nginxproxy, subdomain):
r = nginxproxy.get("https://%s.nginx-proxy.tld:8443/port" % subdomain, allow_redirects=False)
Expand Down
8 changes: 7 additions & 1 deletion test/test_ssl/test_wildcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@


@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_http_redirects_to_https(docker_compose, nginxproxy, subdomain):
def test_web1_http_get_301_redirects_to_https(docker_compose, nginxproxy, subdomain):
r = nginxproxy.get(f"http://{subdomain}.nginx-proxy.tld/", allow_redirects=False)
assert r.status_code == 301
assert "Location" in r.headers
assert f"https://{subdomain}.nginx-proxy.tld/" == r.headers['Location']

@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_http_post_308_redirects_to_https(docker_compose, nginxproxy, subdomain):
r = nginxproxy.post(f"http://{subdomain}.nginx-proxy.tld/", allow_redirects=False)
assert r.status_code == 308
assert "Location" in r.headers
assert f"https://{subdomain}.nginx-proxy.tld/" == r.headers['Location']

@pytest.mark.parametrize("subdomain", ["foo", "bar"])
def test_web1_https_is_forwarded(docker_compose, nginxproxy, subdomain):
Expand Down

0 comments on commit 404d66e

Please sign in to comment.