From: Stefan Eissing Date: Thu, 18 Apr 2024 10:18:14 +0000 (+0200) Subject: tests: check caddy server version to match test expectations X-Git-Tag: curl-8_8_0~192 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e16c97fe9ee92ba06f6cf4581644a31c242c155;p=thirdparty%2Fcurl.git tests: check caddy server version to match test expectations - new caddy servers no longer return 200 on POSTs, but 405 as they should Closes #13405 --- diff --git a/tests/http/test_08_caddy.py b/tests/http/test_08_caddy.py index c35bd27b76..6b8fce8fef 100644 --- a/tests/http/test_08_caddy.py +++ b/tests/http/test_08_caddy.py @@ -179,4 +179,5 @@ class TestCaddy: url = f'https://{env.domain1}:{caddy.port}/data10.data?[0-{count-1}]' r = curl.http_upload(urls=[url], data=data, alpn_proto=proto, extra_args=['--parallel']) - r.check_stats(count=count, http_status=200, exitcode=0) + exp_status = 405 if env.caddy_is_at_least('2.7.0') else 200 + r.check_stats(count=count, http_status=exp_status, exitcode=0) diff --git a/tests/http/testenv/env.py b/tests/http/testenv/env.py index e8c5872daf..ef240bc5c7 100644 --- a/tests/http/testenv/env.py +++ b/tests/http/testenv/env.py @@ -168,7 +168,11 @@ class EnvConfig: if p.returncode != 0: # not a working caddy self.caddy = None - self._caddy_version = re.sub(r' .*', '', p.stdout.strip()) + m = re.match(r'v?(\d+\.\d+\.\d+) .*', p.stdout) + if m: + self._caddy_version = m.group(1) + else: + raise f'Unable to determine cadd version from: {p.stdout}' except: self.caddy = None @@ -196,6 +200,12 @@ class EnvConfig: hv = self.versiontuple(self.httpd_version) return hv >= self.versiontuple(minv) + def caddy_is_at_least(self, minv): + if self.caddy_version is None: + return False + hv = self.versiontuple(self.caddy_version) + return hv >= self.versiontuple(minv) + def is_complete(self) -> bool: return os.path.isfile(self.httpd) and \ os.path.isfile(self.apachectl) and \ @@ -318,6 +328,10 @@ class Env: def caddy_version() -> str: return Env.CONFIG.caddy_version + @staticmethod + def caddy_is_at_least(minv) -> bool: + return Env.CONFIG.caddy_is_at_least(minv) + @staticmethod def httpd_is_at_least(minv) -> bool: return Env.CONFIG.httpd_is_at_least(minv)