Skip to content

Commit

Permalink
Support new format for HTTP header
Browse files Browse the repository at this point in the history
XAPI changed HTTP header format:
xapi-project/xen-api#5238

Signed-off-by: Benjamin Reis <[email protected]>
  • Loading branch information
benjamreis committed Jan 31, 2024
1 parent 65f75c3 commit 19a2810
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/misc/test_file_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

Expand Down

0 comments on commit 19a2810

Please sign in to comment.