You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2021/10/28 12:50:03 UTC
svn commit: r1894599 [1/2] - in /httpd/httpd/trunk/test: ./ modules/
modules/core/ modules/http2/ pyhttpd/ pyhttpd/conf/ pyhttpd/htdocs/ssl/
Author: icing
Date: Thu Oct 28 12:50:02 2021
New Revision: 1894599
URL: http://svn.apache.org/viewvc?rev=1894599&view=rev
Log:
* test: update of python test framework after integration with mod_md
test suite that should come here soonish.
Added:
httpd/httpd/trunk/test/pyhttpd/htdocs/ssl/
httpd/httpd/trunk/test/pyhttpd/log.py
Modified:
httpd/httpd/trunk/test/conftest.py
httpd/httpd/trunk/test/modules/ (props changed)
httpd/httpd/trunk/test/modules/core/ (props changed)
httpd/httpd/trunk/test/modules/core/conftest.py
httpd/httpd/trunk/test/modules/core/test_001_encoding.py
httpd/httpd/trunk/test/modules/http2/conftest.py
httpd/httpd/trunk/test/modules/http2/env.py
httpd/httpd/trunk/test/modules/http2/test_002_curl_basics.py
httpd/httpd/trunk/test/modules/http2/test_003_get.py
httpd/httpd/trunk/test/modules/http2/test_004_post.py
httpd/httpd/trunk/test/modules/http2/test_005_files.py
httpd/httpd/trunk/test/modules/http2/test_100_conn_reuse.py
httpd/httpd/trunk/test/modules/http2/test_101_ssl_reneg.py
httpd/httpd/trunk/test/modules/http2/test_102_require.py
httpd/httpd/trunk/test/modules/http2/test_103_upgrade.py
httpd/httpd/trunk/test/modules/http2/test_104_padding.py
httpd/httpd/trunk/test/modules/http2/test_105_timeout.py
httpd/httpd/trunk/test/modules/http2/test_106_shutdown.py
httpd/httpd/trunk/test/modules/http2/test_200_header_invalid.py
httpd/httpd/trunk/test/modules/http2/test_201_header_conditional.py
httpd/httpd/trunk/test/modules/http2/test_300_interim.py
httpd/httpd/trunk/test/modules/http2/test_400_push.py
httpd/httpd/trunk/test/modules/http2/test_401_early_hints.py
httpd/httpd/trunk/test/modules/http2/test_500_proxy.py
httpd/httpd/trunk/test/modules/http2/test_501_proxy_serverheader.py
httpd/httpd/trunk/test/pyhttpd/conf.py
httpd/httpd/trunk/test/pyhttpd/conf/httpd.conf.template
httpd/httpd/trunk/test/pyhttpd/config.ini.in
httpd/httpd/trunk/test/pyhttpd/env.py
httpd/httpd/trunk/test/pyhttpd/nghttp.py
httpd/httpd/trunk/test/pyhttpd/result.py
Modified: httpd/httpd/trunk/test/conftest.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/conftest.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/conftest.py (original)
+++ httpd/httpd/trunk/test/conftest.py Thu Oct 28 12:50:02 2021
@@ -7,6 +7,6 @@ from pyhttpd.env import HttpdTestEnv
def pytest_report_header(config, startdir):
env = HttpdTestEnv()
- return f"[apache httpd: {env.get_httpd_version()}, mpm: {env.mpm_type}, {env.prefix}]"
+ return f"[apache httpd: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]"
Propchange: httpd/httpd/trunk/test/modules/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct 28 12:50:02 2021
@@ -0,0 +1 @@
+.pytest_cache
Propchange: httpd/httpd/trunk/test/modules/core/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Oct 28 12:50:02 2021
@@ -0,0 +1 @@
+.pytest_cache
Modified: httpd/httpd/trunk/test/modules/core/conftest.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/core/conftest.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/core/conftest.py (original)
+++ httpd/httpd/trunk/test/modules/core/conftest.py Thu Oct 28 12:50:02 2021
@@ -11,7 +11,7 @@ from .env import CoreTestEnv
def pytest_report_header(config, startdir):
env = CoreTestEnv(setup_dirs=False)
- return f"core [apache: {env.get_httpd_version()}, mpm: {env.mpm_type}, {env.prefix}]"
+ return f"core [apache: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]"
@pytest.fixture(scope="package")
@@ -24,15 +24,19 @@ def env(pytestconfig) -> CoreTestEnv:
logging.getLogger('').setLevel(level=level)
env = CoreTestEnv(pytestconfig=pytestconfig)
env.apache_access_log_clear()
- env.apache_error_log_clear()
+ env.httpd_error_log.clear_log()
return env
@pytest.fixture(autouse=True, scope="package")
def _session_scope(env):
+ env.httpd_error_log.set_ignored_lognos([
+ 'AH10244', # core: invalid URI path
+ 'AH01264', # mod_cgid script not found
+ ])
yield
assert env.apache_stop() == 0
- errors, warnings = env.apache_errors_and_warnings()
+ errors, warnings = env.httpd_error_log.get_missed()
assert (len(errors), len(warnings)) == (0, 0),\
f"apache logged {len(errors)} errors and {len(warnings)} warnings: \n"\
"{0}\n{1}\n".format("\n".join(errors), "\n".join(warnings))
Modified: httpd/httpd/trunk/test/modules/core/test_001_encoding.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/core/test_001_encoding.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/core/test_001_encoding.py (original)
+++ httpd/httpd/trunk/test/modules/core/test_001_encoding.py Thu Oct 28 12:50:02 2021
@@ -9,30 +9,22 @@ class TestEncoding:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- conf = HttpdConf(env)
- conf.add(f"""
+ conf = HttpdConf(env, extras={
+ 'base': f"""
<Directory "{env.gen_dir}">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
- """)
- conf.add_vhost_test1()
- conf.add_vhost_test2(extras={
+ """,
f"test2.{env.http_tld}": "AllowEncodedSlashes on",
- })
- conf.add_vhost_cgi(extras={
f"cgi.{env.http_tld}": f"ScriptAlias /cgi-bin/ {env.gen_dir}",
})
+ conf.add_vhost_test1()
+ conf.add_vhost_test2()
+ conf.add_vhost_cgi()
conf.install()
assert env.apache_restart() == 0
- yield
- errors, warnings = env.apache_errors_and_warnings()
- nl = "\n"
- assert (len(errors), len(warnings)) == (TestEncoding.EXP_AH10244_ERRS, 0),\
- f"apache logged {len(errors)} errors and {len(warnings)} warnings: \n"\
- f"{nl.join(errors)}\n{nl.join(warnings)}\n"
- env.apache_error_log_clear()
# check handling of url encodings that are accepted
@pytest.mark.parametrize("path", [
Modified: httpd/httpd/trunk/test/modules/http2/conftest.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/conftest.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/conftest.py (original)
+++ httpd/httpd/trunk/test/modules/http2/conftest.py Thu Oct 28 12:50:02 2021
@@ -11,7 +11,7 @@ from .env import H2TestEnv
def pytest_report_header(config, startdir):
env = H2TestEnv(setup_dirs=False)
- return f"mod_h2 [apache: {env.get_httpd_version()}, mpm: {env.mpm_type}, {env.prefix}]"
+ return f"mod_h2 [apache: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]"
def pytest_addoption(parser):
@@ -37,7 +37,7 @@ def env(pytestconfig) -> H2TestEnv:
logging.getLogger('').setLevel(level=level)
env = H2TestEnv(pytestconfig=pytestconfig)
env.apache_access_log_clear()
- env.apache_error_log_clear()
+ env.httpd_error_log.clear_log()
return env
@@ -45,7 +45,7 @@ def env(pytestconfig) -> H2TestEnv:
def _session_scope(env):
yield
assert env.apache_stop() == 0
- errors, warnings = env.apache_errors_and_warnings()
+ errors, warnings = env.httpd_error_log.get_missed()
assert (len(errors), len(warnings)) == (0, 0),\
f"apache logged {len(errors)} errors and {len(warnings)} warnings: \n"\
"{0}\n{1}\n".format("\n".join(errors), "\n".join(warnings))
Modified: httpd/httpd/trunk/test/modules/http2/env.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/env.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/env.py (original)
+++ httpd/httpd/trunk/test/modules/http2/env.py Thu Oct 28 12:50:02 2021
@@ -1,7 +1,9 @@
import inspect
import logging
import os
+import re
import subprocess
+from typing import Dict, Any
from pyhttpd.certs import CertificateSpec
from pyhttpd.conf import HttpdConf
@@ -39,10 +41,11 @@ class H2TestEnv(HttpdTestEnv):
def __init__(self, pytestconfig=None, setup_dirs=True):
super().__init__(pytestconfig=pytestconfig,
local_dir=os.path.dirname(inspect.getfile(H2TestEnv)),
- add_base_conf="""
- H2MinWorkers 1
- H2MaxWorkers 64
- """,
+ add_base_conf=[
+ "H2MinWorkers 1",
+ "H2MaxWorkers 64",
+ "Protocols h2 http/1.1 h2c",
+ ],
interesting_modules=["http2", "proxy_http2", "h2test"])
self.add_cert_specs([
CertificateSpec(domains=[
@@ -57,6 +60,18 @@ class H2TestEnv(HttpdTestEnv):
]),
CertificateSpec(domains=[f"noh2.{self.http_tld}"], key_type='rsa2048'),
])
+
+ self.httpd_error_log.set_ignored_lognos([
+ 'AH02032',
+ 'AH01276',
+ 'AH01630',
+ 'AH00135',
+ 'AH02261', # Re-negotiation handshake failed (our test_101)
+ ])
+ self.httpd_error_log.add_ignored_patterns([
+ re.compile(r'.*malformed header from script \'hecho.py\': Bad header: x.*'),
+ ])
+
if setup_dirs:
self._setup = H2TestSetup(env=self)
self._setup.make()
@@ -82,18 +97,40 @@ class H2TestEnv(HttpdTestEnv):
class H2Conf(HttpdConf):
- def __init__(self, env: HttpdTestEnv, path=None):
- super().__init__(env=env, path=path)
-
+ def __init__(self, env: HttpdTestEnv, extras: Dict[str, Any] = None):
+ super().__init__(env=env, extras=HttpdConf.merge_extras(extras, {
+ f"cgi.{env.http_tld}": [
+ "SSLOptions +StdEnvVars",
+ "AddHandler cgi-script .py",
+ ]
+ }))
+
+ def start_vhost(self, domains, port=None, doc_root="htdocs", with_ssl=False):
+ super().start_vhost(domains=domains, port=port, doc_root=doc_root, with_ssl=with_ssl)
+ if f"noh2.{self.env.http_tld}" in domains:
+ protos = ["http/1.1"]
+ elif port == self.env.https_port or with_ssl is True:
+ protos = ["h2", "http/1.1"]
+ else:
+ protos = ["h2c", "http/1.1"]
+ if f"test2.{self.env.http_tld}" in domains:
+ protos = reversed(protos)
+ self.add(f"Protocols {' '.join(protos)}")
+ return self
def add_vhost_noh2(self):
- self.start_vhost(self.env.https_port, "noh2", aliases=["noh2-alias"], doc_root="htdocs/noh2", with_ssl=True)
- self.add(f"""
- Protocols http/1.1
- SSLOptions +StdEnvVars""")
+ domains = [f"noh2.{self.env.http_tld}", f"noh2-alias.{self.env.http_tld}"]
+ self.start_vhost(domains=domains, port=self.env.https_port, doc_root="htdocs/noh2")
+ self.add(["Protocols http/1.1", "SSLOptions +StdEnvVars"])
self.end_vhost()
- self.start_vhost(self.env.http_port, "noh2", aliases=["noh2-alias"], doc_root="htdocs/noh2", with_ssl=False)
- self.add(" Protocols http/1.1")
- self.add(" SSLOptions +StdEnvVars")
+ self.start_vhost(domains=domains, port=self.env.http_port, doc_root="htdocs/noh2")
+ self.add(["Protocols http/1.1", "SSLOptions +StdEnvVars"])
self.end_vhost()
return self
+
+ def add_vhost_test1(self, proxy_self=False, h2proxy_self=False):
+ return super().add_vhost_test1(proxy_self=proxy_self, h2proxy_self=h2proxy_self)
+
+ def add_vhost_test2(self):
+ return super().add_vhost_test2()
+
Modified: httpd/httpd/trunk/test/modules/http2/test_002_curl_basics.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_002_curl_basics.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_002_curl_basics.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_002_curl_basics.py Thu Oct 28 12:50:02 2021
@@ -7,62 +7,64 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- H2Conf(env).add_vhost_test1().add_vhost_test2().install()
+ conf = H2Conf(env)
+ conf.add_vhost_test1()
+ conf.add_vhost_test2()
+ conf.install()
assert env.apache_restart() == 0
# check that we see the correct documents when using the test1 server name over http:
def test_h2_002_01(self, env):
url = env.mkurl("http", "test1", "/alive.json")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/1.1" == r.response["protocol"]
- assert True == r.response["json"]["alive"]
- assert "test1" == r.response["json"]["host"]
+ assert r.response["json"]["alive"] is True
+ assert r.response["json"]["host"] == "test1"
# check that we see the correct documents when using the test1 server name over https:
def test_h2_002_02(self, env):
url = env.mkurl("https", "test1", "/alive.json")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert r.response["json"]["alive"] is True
assert "test1" == r.response["json"]["host"]
- assert "application/json" == r.response["header"]["content-type"]
+ assert r.response["header"]["content-type"] == "application/json"
# enforce HTTP/1.1
def test_h2_002_03(self, env):
url = env.mkurl("https", "test1", "/alive.json")
- r = env.curl_get(url, 5, [ "--http1.1" ])
- assert 200 == r.response["status"]
- assert "HTTP/1.1" == r.response["protocol"]
+ r = env.curl_get(url, 5, options=["--http1.1"])
+ assert r.response["status"] == 200
+ assert r.response["protocol"] == "HTTP/1.1"
# enforce HTTP/2
def test_h2_002_04(self, env):
url = env.mkurl("https", "test1", "/alive.json")
- r = env.curl_get(url, 5, [ "--http2" ])
- assert 200 == r.response["status"]
- assert "HTTP/2" == r.response["protocol"]
+ r = env.curl_get(url, 5, options=["--http2"])
+ assert r.response["status"] == 200
+ assert r.response["protocol"] == "HTTP/2"
# default is HTTP/2 on this host
def test_h2_002_04b(self, env):
url = env.mkurl("https", "test1", "/alive.json")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
- assert "HTTP/2" == r.response["protocol"]
- assert "test1" == r.response["json"]["host"]
+ assert r.response["status"] == 200
+ assert r.response["protocol"] == "HTTP/2"
+ assert r.response["json"]["host"] == "test1"
# although, without ALPN, we cannot select it
def test_h2_002_05(self, env):
url = env.mkurl("https", "test1", "/alive.json")
- r = env.curl_get(url, 5, [ "--no-alpn" ])
- assert 200 == r.response["status"]
- assert "HTTP/1.1" == r.response["protocol"]
- assert "test1" == r.response["json"]["host"]
+ r = env.curl_get(url, 5, options=["--no-alpn"])
+ assert r.response["status"] == 200
+ assert r.response["protocol"] == "HTTP/1.1"
+ assert r.response["json"]["host"] == "test1"
# default is HTTP/1.1 on the other
def test_h2_002_06(self, env):
url = env.mkurl("https", "test2", "/alive.json")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
- assert "HTTP/1.1" == r.response["protocol"]
- assert "test2" == r.response["json"]["host"]
-
+ assert r.response["status"] == 200
+ assert r.response["protocol"] == "HTTP/1.1"
+ assert r.response["json"]["host"] == "test2"
Modified: httpd/httpd/trunk/test/modules/http2/test_003_get.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_003_get.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_003_get.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_003_get.py Thu Oct 28 12:50:02 2021
@@ -18,17 +18,17 @@ class TestStore:
# check SSL environment variables from CGI script
def test_h2_003_01(self, env):
url = env.mkurl("https", "cgi", "/hello.py")
- r = env.curl_get(url, 5, ["--tlsv1.2"])
- assert 200 == r.response["status"]
- assert "HTTP/2.0" == r.response["json"]["protocol"]
- assert "on" == r.response["json"]["https"]
+ r = env.curl_get(url, 5, options=["--tlsv1.2"])
+ assert r.response["status"] == 200
+ assert r.response["json"]["protocol"] == "HTTP/2.0"
+ assert r.response["json"]["https"] == "on"
tls_version = r.response["json"]["ssl_protocol"]
assert tls_version in ["TLSv1.2", "TLSv1.3"]
- assert "on" == r.response["json"]["h2"]
- assert "off" == r.response["json"]["h2push"]
+ assert r.response["json"]["h2"] == "on"
+ assert r.response["json"]["h2push"] == "off"
- r = env.curl_get(url, 5, ["--http1.1", "--tlsv1.2"])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=["--http1.1", "--tlsv1.2"])
+ assert r.response["status"] == 200
assert "HTTP/1.1" == r.response["json"]["protocol"]
assert "on" == r.response["json"]["https"]
tls_version = r.response["json"]["ssl_protocol"]
@@ -43,21 +43,21 @@ class TestStore:
url = env.mkurl("https", "test1", "/index.html")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
assert src == r.response["body"]
url = env.mkurl("https", "test1", "/index.html")
- r = env.curl_get(url, 5, ["--http1.1"])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=["--http1.1"])
+ assert r.response["status"] == 200
assert "HTTP/1.1" == r.response["protocol"]
assert src == r.response["body"]
# retrieve chunked content from a cgi script
def check_necho(self, env, n, text):
url = env.mkurl("https", "cgi", "/necho.py")
- r = env.curl_get(url, 5, ["-F", f"count={n}", "-F", f"text={text}"])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=["-F", f"count={n}", "-F", f"text={text}"])
+ assert r.response["status"] == 200
exp = ""
for i in range(n):
exp += text + "\n"
@@ -82,7 +82,7 @@ class TestStore:
def test_h2_003_20(self, env):
url = env.mkurl("https", "test1", "/006/")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
body = r.response["body"].decode('utf-8')
# our doctype varies between branches and in time, lets not compare
body = re.sub(r'^<!DOCTYPE[^>]+>', '', body)
@@ -113,8 +113,8 @@ class TestStore:
def test_h2_003_21(self, env):
url = env.mkurl("https", "test1", "/index.html")
- r = env.curl_get(url, 5, ["-I"])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=["-I"])
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
s = self.clean_header(r.response["body"].decode('utf-8'))
assert '''HTTP/2 200
@@ -123,8 +123,8 @@ content-type: text/html
''' == s
- r = env.curl_get(url, 5, ["-I", url])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=["-I", url])
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
s = self.clean_header(r.response["body"].decode('utf-8'))
assert '''HTTP/2 200
@@ -144,12 +144,12 @@ content-type: text/html
def test_h2_003_30(self, env, path):
url = env.mkurl("https", "test1", path)
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
h = r.response["header"]
assert "last-modified" in h
lastmod = h["last-modified"]
- r = env.curl_get(url, 5, ['-H', ("if-modified-since: %s" % lastmod)])
+ r = env.curl_get(url, 5, options=['-H', ("if-modified-since: %s" % lastmod)])
assert 304 == r.response["status"]
# test conditionals: if-etag
@@ -159,12 +159,12 @@ content-type: text/html
def test_h2_003_31(self, env, path):
url = env.mkurl("https", "test1", path)
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
h = r.response["header"]
assert "etag" in h
etag = h["etag"]
- r = env.curl_get(url, 5, ['-H', ("if-none-match: %s" % etag)])
+ r = env.curl_get(url, 5, options=['-H', ("if-none-match: %s" % etag)])
assert 304 == r.response["status"]
# test various response body lengths to work correctly
@@ -173,7 +173,7 @@ content-type: text/html
while n <= 1025024:
url = env.mkurl("https", "cgi", f"/mnot164.py?count={n}&text=X")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
assert n == len(r.response["body"])
n *= 2
@@ -185,7 +185,7 @@ content-type: text/html
def test_h2_003_41(self, env, n):
url = env.mkurl("https", "cgi", f"/mnot164.py?count={n}&text=X")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
assert n == len(r.response["body"])
@@ -197,7 +197,7 @@ content-type: text/html
# check that the resource supports ranges and we see its raw content-length
url = env.mkurl("https", "test1", path)
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
h = r.response["header"]
assert "accept-ranges" in h
Modified: httpd/httpd/trunk/test/modules/http2/test_004_post.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_004_post.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_004_post.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_004_post.py Thu Oct 28 12:50:02 2021
@@ -15,7 +15,7 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
env.setup_data_1k_1m()
- H2Conf(env).add("Timeout 10").add_vhost_cgi().install()
+ H2Conf(env).add_vhost_cgi().install()
assert env.apache_restart() == 0
# upload and GET again using curl, compare to original content
@@ -23,8 +23,8 @@ class TestStore:
url = env.mkurl("https", "cgi", "/upload.py")
fpath = os.path.join(env.gen_dir, fname)
r = env.curl_upload(url, fpath, options=options)
- assert r.exit_code == 0, r.stderr
- assert r.response["status"] >= 200 and r.response["status"] < 300
+ assert r.exit_code == 0, f"{r}"
+ assert 200 <= r.response["status"] < 300
r2 = env.curl_get(r.response["header"]["location"])
assert r2.exit_code == 0
@@ -34,7 +34,7 @@ class TestStore:
assert src == r2.response["body"]
def test_h2_004_01(self, env):
- self.curl_upload_and_verify(env, "data-1k", ["--http1.1"])
+ self.curl_upload_and_verify(env, "data-1k", ["-vvv", "--http1.1"])
self.curl_upload_and_verify(env, "data-1k", ["--http2"])
def test_h2_004_02(self, env):
@@ -99,10 +99,9 @@ class TestStore:
assert r.response["body"] == src, f"expected '{src}', got '{r.response['body']}'"
@pytest.mark.parametrize("name", [
- # "data-1k", "data-10k", "data-100k", "data-1m"
- "data-1m"
+ "data-1k", "data-10k", "data-100k", "data-1m"
])
- def test_h2_004_21(self, env, name, repeat):
+ def test_h2_004_21(self, env, name):
self.nghttp_post_and_verify(env, name, [])
@pytest.mark.parametrize("name", [
@@ -161,12 +160,12 @@ CustomLog logs/test_004_30 issue_203
""").add_vhost_cgi().install()
assert env.apache_restart() == 0
url = env.mkurl("https", "cgi", "/files/{0}".format(resource))
- r = env.curl_get(url, 5, ["--http2"])
- assert 200 == r.response["status"]
- r = env.curl_get(url, 5, ["--http1.1", "-H", "Range: bytes=0-{0}".format(chunk-1)])
+ r = env.curl_get(url, 5, options=["--http2"])
+ assert r.response["status"] == 200
+ r = env.curl_get(url, 5, options=["--http1.1", "-H", "Range: bytes=0-{0}".format(chunk-1)])
assert 206 == r.response["status"]
assert chunk == len(r.response["body"].decode('utf-8'))
- r = env.curl_get(url, 5, ["--http2", "-H", "Range: bytes=0-{0}".format(chunk-1)])
+ r = env.curl_get(url, 5, options=["--http2", "-H", "Range: bytes=0-{0}".format(chunk-1)])
assert 206 == r.response["status"]
assert chunk == len(r.response["body"].decode('utf-8'))
# now check what response lengths have actually been reported
Modified: httpd/httpd/trunk/test/modules/http2/test_005_files.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_005_files.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_005_files.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_005_files.py Thu Oct 28 12:50:02 2021
@@ -44,4 +44,4 @@ class TestFiles:
url = env.mkurl("https", "cgi", self.URI_PATHS[2])
r = env.curl_get(url)
assert r.response, r.stderr + r.stdout
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
Modified: httpd/httpd/trunk/test/modules/http2/test_100_conn_reuse.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_100_conn_reuse.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_100_conn_reuse.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_100_conn_reuse.py Thu Oct 28 12:50:02 2021
@@ -26,8 +26,8 @@ class TestStore:
def test_h2_100_02(self, env):
url = env.mkurl("https", "cgi", "/hello.py")
hostname = ("cgi-alias.%s" % env.http_tld)
- r = env.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=[ "-H", "Host:%s" % hostname ])
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
assert hostname == r.response["json"]["host"]
@@ -35,8 +35,8 @@ class TestStore:
def test_h2_100_03(self, env):
url = env.mkurl("https", "cgi", "/")
hostname = ("test1.%s" % env.http_tld)
- r = env.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
- assert 200 == r.response["status"]
+ r = env.curl_get(url, 5, options=[ "-H", "Host:%s" % hostname ])
+ assert r.response["status"] == 200
assert "HTTP/2" == r.response["protocol"]
assert "text/html" == r.response["header"]["content-type"]
@@ -45,12 +45,12 @@ class TestStore:
def test_h2_100_04(self, env):
url = env.mkurl("https", "cgi", "/hello.py")
hostname = ("noh2.%s" % env.http_tld)
- r = env.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
+ r = env.curl_get(url, 5, options=[ "-H", "Host:%s" % hostname ])
assert 421 == r.response["status"]
# access an unknown vhost, after using ServerName in SNI
def test_h2_100_05(self, env):
url = env.mkurl("https", "cgi", "/hello.py")
hostname = ("unknown.%s" % env.http_tld)
- r = env.curl_get(url, 5, [ "-H", "Host:%s" % hostname ])
+ r = env.curl_get(url, 5, options=[ "-H", "Host:%s" % hostname ])
assert 421 == r.response["status"]
Modified: httpd/httpd/trunk/test/modules/http2/test_101_ssl_reneg.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_101_ssl_reneg.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_101_ssl_reneg.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_101_ssl_reneg.py Thu Oct 28 12:50:02 2021
@@ -8,36 +8,38 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- H2Conf(env).add(
- f"""
- SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384
- <Directory \"{env.server_dir}/htdocs/ssl-client-verify\">
- Require all granted
- SSLVerifyClient require
- SSLVerifyDepth 0
- </Directory>"""
- ).start_vhost(
- env.https_port, "ssl", with_ssl=True
- ).add(
- f"""
- Protocols h2 http/1.1"
- <Location /renegotiate/cipher>
- SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305
- </Location>
- <Location /renegotiate/err-doc-cipher>
- SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305
- ErrorDocument 403 /forbidden.html
- </Location>
- <Location /renegotiate/verify>
- SSLVerifyClient require
- </Location>
- <Directory \"{env.server_dir}/htdocs/sslrequire\">
- SSLRequireSSL
- </Directory>
- <Directory \"{env.server_dir}/htdocs/requiressl\">
- Require ssl
- </Directory>"""
- ).end_vhost().install()
+ domain = f"ssl.{env.http_tld}"
+ conf = H2Conf(env, extras={
+ 'base': [
+ "SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384",
+ f"<Directory \"{env.server_dir}/htdocs/ssl-client-verify\">",
+ " Require all granted",
+ " SSLVerifyClient require",
+ " SSLVerifyDepth 0",
+ "</Directory>"
+ ],
+ domain: [
+ "Protocols h2 http/1.1",
+ "<Location /renegotiate/cipher>",
+ " SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305",
+ "</Location>",
+ "<Location /renegotiate/err-doc-cipher>",
+ " SSLCipherSuite ECDHE-RSA-CHACHA20-POLY1305",
+ " ErrorDocument 403 /forbidden.html",
+ "</Location>",
+ "<Location /renegotiate/verify>",
+ " SSLVerifyClient require",
+ "</Location>",
+ f"<Directory \"{env.server_dir}/htdocs/sslrequire\">",
+ " SSLRequireSSL",
+ "</Directory>",
+ f"<Directory \"{env.server_dir}/htdocs/requiressl\">",
+ " Require ssl",
+ "</Directory>",
+ ]})
+ conf.add_vhost(domains=[domain], port=env.https_port,
+ doc_root=f"{env.server_dir}/htdocs")
+ conf.install()
# the dir needs to exists for the configuration to have effect
env.mkpath("%s/htdocs/ssl-client-verify" % env.server_dir)
env.mkpath("%s/htdocs/renegotiate/cipher" % env.server_dir)
@@ -49,7 +51,7 @@ class TestStore:
def test_h2_101_01(self, env):
url = env.mkurl("https", "ssl", "/renegotiate/cipher/")
r = env.curl_get(url, options=["-v", "--http1.1", "--tlsv1.2", "--tls-max", "1.2"])
- assert 0 == r.exit_code
+ assert 0 == r.exit_code, f"{r}"
assert r.response
assert 403 == r.response["status"]
@@ -77,7 +79,7 @@ class TestStore:
def test_h2_101_04(self, env):
url = env.mkurl("https", "ssl", "/ssl-client-verify/index.html")
r = env.curl_get(url, options=["-vvv", "--tlsv1.2", "--tls-max", "1.2"])
- assert 0 != r.exit_code
+ assert 0 != r.exit_code, f"{r}"
assert not r.response
assert re.search(r'HTTP_1_1_REQUIRED \(err 13\)', r.stderr)
Modified: httpd/httpd/trunk/test/modules/http2/test_102_require.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_102_require.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_102_require.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_102_require.py Thu Oct 28 12:50:02 2021
@@ -7,7 +7,9 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- conf = H2Conf(env).start_vhost(env.https_port, "ssl", with_ssl=True)
+ domain = f"ssl.{env.http_tld}"
+ conf = H2Conf(env)
+ conf.start_vhost(domains=[domain], port=env.https_port)
conf.add("""
Protocols h2 http/1.1
SSLOptions +StdEnvVars
@@ -20,7 +22,7 @@ class TestStore:
conf.end_vhost()
conf.install()
# the dir needs to exists for the configuration to have effect
- env.mkpath("%s/htdocs/ssl-client-verify" % env.server_dir)
+ env.mkpath(f"{env.server_dir}/htdocs/ssl-client-verify")
assert env.apache_restart() == 0
def test_h2_102_01(self, env):
Modified: httpd/httpd/trunk/test/modules/http2/test_103_upgrade.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_103_upgrade.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_103_upgrade.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_103_upgrade.py Thu Oct 28 12:50:02 2021
@@ -8,15 +8,13 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
H2Conf(env).add_vhost_test1().add_vhost_test2().add_vhost_noh2(
- ).start_vhost(
- env.https_port, "test3", doc_root="htdocs/test1", with_ssl=True
+ ).start_vhost(domains=[f"test3.{env.http_tld}"], port=env.https_port, doc_root="htdocs/test1"
).add(
"""
Protocols h2 http/1.1
Header unset Upgrade"""
).end_vhost(
- ).start_vhost(
- env.http_port, "test1b", doc_root="htdocs/test1", with_ssl=False
+ ).start_vhost(domains=[f"test1b.{env.http_tld}"], port=env.http_port, doc_root="htdocs/test1"
).add(
"""
Protocols h2c http/1.1
@@ -90,7 +88,7 @@ class TestStore:
def test_h2_103_20(self, env):
url = env.mkurl("http", "test1", "/index.html")
r = env.nghttp().get(url, options=["-u"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
# upgrade to h2c for a request where http/1.1 is preferred, but the clients upgrade
# wish is honored nevertheless
@@ -116,4 +114,4 @@ class TestStore:
def test_h2_103_24(self, env):
url = env.mkurl("http", "test1b", "/006.html")
r = env.nghttp().get(url, options=["-u"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
Modified: httpd/httpd/trunk/test/modules/http2/test_104_padding.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_104_padding.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_104_padding.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_104_padding.py Thu Oct 28 12:50:02 2021
@@ -13,32 +13,26 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
conf = H2Conf(env)
- conf.start_vhost(env.https_port, "ssl", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"ssl.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
- conf.start_vhost(env.https_port, "pad0", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"pad0.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("H2Padding 0")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
- conf.start_vhost(env.https_port, "pad1", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"pad1.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("H2Padding 1")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
- conf.start_vhost(env.https_port, "pad2", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"pad2.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("H2Padding 2")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
- conf.start_vhost(env.https_port, "pad3", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"pad3.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("H2Padding 3")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
- conf.start_vhost(env.https_port, "pad8", doc_root="htdocs/cgi", with_ssl=True)
- conf.add("Protocols h2 http/1.1")
+ conf.start_vhost(domains=[f"pad8.{env.http_tld}"], port=env.https_port, doc_root="htdocs/cgi")
conf.add("H2Padding 8")
conf.add("AddHandler cgi-script .py")
conf.end_vhost()
@@ -52,7 +46,7 @@ class TestStore:
# check the number of padding bytes is as expected
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert r.results["paddings"] == [
frame_padding(len(data)+1, 0),
frame_padding(0, 0)
@@ -63,7 +57,7 @@ class TestStore:
url = env.mkurl("https", "pad0", "/echo.py")
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert r.results["paddings"] == [0, 0]
# 1 bit of padding
@@ -71,7 +65,7 @@ class TestStore:
url = env.mkurl("https", "pad1", "/echo.py")
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
for i in r.results["paddings"]:
assert i in range(0, 2)
@@ -80,7 +74,7 @@ class TestStore:
url = env.mkurl("https", "pad2", "/echo.py")
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
for i in r.results["paddings"]:
assert i in range(0, 4)
@@ -89,7 +83,7 @@ class TestStore:
url = env.mkurl("https", "pad3", "/echo.py")
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
for i in r.results["paddings"]:
assert i in range(0, 8)
@@ -98,6 +92,6 @@ class TestStore:
url = env.mkurl("https", "pad8", "/echo.py")
for data in ["x", "xx", "xxx", "xxxx", "xxxxx", "xxxxxx", "xxxxxxx", "xxxxxxxx"]:
r = env.nghttp().post_data(url, data, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
for i in r.results["paddings"]:
assert i in range(0, 256)
Modified: httpd/httpd/trunk/test/modules/http2/test_105_timeout.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_105_timeout.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_105_timeout.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_105_timeout.py Thu Oct 28 12:50:02 2021
@@ -90,13 +90,13 @@ class TestStore:
conf.install()
assert env.apache_restart() == 0
url = env.mkurl("https", "cgi", "/necho.py")
- r = env.curl_get(url, 5, [
+ r = env.curl_get(url, 5, options=[
"-vvv",
"-F", ("count=%d" % 100),
"-F", ("text=%s" % "abcdefghijklmnopqrstuvwxyz"),
"-F", ("wait1=%f" % 1.5),
])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
def test_h2_105_10(self, env):
# just a check without delays if all is fine
Modified: httpd/httpd/trunk/test/modules/http2/test_106_shutdown.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_106_shutdown.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_106_shutdown.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_106_shutdown.py Thu Oct 28 12:50:02 2021
@@ -32,7 +32,7 @@ class TestShutdown:
"-F", f"text={text}",
"-F", f"wait2={wait2}",
]
- self.r = env.curl_get(url, 5, args)
+ self.r = env.curl_get(url, 5, options=args)
t = Thread(target=long_request)
t.start()
@@ -40,6 +40,9 @@ class TestShutdown:
assert env.apache_reload() == 0
t.join()
# noinspection PyTypeChecker
+ time.sleep(1)
r: ExecResult = self.r
- assert r.response["status"] == 200
- assert len(r.response["body"]) == (lines * (len(text)+1))
+ assert r.exit_code == 0
+ assert r.response, f"no response via {r.args} in {r.stderr}\nstdout: {len(r.stdout)} bytes"
+ assert r.response["status"] == 200, f"{r}"
+ assert len(r.response["body"]) == (lines * (len(text)+1)), f"{r}"
Modified: httpd/httpd/trunk/test/modules/http2/test_200_header_invalid.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_200_header_invalid.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_200_header_invalid.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_200_header_invalid.py Thu Oct 28 12:50:02 2021
@@ -57,12 +57,12 @@ class TestStore:
val = "%s%s%s%s%s%s%s%s%s%s" % (val, val, val, val, val, val, val, val, val, val)
# LimitRequestLine 8190 ok, one more char -> 431
r = env.curl_get(url, options=["-H", "x: %s" % (val[:8187])])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
r = env.curl_get(url, options=["-H", "x: %sx" % (val[:8188])])
assert 431 == r.response["status"]
# same with field name
r = env.curl_get(url, options=["-H", "y%s: 1" % (val[:8186])])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
r = env.curl_get(url, options=["-H", "y%s: 1" % (val[:8188])])
assert 431 == r.response["status"]
@@ -75,7 +75,7 @@ class TestStore:
# LimitRequestFieldSize 8190 ok, one more char -> 400 in HTTP/1.1
# (we send 4000+4185 since they are concatenated by ", " and start with "x: "
r = env.curl_get(url, options=["-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4185])])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
r = env.curl_get(url, options=["--http1.1", "-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4189])])
assert 400 == r.response["status"]
r = env.curl_get(url, options=["-H", "x: %s" % (val[:4000]), "-H", "x: %s" % (val[:4191])])
@@ -89,9 +89,9 @@ class TestStore:
for i in range(98): # curl sends 2 headers itself (user-agent and accept)
opt += ["-H", "x: 1"]
r = env.curl_get(url, options=opt)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
r = env.curl_get(url, options=(opt + ["-H", "y: 2"]))
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
# test header field count, LimitRequestFields (default 100)
# different header names count each
@@ -101,7 +101,7 @@ class TestStore:
for i in range(98): # curl sends 2 headers itself (user-agent and accept)
opt += ["-H", "x{0}: 1".format(i)]
r = env.curl_get(url, options=opt)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
r = env.curl_get(url, options=(opt + ["-H", "y: 2"]))
assert 431 == r.response["status"]
@@ -132,7 +132,7 @@ class TestStore:
for i in range(100):
opt += ["-H", "x{0}: 1".format(i)]
r = env.curl_get(url, options=opt)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
# the uri limits
def test_h2_200_15(self, env):
@@ -145,7 +145,7 @@ class TestStore:
assert env.apache_restart() == 0
url = env.mkurl("https", "cgi", "/")
r = env.curl_get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
url = env.mkurl("https", "cgi", "/" + (48*"x"))
r = env.curl_get(url)
assert 414 == r.response["status"]
Modified: httpd/httpd/trunk/test/modules/http2/test_201_header_conditional.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_201_header_conditional.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_201_header_conditional.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_201_header_conditional.py Thu Oct 28 12:50:02 2021
@@ -19,31 +19,31 @@ class TestStore:
def test_h2_201_01(self, env):
url = env.mkurl("https", "test1", "/006/006.css")
r = env.curl_get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
lm = r.response["header"]["last-modified"]
assert lm
r = env.curl_get(url, options=["-H", "if-modified-since: %s" % lm])
assert 304 == r.response["status"]
r = env.curl_get(url, options=["-H", "if-modified-since: Tue, 04 Sep 2010 11:51:59 GMT"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
# check handling of 'if-none-match' header
def test_h2_201_02(self, env):
url = env.mkurl("https", "test1", "/006/006.css")
r = env.curl_get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
etag = r.response["header"]["etag"]
assert etag
r = env.curl_get(url, options=["-H", "if-none-match: %s" % etag])
assert 304 == r.response["status"]
r = env.curl_get(url, options=["-H", "if-none-match: dummy"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
@pytest.mark.skipif(True, reason="304 misses the Vary header in trunk and 2.4.x")
def test_h2_201_03(self, env):
url = env.mkurl("https", "test1", "/006.html")
r = env.curl_get(url, options=["-H", "Accept-Encoding: gzip"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
for h in r.response["header"]:
print("%s: %s" % (h, r.response["header"][h]))
lm = r.response["header"]["last-modified"]
@@ -62,8 +62,8 @@ class TestStore:
def test_h2_201_04(self, env):
url = env.mkurl("https", "test1", "/006.html")
r = env.curl_get(url, options=["--http1.1", "-H", "Connection: keep-alive"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "timeout=30, max=30" == r.response["header"]["keep-alive"]
r = env.curl_get(url, options=["-H", "Connection: keep-alive"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "keep-alive" not in r.response["header"]
Modified: httpd/httpd/trunk/test/modules/http2/test_300_interim.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_300_interim.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_300_interim.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_300_interim.py Thu Oct 28 12:50:02 2021
@@ -20,14 +20,14 @@ class TestStore:
def test_h2_300_01(self, env):
url = env.mkurl("https", "test1", "/index.html")
r = env.curl_post_data(url, 'XYZ')
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "previous" not in r.response
# check that we see an interim response when we ask for it
def test_h2_300_02(self, env):
url = env.mkurl("https", "cgi", "/echo.py")
r = env.curl_post_data(url, 'XYZ', options=["-H", "expect: 100-continue"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "previous" in r.response
assert 100 == r.response["previous"]["status"]
Modified: httpd/httpd/trunk/test/modules/http2/test_400_push.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_400_push.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_400_push.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_400_push.py Thu Oct 28 12:50:02 2021
@@ -9,9 +9,9 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- H2Conf(env).start_vhost(
- env.https_port, "push", doc_root="htdocs/test1", with_ssl=True
- ).add(r""" Protocols h2 http/1.1"
+ H2Conf(env).start_vhost(domains=[f"push.{env.http_tld}"],
+ port=env.https_port, doc_root="htdocs/test1"
+ ).add(r"""
RewriteEngine on
RewriteRule ^/006-push(.*)?\.html$ /006.html
<Location /006-push.html>
@@ -64,7 +64,7 @@ class TestStore:
def test_h2_400_00(self, env):
url = env.mkurl("https", "push", "/006.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
@@ -72,7 +72,7 @@ class TestStore:
def test_h2_400_01(self, env):
url = env.mkurl("https", "push", "/006-push.html")
r = env.nghttp().get(url, options=["-Haccept-encoding: none"])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.css' == promises[0]["request"]["header"][":path"]
@@ -82,7 +82,7 @@ class TestStore:
def test_h2_400_02(self, env):
url = env.mkurl("https", "push", "/006-push2.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.js' == promises[0]["request"]["header"][":path"]
@@ -91,7 +91,7 @@ class TestStore:
def test_h2_400_03(self, env):
url = env.mkurl("https", "push", "/006-push3.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.js' == promises[0]["request"]["header"][":path"]
@@ -100,7 +100,7 @@ class TestStore:
def test_h2_400_04(self, env):
url = env.mkurl("https", "push", "/006-push4.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
@@ -108,7 +108,7 @@ class TestStore:
def test_h2_400_05(self, env):
url = env.mkurl("https", "push", "/006-push5.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.css' == promises[0]["request"]["header"][":path"]
@@ -117,7 +117,7 @@ class TestStore:
def test_h2_400_06(self, env):
url = env.mkurl("https", "push", "/006-push6.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.css' == promises[0]["request"]["header"][":path"]
@@ -126,7 +126,7 @@ class TestStore:
def test_h2_400_07(self, env):
url = env.mkurl("https", "push", "/006-push7.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.css' == promises[0]["request"]["header"][":path"]
@@ -135,15 +135,15 @@ class TestStore:
def test_h2_400_08(self, env):
url = env.mkurl("https", "push", "/006-push8.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
# 2 H2PushResource config trigger on GET, but not on POST
- def test_h2_400_20(self, env, repeat):
+ def test_h2_400_20(self, env):
url = env.mkurl("https", "push", "/006-push20.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 2 == len(promises)
@@ -151,7 +151,7 @@ class TestStore:
with open(fpath, 'w') as f:
f.write("test upload data")
r = env.nghttp().upload(url, fpath)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
@@ -159,7 +159,7 @@ class TestStore:
def test_h2_400_30(self, env):
url = env.mkurl("https", "push", "/006-push30.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
@@ -167,7 +167,7 @@ class TestStore:
def test_h2_400_50(self, env):
url = env.mkurl("https", "push", "/006-push.html")
r = env.nghttp().get(url, options=['-H', 'accept-push-policy: none'])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 0 == len(promises)
@@ -175,7 +175,7 @@ class TestStore:
def test_h2_400_51(self, env):
url = env.mkurl("https", "push", "/006-push.html")
r = env.nghttp().get(url, options=['-H', 'accept-push-policy: default'])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
@@ -183,7 +183,7 @@ class TestStore:
def test_h2_400_52(self, env):
url = env.mkurl("https", "push", "/006-push.html")
r = env.nghttp().get(url, options=['-H', 'accept-push-policy: head'])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert '/006/006.css' == promises[0]["request"]["header"][":path"]
@@ -194,6 +194,6 @@ class TestStore:
def test_h2_400_53(self, env):
url = env.mkurl("https", "push", "/006-push.html")
r = env.nghttp().get(url, options=['-H', 'accept-push-policy: fast-load'])
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
Modified: httpd/httpd/trunk/test/modules/http2/test_401_early_hints.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_401_early_hints.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_401_early_hints.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_401_early_hints.py Thu Oct 28 12:50:02 2021
@@ -8,9 +8,9 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- H2Conf(env).start_vhost(
- env.https_port, "hints", doc_root="htdocs/test1", with_ssl=True
- ).add(""" Protocols h2 http/1.1"
+ H2Conf(env).start_vhost(domains=[f"hints.{env.http_tld}"],
+ port=env.https_port, doc_root="htdocs/test1"
+ ).add("""
H2EarlyHints on
RewriteEngine on
RewriteRule ^/006-(.*)?\\.html$ /006.html
@@ -25,10 +25,10 @@ class TestStore:
assert env.apache_restart() == 0
# H2EarlyHints enabled in general, check that it works for H2PushResource
- def test_h2_401_31(self, env, repeat):
+ def test_h2_401_31(self, env):
url = env.mkurl("https", "hints", "/006-hints.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
early = r.response["previous"]
@@ -40,7 +40,7 @@ class TestStore:
def test_h2_401_32(self, env):
url = env.mkurl("https", "hints", "/006-nohints.html")
r = env.nghttp().get(url)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
promises = r.results["streams"][r.response["id"]]["promises"]
assert 1 == len(promises)
assert "previous" not in r.response
Modified: httpd/httpd/trunk/test/modules/http2/test_500_proxy.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_500_proxy.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_500_proxy.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_500_proxy.py Thu Oct 28 12:50:02 2021
@@ -22,7 +22,7 @@ class TestStore:
def test_h2_500_01(self, env):
url = env.mkurl("https", "cgi", "/proxy/hello.py")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/1.1" == r.response["json"]["protocol"]
assert "" == r.response["json"]["https"]
assert "" == r.response["json"]["ssl_protocol"]
Modified: httpd/httpd/trunk/test/modules/http2/test_501_proxy_serverheader.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/modules/http2/test_501_proxy_serverheader.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/modules/http2/test_501_proxy_serverheader.py (original)
+++ httpd/httpd/trunk/test/modules/http2/test_501_proxy_serverheader.py Thu Oct 28 12:50:02 2021
@@ -7,13 +7,13 @@ class TestStore:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
- conf = H2Conf(env)
- conf.add_vhost_cgi(proxy_self=True, h2proxy_self=False, extras={
- f'cgi.{env.http_tld}': f"""
- Header unset Server
- Header always set Server cgi
- """
+ conf = H2Conf(env, extras={
+ f'cgi.{env.http_tld}': [
+ "Header unset Server",
+ "Header always set Server cgi",
+ ]
})
+ conf.add_vhost_cgi(proxy_self=True, h2proxy_self=False)
conf.install()
assert env.apache_restart() == 0
@@ -26,7 +26,7 @@ class TestStore:
def test_h2_501_01(self, env):
url = env.mkurl("https", "cgi", "/proxy/hello.py")
r = env.curl_get(url, 5)
- assert 200 == r.response["status"]
+ assert r.response["status"] == 200
assert "HTTP/1.1" == r.response["json"]["protocol"]
assert "" == r.response["json"]["https"]
assert "" == r.response["json"]["ssl_protocol"]
Modified: httpd/httpd/trunk/test/pyhttpd/conf.py
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/pyhttpd/conf.py?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/pyhttpd/conf.py (original)
+++ httpd/httpd/trunk/test/pyhttpd/conf.py Thu Oct 28 12:50:02 2021
@@ -1,151 +1,178 @@
+from typing import Dict, Any
+
from pyhttpd.env import HttpdTestEnv
class HttpdConf(object):
- def __init__(self, env: HttpdTestEnv, path=None):
+ def __init__(self, env: HttpdTestEnv, extras: Dict[str, Any] = None):
+ """ Create a new httpd configuration.
+ :param env: then environment this operates in
+ :param extras: extra configuration directive with ServerName as key and
+ 'base' as special key for global configuration additions.
+ """
self.env = env
+ self._indents = 0
self._lines = []
- self._has_ssl_vhost = False
+ self._extras = extras.copy() if extras else {}
+ if 'base' in self._extras:
+ self.add(self._extras['base'])
+
+ def __repr__(self):
+ s = '\n'.join(self._lines)
+ return f"HttpdConf[{s}]"
def install(self):
- if not self._has_ssl_vhost:
- self.add_vhost_test1()
self.env.install_test_conf(self._lines)
- def add(self, line):
- if isinstance(line, list):
- self._lines.extend(line)
- else:
+ def add(self, line: Any):
+ if isinstance(line, str):
+ if self._indents > 0:
+ line = f"{' ' * self._indents}{line}"
self._lines.append(line)
+ else:
+ if self._indents > 0:
+ line = [f"{' ' * self._indents}{l}" for l in line]
+ self._lines.extend(line)
return self
- def add_vhost(self, port, name, aliases=None, doc_root="htdocs", with_ssl=True):
- self.start_vhost(port, name, aliases, doc_root, with_ssl)
+ def add_certificate(self, cert_file, key_file):
+ if self.env.ssl_module == "ssl":
+ self.add([
+ f"SSLCertificateFile {cert_file}",
+ f"SSLCertificateKeyFile {key_file}",
+ ])
+ elif self.env.ssl_module == "tls":
+ self.add(f"""
+ TLSCertificate {cert_file} {key_file}
+ """)
+
+ def add_vhost(self, domains, port=None, doc_root="htdocs", with_ssl=True):
+ self.start_vhost(domains=domains, port=port, doc_root=doc_root, with_ssl=with_ssl)
self.end_vhost()
return self
- def start_vhost(self, port, name, aliases=None, doc_root="htdocs", with_ssl=True):
- server_domain = f"{name}.{self.env.http_tld}"
- lines = [
- f"<VirtualHost *:{port}>",
- f" ServerName {server_domain}"
- ]
- if aliases:
- lines.extend([
- f" ServerAlias {alias}.{self.env.http_tld}" for alias in aliases])
- lines.append(f" DocumentRoot {doc_root}")
- if with_ssl:
- self._has_ssl_vhost = True
- lines.append(" SSLEngine on")
- for cred in self.env.get_credentials_for_name(server_domain):
- lines.extend([
- f"SSLCertificateFile {cred.cert_file}",
- f"SSLCertificateKeyFile {cred.pkey_file}",
- ])
- return self.add(lines)
+ def start_vhost(self, domains, port=None, doc_root="htdocs", with_ssl=False):
+ if not isinstance(domains, list):
+ domains = [domains]
+ if port is None:
+ port = self.env.https_port
+ self.add("")
+ self.add(f"<VirtualHost *:{port}>")
+ self._indents += 1
+ self.add(f"ServerName {domains[0]}")
+ for alias in domains[1:]:
+ self.add(f"ServerAlias {alias}")
+ self.add(f"DocumentRoot {doc_root}")
+ if self.env.https_port == port or with_ssl:
+ if self.env.ssl_module == "ssl":
+ self.add("SSLEngine on")
+ for cred in self.env.get_credentials_for_name(domains[0]):
+ self.add_certificate(cred.cert_file, cred.pkey_file)
+ if domains[0] in self._extras:
+ self.add(self._extras[domains[0]])
+ return self
def end_vhost(self):
+ self._indents -= 1
self.add("</VirtualHost>")
+ self.add("")
return self
def add_proxies(self, host, proxy_self=False, h2proxy_self=False):
if proxy_self or h2proxy_self:
- self.add(" ProxyPreserveHost on")
+ self.add("ProxyPreserveHost on")
if proxy_self:
- self.add(f"""
- ProxyPass /proxy/ http://127.0.0.1:{self.env.http_port}/
- ProxyPassReverse /proxy/ http://{host}.{self.env.http_tld}:{self.env.http_port}/
- """)
+ self.add([
+ f"ProxyPass /proxy/ http://127.0.0.1:{self.env.http_port}/",
+ f"ProxyPassReverse /proxy/ http://{host}.{self.env.http_tld}:{self.env.http_port}/",
+ ])
if h2proxy_self:
- self.add(f"""
- ProxyPass /h2proxy/ h2://127.0.0.1:{self.env.https_port}/
- ProxyPassReverse /h2proxy/ https://{host}.{self.env.http_tld}:self.env.https_port/
- """)
+ self.add([
+ f"ProxyPass /h2proxy/ h2://127.0.0.1:{self.env.https_port}/",
+ f"ProxyPassReverse /h2proxy/ https://{host}.{self.env.http_tld}:self.env.https_port/",
+ ])
return self
- def add_proxy_setup(self):
- self.add("ProxyStatus on")
- self.add("ProxyTimeout 5")
- self.add("SSLProxyEngine on")
- self.add("SSLProxyVerify none")
- return self
-
- def add_vhost_test1(self, proxy_self=False, h2proxy_self=False, extras=None):
+ def add_vhost_test1(self, proxy_self=False, h2proxy_self=False):
domain = f"test1.{self.env.http_tld}"
- if extras and 'base' in extras:
- self.add(extras['base'])
- self.start_vhost(
- self.env.http_port, "test1", aliases=["www1"], doc_root="htdocs/test1", with_ssl=False
- ).add(
- " Protocols h2c http/1.1"
- ).end_vhost()
- self.start_vhost(
- self.env.https_port, "test1", aliases=["www1"], doc_root="htdocs/test1", with_ssl=True)
- self.add(f"""
- Protocols h2 http/1.1
- <Location /006>
- Options +Indexes
- HeaderName /006/header.html
- </Location>
- {extras[domain] if extras and domain in extras else ""}
- """)
+ self.start_vhost(domains=[domain, f"www1.{self.env.http_tld}"],
+ port=self.env.http_port, doc_root="htdocs/test1")
+ self.end_vhost()
+ self.start_vhost(domains=[domain, f"www1.{self.env.http_tld}"],
+ port=self.env.https_port, doc_root="htdocs/test1")
+ self.add([
+ "<Location /006>",
+ " Options +Indexes",
+ " HeaderName /006/header.html",
+ "</Location>",
+ ])
self.add_proxies("test1", proxy_self, h2proxy_self)
self.end_vhost()
return self
- def add_vhost_test2(self, extras=None):
+ def add_vhost_test2(self):
domain = f"test2.{self.env.http_tld}"
- if extras and 'base' in extras:
- self.add(extras['base'])
- self.start_vhost(self.env.http_port, "test2", aliases=["www2"], doc_root="htdocs/test2", with_ssl=False)
- self.add(" Protocols http/1.1 h2c")
- self.end_vhost()
- self.start_vhost(self.env.https_port, "test2", aliases=["www2"], doc_root="htdocs/test2", with_ssl=True)
- self.add(f"""
- Protocols http/1.1 h2
- <Location /006>
- Options +Indexes
- HeaderName /006/header.html
- </Location>
- {extras[domain] if extras and domain in extras else ""}
- """)
+ self.start_vhost(domains=[domain, f"www2.{self.env.http_tld}"],
+ port=self.env.http_port, doc_root="htdocs/test2")
+ self.end_vhost()
+ self.start_vhost(domains=[domain, f"www2.{self.env.http_tld}"],
+ port=self.env.https_port, doc_root="htdocs/test2")
+ self.add([
+ "<Location /006>",
+ " Options +Indexes",
+ " HeaderName /006/header.html",
+ "</Location>",
+ ])
self.end_vhost()
return self
- def add_vhost_cgi(self, proxy_self=False, h2proxy_self=False, extras=None):
+ def add_vhost_cgi(self, proxy_self=False, h2proxy_self=False):
domain = f"cgi.{self.env.http_tld}"
- if extras and 'base' in extras:
- self.add(extras['base'])
if proxy_self:
- self.add_proxy_setup()
+ self.add(["ProxyStatus on", "ProxyTimeout 5",
+ "SSLProxyEngine on", "SSLProxyVerify none"])
if h2proxy_self:
- self.add(" SSLProxyEngine on")
- self.add(" SSLProxyCheckPeerName off")
- self.start_vhost(self.env.https_port, "cgi", aliases=["cgi-alias"], doc_root="htdocs/cgi", with_ssl=True)
- self.add("""
- Protocols h2 http/1.1
- SSLOptions +StdEnvVars
- AddHandler cgi-script .py
- <Location \"/.well-known/h2/state\">
- SetHandler http2-status
- </Location>""")
+ self.add(["SSLProxyEngine on", "SSLProxyCheckPeerName off"])
+ self.start_vhost(domains=[domain, f"cgi-alias.{self.env.http_tld}"],
+ port=self.env.https_port, doc_root="htdocs/cgi")
self.add_proxies("cgi", proxy_self=proxy_self, h2proxy_self=h2proxy_self)
- self.add(" <Location \"/h2test/echo\">")
- self.add(" SetHandler h2test-echo")
- self.add(" </Location>")
- self.add(" <Location \"/h2test/delay\">")
- self.add(" SetHandler h2test-delay")
- self.add(" </Location>")
- if extras and domain in extras:
- self.add(extras[domain])
- self.end_vhost()
- self.start_vhost(self.env.http_port, "cgi", aliases=["cgi-alias"], doc_root="htdocs/cgi", with_ssl=False)
- self.add(" AddHandler cgi-script .py")
+ self.add("<Location \"/h2test/echo\">")
+ self.add(" SetHandler h2test-echo")
+ self.add("</Location>")
+ self.add("<Location \"/h2test/delay\">")
+ self.add(" SetHandler h2test-delay")
+ self.add("</Location>")
+ if domain in self._extras:
+ self.add(self._extras[domain])
+ self.end_vhost()
+ self.start_vhost(domains=[domain, f"cgi-alias.{self.env.http_tld}"],
+ port=self.env.http_port, doc_root="htdocs/cgi")
+ self.add("AddHandler cgi-script .py")
self.add_proxies("cgi", proxy_self=proxy_self, h2proxy_self=h2proxy_self)
- if extras and domain in extras:
- self.add(extras[domain])
self.end_vhost()
- self.add(" LogLevel proxy:info")
- self.add(" LogLevel proxy_http:info")
+ self.add("LogLevel proxy:info")
+ self.add("LogLevel proxy_http:info")
return self
+
+ @staticmethod
+ def merge_extras(e1: Dict[str, Any], e2: Dict[str, Any]) -> Dict[str, Any]:
+ def _concat(v1, v2):
+ if isinstance(v1, str):
+ v1 = [v1]
+ if isinstance(v2, str):
+ v2 = [v2]
+ v1.extend(v2)
+ return v1
+
+ if e1 is None:
+ return e2.copy() if e2 else None
+ if e2 is None:
+ return e1.copy()
+ e3 = e1.copy()
+ for name, val in e2.items():
+ if name in e3:
+ e3[name] = _concat(e3[name], val)
+ else:
+ e3[name] = val
+ return e3
Modified: httpd/httpd/trunk/test/pyhttpd/conf/httpd.conf.template
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/pyhttpd/conf/httpd.conf.template?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/pyhttpd/conf/httpd.conf.template (original)
+++ httpd/httpd/trunk/test/pyhttpd/conf/httpd.conf.template Thu Oct 28 12:50:02 2021
@@ -17,6 +17,11 @@ TypesConfig "${gen_dir}/apache/conf/mime
Listen ${http_port}
Listen ${https_port}
+<IfModule mod_ssl.c>
+ # provide some default
+ SSLSessionCache "shmcb:ssl_gcache_data(32000)"
+</IfModule>
+
# Insert our test specific configuration before the first vhost,
# so that its vhosts can be the default one. This is relevant in
# certain behaviours, such as protocol selection during SSL ALPN
@@ -34,9 +39,11 @@ RequestReadTimeout header=10 body=10
</IfModule>
<VirtualHost *:${http_port}>
- ServerName not-forbidden.org
- ServerAlias www.not-forbidden.org
-
+ ServerName ${http_tld}
+ ServerAlias www.${http_tld}
+ <IfModule ssl_module>
+ SSLEngine off
+ </IfModule>
DocumentRoot "${server_dir}/htdocs"
</VirtualHost>
Modified: httpd/httpd/trunk/test/pyhttpd/config.ini.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/pyhttpd/config.ini.in?rev=1894599&r1=1894598&r2=1894599&view=diff
==============================================================================
--- httpd/httpd/trunk/test/pyhttpd/config.ini.in (original)
+++ httpd/httpd/trunk/test/pyhttpd/config.ini.in Thu Oct 28 12:50:02 2021
@@ -13,16 +13,18 @@ libexecdir = @libexecdir@
apr_bindir = @APR_BINDIR@
apxs = @bindir@/apxs
apachectl = @sbindir@/apachectl
-dso_modules = @DSO_MODULES@
[httpd]
version = @HTTPD_VERSION@
name = @progname@
+dso_modules = @DSO_MODULES@
+static_modules = @STATIC_MODULES@
[test]
-http_port = 40001
-https_port = 40002
-http_tld = tests.httpd.apache.org
-test_dir = @abs_srcdir@/..
-server_dir = @abs_srcdir@/../gen/apache
gen_dir = @abs_srcdir@/../gen
+http_port = 5002
+https_port = 5001
+proxy_port = 5003
+http_tld = tests.httpd.apache.org
+test_dir = @abs_srcdir@
+test_src_dir = @abs_srcdir@