From a458f50d59ddddfd9de331f45c712fc3600295ec Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Mon, 30 Jul 2018 16:40:52 +0300 Subject: Tests: fixed header value char tests. Use byte strings to avoid problems with encoding. --- test/test_http_header.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'test/test_http_header.py') diff --git a/test/test_http_header.py b/test/test_http_header.py index f5388e9e..b787b382 100644 --- a/test/test_http_header.py +++ b/test/test_http_header.py @@ -83,12 +83,16 @@ class TestUnitHTTPHeader(unit.TestUnitApplicationPython): self.assertEqual(resp['headers']['Custom-Header'], '(),/:;<=>?@[\]{}\t !#$%&\'*+-.^_`|~', 'value chars custom header') + @unittest.expectedFailure def test_http_header_value_chars_edge(self): self.load('custom_header') - resp = self.get(headers={ - 'Custom-Header': '\x20\xFF' - }) + resp = self.http(b"""GET / HTTP/1.1 +Host: localhost +Custom-Header: \x20\xFF +Connection: close + +""", raw=True, encoding='latin1') self.assertEqual(resp['status'], 200, 'value chars edge status') self.assertEqual(resp['headers']['Custom-Header'], '\xFF', @@ -97,9 +101,12 @@ class TestUnitHTTPHeader(unit.TestUnitApplicationPython): def test_http_header_value_chars_below(self): self.load('custom_header') - resp = self.get(headers={ - 'Custom-Header': '\x1F' - }) + resp = self.http(b"""GET / HTTP/1.1 +Host: localhost +Custom-Header: \x1F +Connection: close + +""", raw=True) self.assertEqual(resp['status'], 400, 'value chars below') -- cgit