From 19a281097e0c6010ce730fe7b94aa3dd6fa8fdb7 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 31 Jan 2024 15:04:34 +0100 Subject: [PATCH] Support new format for HTTP header XAPI changed HTTP header format: https://github.com/xapi-project/xen-api/pull/5238 Signed-off-by: Benjamin Reis --- tests/misc/test_file_server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/misc/test_file_server.py b/tests/misc/test_file_server.py index 547ab7879..bd4bdf7f6 100644 --- a/tests/misc/test_file_server.py +++ b/tests/misc/test_file_server.py @@ -17,11 +17,12 @@ def test_fileserver_redirect_https(host): stdout, _ = process.communicate() lines = stdout.decode().splitlines() assert lines[0].strip() == "HTTP/1.1 301 Moved Permanently" - assert lines[2].strip() == "location:https://" + host.hostname_or_ip + path + assert lines[2].split(':')[0].strip() == "location" + assert lines[2].split(':')[1].strip() == "https://" + host.hostname_or_ip + path @pytest.mark.usefixtures("host_at_least_8_3") class TestHSTS: - HSTS_HEADER = "strict-transport-security:max-age=63072000" + HSTS_HEADER = ["strict-transport-security:max-age=63072000", "strict-transport-security: max-age=63072000"] def __get_header(host): process = subprocess.Popen( @@ -35,13 +36,13 @@ def __get_header(host): def test_fileserver_hsts_default(self, host): # By default HSTS header should not be set for line in TestHSTS.__get_header(host): - assert line != TestHSTS.HSTS_HEADER + assert line not in TestHSTS.HSTS_HEADER def test_fileserver_hsts(self, host_with_hsts): hsts_header_found = False for line in TestHSTS.__get_header(host_with_hsts): - if line == TestHSTS.HSTS_HEADER: + if line in TestHSTS.HSTS_HEADER: hsts_header_found = True break