]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: make precheck for HTTP on 127.0.0.1 into a feature
authorDaniel Stenberg <daniel@haxx.se>
Wed, 25 Sep 2024 11:53:17 +0000 (13:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Sep 2024 06:44:45 +0000 (08:44 +0200)
It can now be required easily in <features> instead of having perl code
in a <precheck>.

Closes #15039

25 files changed:
tests/FILEFORMAT.md
tests/data/test1105
tests/data/test2033
tests/data/test2034
tests/data/test2035
tests/data/test2037
tests/data/test2038
tests/data/test2041
tests/data/test2042
tests/data/test2070
tests/data/test2079
tests/data/test2087
tests/data/test3000
tests/data/test3001
tests/data/test3023
tests/data/test3024
tests/data/test31
tests/data/test310
tests/data/test311
tests/data/test312
tests/data/test313
tests/data/test389
tests/data/test392
tests/runtests.pl
tests/servers.pm

index 7ab1583057d222a5b7b7a2d06d603034b803dab6..1bb56cf4ab940e71b451104124ee0bf2da296673 100644 (file)
@@ -456,6 +456,7 @@ Features testable here are:
 - `libssh`
 - `oldlibssh` (versions before 0.9.4)
 - `libz`
+- `local-http`. The HTTP server runs on 127.0.0.1
 - `manual`
 - `mbedtls`
 - `Mime`
index afe621bb0d10cd664ef543bdacb2f2bc3a2db3db..68922dc770ca2da9d98b10055b720cdbf859f124 100644 (file)
@@ -37,11 +37,9 @@ HTTP with cookie parser and header recording
 <command>
 "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER?parm1=this*that/other/thing&parm2=foobar/%TESTNUMBER" -c %LOGDIR/cookie%TESTNUMBER.txt -d "userid=myname&password=mypassword"
 </command>
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 <features>
 cookies
+local-http
 </features>
 </client>
 
index c23d8d0c3b4a32fbd0f40bd222c411cb04ff7057..6aa5e50f036d12ead1c620419719983e72fa4906 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.der --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 5192cb73ea157f05f6434791e90875b23490cbd0..82b205555f39cba1010de4a1c0552e1047c828e0 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -37,10 +38,6 @@ simple HTTPS GET with DER public key pinning
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.der https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index b17cddd567cb303ef59fff660cf68b927049f17a..9680a3634676d0d4c85fb201e9b01413d446790b 100644 (file)
@@ -18,6 +18,7 @@ PEM certificate
 <features>
 SSL
 SSLpinning
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -28,10 +29,6 @@ HTTPS wrong DER pinnedpubkey but right CN
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.der https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 96406410aa227223a2d878990ff62ed42d2dcf55..f55e6b11c441ba2413b4675743c7bc6acbc0ff0f 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -37,10 +38,6 @@ simple HTTPS GET with PEM public key pinning
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.pem https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 6cd91d623118c990fdce076e6ff4fadad0811e7a..36d399fa621e0024e99409aa7e06f7b05dcaecf7 100644 (file)
@@ -18,6 +18,7 @@ PEM certificate
 <features>
 SSL
 SSLpinning
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -28,10 +29,6 @@ HTTPS wrong PEM pinnedpubkey but right CN
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pem https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index f7d06006456653e8256da85851bd8ca971d56997..0b6fa9a18fb5b23923732c0219b6b70e5533ee16 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -37,10 +38,6 @@ simple HTTPS GET with base64-sha256 public key pinning
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey sha256//%sha256b64file[%SRCDIR/certs/Server-localhost-sv.pub.der]sha256b64file% https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 594a7e460af2ea1c94e3653ea0bb38bdf2d25416..f4cf340fdb76d124e11dc1b8ab8944f6e46115e4 100644 (file)
@@ -18,6 +18,7 @@ PEM certificate
 <features>
 SSL
 SSLpinning
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -28,10 +29,6 @@ HTTPS wrong base64-sha256 pinnedpubkey but right CN
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey sha256//bSIggTf+ikMG0CtmDlpMVBd7yi7H1md4URogRPqerso= https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 678f3f210f40bcc27d985b48559151218d5622c4..abb22fc3258cc5b89c5b490f1d3a7aa6abebe5ad 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index da531902a1d9402119922c5086cc5b4876b614c6..13e4fe1dd7dc120ebf03636adf282b83cdb6730a 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.pem --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 61de80a5e6e57a99c5d812344ad7da940b1f8d68..8084e78ad427a2921ec5ee6a07f92e350e786cd8 100644 (file)
@@ -27,6 +27,7 @@ MooMoo
 SSL
 SSLpinning
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey sha256//%sha256b64file[%SRCDIR/certs/Server-localhost-sv.pub.der]sha256b64file% --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 05f4a010edd149cccc8cf63a906a5866c1fa21b9..6e7f7db4f62918607c338008886a5f950b530def 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-firstSAN-sv.pem
@@ -36,10 +37,6 @@ HTTPS GET to localhost, first subject alt name matches, CN does not match
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 3a954324be83494f4ec218b40822681542af5513..2d8817f0d0c3d43718fd4b13455bac140f0373dc 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-lastSAN-sv.pem
@@ -36,10 +37,6 @@ HTTPS GET to localhost, last subject alt name matches, CN does not match
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 258f34eb0f54c324ad0a90e3feb2b06dfae58277..a5bba7683dd232ba883de906db13a2a1d95ba794 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-firstSAN-sv.pem
@@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 57c12734847e1ab18a7132718a0b78be87ea3ca2..af1549c62b9a3d0d427e1f3fdead078c37080840 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 Schannel
+local-http
 </features>
 <server>
 https Server-localhost-lastSAN-sv.pem
@@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 3ceaad0f94d791f0d5813970f6b449c68943cda2..d9d073996bef25ab162c673c85cf3c3d0806396d 100644 (file)
@@ -144,11 +144,9 @@ TZ=GMT
 <command>
 http://test31.curl:%HTTPPORT/we/want/%TESTNUMBER -b none -c %LOGDIR/jar%TESTNUMBER.txt --resolve test31.curl:%HTTPPORT:127.0.0.1
 </command>
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 <features>
 cookies
+local-http
 </features>
 </client>
 
index b9f1850ead86341e233e309ff17db8df6f4a3e06..f7427981cc3b0bd8d709e0137d5b81501f22f352 100644 (file)
@@ -26,6 +26,7 @@ MooMoo
 <features>
 SSL
 !Schannel
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -36,10 +37,6 @@ simple HTTPS GET
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index a3f9ed0e27228472ef0efba4fdc37c1bfb4f8b1f..e16341274147e8ac7e0d4c28497ddd9a9a29f3c4 100644 (file)
@@ -17,6 +17,7 @@ PEM certificate
 <client>
 <features>
 SSL
+local-http
 </features>
 <server>
 https Server-localhost0h-sv.pem
@@ -27,10 +28,6 @@ HTTPS wrong subjectAltName but right CN
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index c8c46b82146a54a755041ddb1b0f7d0168de412b..5466c3eaab414e5a93778204d34e8ba6cec9bebe 100644 (file)
@@ -17,6 +17,7 @@ PEM certificate
 <client>
 <features>
 SSL
+local-http
 </features>
 <server>
 https Server-localhost.nn-sv.pem
@@ -27,10 +28,6 @@ HTTPS GET to localhost and null-prefixed CN cert
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 12f91f96598522dc5b5d3b9adf142f0b645ccd48..3d31dc6808887b86a77728f24332c035511b95fb 100644 (file)
@@ -13,6 +13,7 @@ CRL
 <client>
 <features>
 SSL
+local-http
 </features>
 <server>
 https Server-localhost-sv.pem
@@ -23,10 +24,6 @@ CRL test
 <command>
 --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --crlfile %SRCDIR/certs/Server-localhost-sv.crl https://localhost:%HTTPSPORT/%TESTNUMBER
 </command>
-# Ensure that we're running on localhost because we're checking the host name
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index fcb29f5b8c446fb8fefd29e6b88954856edbfee7..2dc0731b8e75f58d196472b8622eb3ab1bf75e51 100644 (file)
@@ -31,6 +31,9 @@ Funny-head: yesyes
 <server>
 http
 </server>
+<features>
+local-http
+</features>
 <name>
 *.localhost is a local host
 </name>
@@ -38,9 +41,6 @@ http
 http://curlmachine.localhost:%HTTPPORT/%TESTNUMBER
 </command>
 # Ensure that we're running on localhost
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 </client>
 
 #
index 5c1076c82bbbea0003b942015744dac7fc8f15cd..d24841c6168d0861871c5b708bdb19c67cc03fcd 100644 (file)
@@ -37,11 +37,9 @@ TZ=GMT
 <command>
 http://localhost:%HTTPPORT/%TESTNUMBER -b none http://localhost:%HTTPPORT/%TESTNUMBER
 </command>
-<precheck>
-perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
-</precheck>
 <features>
 cookies
+local-http
 </features>
 </client>
 
index d906a2757e74d42e60ec695f651fb62836ead078..4764ba31aabe0f1a6a0f47ce2dc5b10ce55cca46 100755 (executable)
@@ -824,6 +824,7 @@ sub checksystemfeatures {
     $feature{"xattr"} = 1;
     $feature{"large-time"} = 1;
     $feature{"sha512-256"} = 1;
+    $feature{"local-http"} = servers::localhttp();
 
     # make each protocol an enabled "feature"
     for my $p (@protocols) {
index 88ec10b4845724c5f53ac85aa5680bdf9495bf2f..86119c088c6d0d0172d7a3cfd78f1754a7d706f4 100644 (file)
@@ -59,6 +59,7 @@ BEGIN {
             stopserver
             stopservers
             subvariables
+            localhttp
         ),
 
         # for debugging only
@@ -3040,5 +3041,8 @@ sub subvariables {
     $$thing =~ s/${prefix}H2CVER/$h2cver/g;
 }
 
+sub localhttp {
+    return $HOSTIP eq "127.0.0.1";
+}
 
 1;