mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
tests: parameterize test
This commit is contained in:
parent
923f05032f
commit
8447a36046
@ -1,34 +1,28 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
# These tests are to test that GET is 301 and other methods all use 308
|
|
||||||
# Permanent Redirects
|
|
||||||
# https://github.com/nginx-proxy/nginx-proxy/pull/1737
|
|
||||||
def test_web1_GET_301(docker_compose, nginxproxy):
|
|
||||||
r = nginxproxy.get('http://nginx-proxy.tld', allow_redirects=False)
|
|
||||||
assert r.status_code == 301
|
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
|
||||||
|
|
||||||
def test_web1_POST_308(docker_compose, nginxproxy):
|
@pytest.mark.parametrize("http_method,expected_code", [
|
||||||
r = nginxproxy.post('http://nginx-proxy.tld', allow_redirects=False)
|
("GET", 301),
|
||||||
assert r.status_code == 308
|
("HEAD", 308),
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
("POST", 308),
|
||||||
|
("PUT", 308),
|
||||||
def test_web1_PUT_308(docker_compose, nginxproxy):
|
("PATCH", 308),
|
||||||
r = nginxproxy.put('http://nginx-proxy.tld', allow_redirects=False)
|
("DELETE", 308),
|
||||||
assert r.status_code == 308
|
("OPTIONS", 308),
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
("CONNECT", 405),
|
||||||
|
("TRACE", 405),
|
||||||
def test_web1_HEAD_308(docker_compose, nginxproxy):
|
])
|
||||||
r = nginxproxy.head('http://nginx-proxy.tld', allow_redirects=False)
|
def test_default_redirect_by_method(
|
||||||
assert r.status_code == 308
|
docker_compose,
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
nginxproxy,
|
||||||
|
http_method: str,
|
||||||
def test_web1_DELETE_308(docker_compose, nginxproxy):
|
expected_code: int,
|
||||||
r = nginxproxy.delete('http://nginx-proxy.tld', allow_redirects=False)
|
):
|
||||||
assert r.status_code == 308
|
r = nginxproxy.request(
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
method=http_method,
|
||||||
|
url='http://nginx-proxy.tld',
|
||||||
def test_web1_OPTIONS_308(docker_compose, nginxproxy):
|
allow_redirects=False,
|
||||||
r = nginxproxy.options('http://nginx-proxy.tld', allow_redirects=False)
|
)
|
||||||
assert r.status_code == 308
|
assert r.status_code == expected_code
|
||||||
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
if expected_code in { 301, 302, 307, 308 }:
|
||||||
|
assert r.headers['Location'] == 'https://nginx-proxy.tld/'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user