diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/mozilla/tests/webdriver/protocol/request.py | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/mozilla/tests/webdriver/protocol/request.py')
-rw-r--r-- | testing/web-platform/mozilla/tests/webdriver/protocol/request.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/mozilla/tests/webdriver/protocol/request.py b/testing/web-platform/mozilla/tests/webdriver/protocol/request.py new file mode 100644 index 0000000000..ad99d6964d --- /dev/null +++ b/testing/web-platform/mozilla/tests/webdriver/protocol/request.py @@ -0,0 +1,72 @@ +import pytest +from support.network import get_host, http_request + + +@pytest.mark.parametrize( + "hostname, port_type, status", + [ + # Valid hosts + ("localhost", "server_port", 200), + ("127.0.0.1", "server_port", 200), + ("[::1]", "server_port", 200), + ("192.168.8.1", "server_port", 200), + ("[fdf8:f535:82e4::53]", "server_port", 200), + # Invalid hosts + ("localhost", "default_port", 500), + ("127.0.0.1", "default_port", 500), + ("[::1]", "default_port", 500), + ("192.168.8.1", "default_port", 500), + ("[fdf8:f535:82e4::53]", "default_port", 500), + ("example.org", "server_port", 500), + ("example.org", "wrong_port", 500), + ("example.org", "default_port", 500), + ("localhost", "wrong_port", 500), + ("127.0.0.1", "wrong_port", 500), + ("[::1]", "wrong_port", 500), + ("192.168.8.1", "wrong_port", 500), + ("[fdf8:f535:82e4::53]", "wrong_port", 500), + ], + ids=[ + # Valid hosts + "localhost with same port as server", + "127.0.0.1 (loopback) with same port as server", + "[::1] (ipv6 loopback) with same port as server", + "ipv4 address with same port as server", + "ipv6 address with same port as server", + # Invalid hosts + "localhost with default port", + "127.0.0.1 (loopback) with default port", + "[::1] (ipv6 loopback) with default port", + "ipv4 address with default port", + "ipv6 address with default port", + "random hostname with the same port as server", + "random hostname with a different port than server", + "random hostname with default port", + "localhost with a different port than server", + "127.0.0.1 (loopback) with a different port than server", + "[::1] (ipv6 loopback) with a different port than server", + "ipv4 address with a different port than server", + "ipv6 address with a different port than server", + ], +) +def test_host_header(configuration, hostname, port_type, status): + host = get_host(port_type, hostname, configuration["port"]) + response = http_request(configuration["host"], configuration["port"], host=host) + + assert response.status == status + + +@pytest.mark.parametrize( + "origin, add_port, status", + [ + (None, False, 200), + ("", False, 500), + ("sometext", False, 500), + ("http://localhost", True, 500), + ], +) +def test_origin_header(configuration, origin, add_port, status): + if add_port: + origin = f"{origin}:{configuration['port']}" + response = http_request(configuration["host"], configuration["port"], origin=origin) + assert response.status == status |