]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) test modules/http1: adding new invalid header values and testing also via h1...
authorStefan Eissing <icing@apache.org>
Fri, 21 Oct 2022 07:39:49 +0000 (07:39 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 21 Oct 2022 07:39:49 +0000 (07:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904756 13f79535-47bb-0310-9956-ffa450edef68

test/modules/http1/env.py
test/modules/http1/test_007_strict.py

index 55dfbe26833c0a7943c509768e8e270ea314c3a3..5e395f31a8db9410c35817d5b75fcf06198b576d 100644 (file)
@@ -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([
         ])
index 78182419dc283f8d5b41a6c2995e45ad6d511826..784e77b9fdc44d63f03c3d0e05d9e995adb0f99b 100644 (file)
@@ -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}': [
+                '<Location /index.html>',
+                f'Header add {hname} {hvalue}',
+                '</Location>',
+            ]
+        })
+        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}': [
-                '<Location />',
+                '<Location /index.html>',
                 f'Header add {hname} "{hvalue}"',
                 '</Location>',
             ]
         })
-        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
-