]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: check caddy server version to match test expectations
authorStefan Eissing <stefan@eissing.org>
Thu, 18 Apr 2024 10:18:14 +0000 (12:18 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 18 Apr 2024 14:10:42 +0000 (16:10 +0200)
- new caddy servers no longer return 200 on POSTs, but 405
  as they should

Closes #13405

tests/http/test_08_caddy.py
tests/http/testenv/env.py

index c35bd27b76a145f30d1528c6391b6d99085e56e9..6b8fce8fef24fe6edaef7a2e46cbb5844923ab0e 100644 (file)
@@ -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)
index e8c5872daf0799f8addbe5cf1d2d83a1fc864112..ef240bc5c7a8a70ad9e9f0d1eab8fbd80be72203 100644 (file)
@@ -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)