From d4d25443cb12b5c84ff27e5c4f429c56a605362e Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 21 Oct 2022 07:39:49 +0000 Subject: *) test modules/http1: adding new invalid header values and testing also via h1 proxy. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904756 13f79535-47bb-0310-9956-ffa450edef68 --- test/modules/http1/env.py | 1 + test/modules/http1/test_007_strict.py | 43 +++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/modules/http1/env.py b/test/modules/http1/env.py index 55dfbe2683..5e395f31a8 100644 --- a/test/modules/http1/env.py +++ b/test/modules/http1/env.py @@ -63,6 +63,7 @@ class H1TestEnv(HttpdTestEnv): self.httpd_error_log.set_ignored_lognos([ 'AH00135', # unsafe/strict tests send invalid methods + 'AH02430', # test of invalid chars in response headers ]) self.httpd_error_log.add_ignored_patterns([ ]) diff --git a/test/modules/http1/test_007_strict.py b/test/modules/http1/test_007_strict.py index 78182419dc..784e77b9fd 100644 --- a/test/modules/http1/test_007_strict.py +++ b/test/modules/http1/test_007_strict.py @@ -68,30 +68,55 @@ class TestRequestStrict: else: assert int(m.group(1)) >= 400, f"{rlines}" + @pytest.mark.parametrize(["hvalue", "expvalue", "status"], [ + ['"123"', '123', 200], + ['"123 "', '123 ', 200], # trailing space stays + ['"123\t"', '123\t', 200], # trailing tab stays + ['" 123"', '123', 200], # leading space is stripped + ['" 123"', '123', 200], # leading spaces are stripped + ['"\t123"', '123', 200], # leading tab is stripped + ['"expr=%{unescape:123%0A 123}"', '', 500], # illegal char + ]) + def test_h1_007_02(self, env, hvalue, expvalue, status): + hname = 'ap-test-007' + conf = H1Conf(env, extras={ + f'test1.{env.http_tld}': [ + '', + f'Header add {hname} {hvalue}', + '', + ] + }) + conf.add_vhost_test1(proxy_self=True) + conf.install() + assert env.apache_restart() == 0 + url = env.mkurl("https", "test1", "/index.html") + r = env.curl_get(url, options=['--http1.1']) + assert r.response["status"] == status + if int(status) < 400: + assert r.response["header"][hname] == expvalue + @pytest.mark.parametrize(["hvalue", "expvalue"], [ ['123', '123'], - ['123 ', '123 '], # trailing space stays - ['123\t', '123\t'], # trailing tab stays + ['123 ', '123'], # trailing space is stripped + ['123\t', '123'], # trailing tab is stripped [' 123', '123'], # leading space is stripped [' 123', '123'], # leading spaces are stripped ['\t123', '123'], # leading tab is stripped ]) - def test_h1_007_02(self, env, hvalue, expvalue): + def test_h1_007_03(self, env, hvalue, expvalue): + # same as 007_02, but http1 proxied hname = 'ap-test-007' conf = H1Conf(env, extras={ f'test1.{env.http_tld}': [ - '', + '', f'Header add {hname} "{hvalue}"', '', ] }) - conf.add_vhost_test1( - proxy_self=True - ) + conf.add_vhost_test1(proxy_self=True) conf.install() assert env.apache_restart() == 0 - url = env.mkurl("https", "test1", "/") + url = env.mkurl("https", "test1", "/proxy/index.html") r = env.curl_get(url, options=['--http1.1']) assert r.response["status"] == 200 assert r.response["header"][hname] == expvalue - -- cgit v1.2.1