From 7aa2b4e01f5cc602fb9a58a9649ab242043013f6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 25 Sep 2024 13:53:17 +0200 Subject: [PATCH] tests: make precheck for HTTP on 127.0.0.1 into a feature It can now be required easily in instead of having perl code in a . Closes #15039 --- tests/FILEFORMAT.md | 1 + tests/data/test1105 | 4 +--- tests/data/test2033 | 5 +---- tests/data/test2034 | 5 +---- tests/data/test2035 | 5 +---- tests/data/test2037 | 5 +---- tests/data/test2038 | 5 +---- tests/data/test2041 | 5 +---- tests/data/test2042 | 5 +---- tests/data/test2070 | 5 +---- tests/data/test2079 | 5 +---- tests/data/test2087 | 5 +---- tests/data/test3000 | 5 +---- tests/data/test3001 | 5 +---- tests/data/test3023 | 5 +---- tests/data/test3024 | 5 +---- tests/data/test31 | 4 +--- tests/data/test310 | 5 +---- tests/data/test311 | 5 +---- tests/data/test312 | 5 +---- tests/data/test313 | 5 +---- tests/data/test389 | 6 +++--- tests/data/test392 | 4 +--- tests/runtests.pl | 1 + tests/servers.pm | 4 ++++ 25 files changed, 30 insertions(+), 84 deletions(-) diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 7ab1583057..1bb56cf4ab 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -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` diff --git a/tests/data/test1105 b/tests/data/test1105 index afe621bb0d..68922dc770 100644 --- a/tests/data/test1105 +++ b/tests/data/test1105 @@ -37,11 +37,9 @@ HTTP with cookie parser and header recording "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER?parm1=this*that/other/thing&parm2=foobar/%TESTNUMBER" -c %LOGDIR/cookie%TESTNUMBER.txt -d "userid=myname&password=mypassword" - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - cookies +local-http diff --git a/tests/data/test2033 b/tests/data/test2033 index c23d8d0c3b..6aa5e50f03 100644 --- a/tests/data/test2033 +++ b/tests/data/test2033 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning Schannel +local-http https Server-localhost-sv.pem @@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.der --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2034 b/tests/data/test2034 index 5192cb73ea..82b205555f 100644 --- a/tests/data/test2034 +++ b/tests/data/test2034 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning !Schannel +local-http https Server-localhost-sv.pem @@ -37,10 +38,6 @@ simple HTTPS GET with DER public key pinning --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.der https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2035 b/tests/data/test2035 index b17cddd567..9680a36346 100644 --- a/tests/data/test2035 +++ b/tests/data/test2035 @@ -18,6 +18,7 @@ PEM certificate SSL SSLpinning +local-http https Server-localhost-sv.pem @@ -28,10 +29,6 @@ HTTPS wrong DER pinnedpubkey but right CN --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.der https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2037 b/tests/data/test2037 index 96406410aa..f55e6b11c4 100644 --- a/tests/data/test2037 +++ b/tests/data/test2037 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning !Schannel +local-http https Server-localhost-sv.pem @@ -37,10 +38,6 @@ simple HTTPS GET with PEM public key pinning --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.pem https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2038 b/tests/data/test2038 index 6cd91d6231..36d399fa62 100644 --- a/tests/data/test2038 +++ b/tests/data/test2038 @@ -18,6 +18,7 @@ PEM certificate SSL SSLpinning +local-http https Server-localhost-sv.pem @@ -28,10 +29,6 @@ HTTPS wrong PEM pinnedpubkey but right CN --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pem https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2041 b/tests/data/test2041 index f7d0600645..0b6fa9a18f 100644 --- a/tests/data/test2041 +++ b/tests/data/test2041 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning !Schannel +local-http https Server-localhost-sv.pem @@ -37,10 +38,6 @@ simple HTTPS GET with base64-sha256 public key pinning --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey sha256//%sha256b64file[%SRCDIR/certs/Server-localhost-sv.pub.der]sha256b64file% https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2042 b/tests/data/test2042 index 594a7e460a..f4cf340fdb 100644 --- a/tests/data/test2042 +++ b/tests/data/test2042 @@ -18,6 +18,7 @@ PEM certificate SSL SSLpinning +local-http https Server-localhost-sv.pem @@ -28,10 +29,6 @@ HTTPS wrong base64-sha256 pinnedpubkey but right CN --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey sha256//bSIggTf+ikMG0CtmDlpMVBd7yi7H1md4URogRPqerso= https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2070 b/tests/data/test2070 index 678f3f210f..abb22fc325 100644 --- a/tests/data/test2070 +++ b/tests/data/test2070 @@ -26,6 +26,7 @@ MooMoo SSL Schannel +local-http https Server-localhost-sv.pem @@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2079 b/tests/data/test2079 index da531902a1..13e4fe1dd7 100644 --- a/tests/data/test2079 +++ b/tests/data/test2079 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning Schannel +local-http https Server-localhost-sv.pem @@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --pinnedpubkey %SRCDIR/certs/Server-localhost-sv.pub.pem --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test2087 b/tests/data/test2087 index 61de80a5e6..8084e78ad4 100644 --- a/tests/data/test2087 +++ b/tests/data/test2087 @@ -27,6 +27,7 @@ MooMoo SSL SSLpinning Schannel +local-http https Server-localhost-sv.pem @@ -41,10 +42,6 @@ CURL_SSL_BACKEND=schannel --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 -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test3000 b/tests/data/test3000 index 05f4a010ed..6e7f7db4f6 100644 --- a/tests/data/test3000 +++ b/tests/data/test3000 @@ -26,6 +26,7 @@ MooMoo SSL !Schannel +local-http https Server-localhost-firstSAN-sv.pem @@ -36,10 +37,6 @@ HTTPS GET to localhost, first subject alt name matches, CN does not match --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test3001 b/tests/data/test3001 index 3a954324be..2d8817f0d0 100644 --- a/tests/data/test3001 +++ b/tests/data/test3001 @@ -26,6 +26,7 @@ MooMoo SSL !Schannel +local-http https Server-localhost-lastSAN-sv.pem @@ -36,10 +37,6 @@ HTTPS GET to localhost, last subject alt name matches, CN does not match --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test3023 b/tests/data/test3023 index 258f34eb0f..a5bba7683d 100644 --- a/tests/data/test3023 +++ b/tests/data/test3023 @@ -26,6 +26,7 @@ MooMoo SSL Schannel +local-http https Server-localhost-firstSAN-sv.pem @@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test3024 b/tests/data/test3024 index 57c1273484..af1549c62b 100644 --- a/tests/data/test3024 +++ b/tests/data/test3024 @@ -26,6 +26,7 @@ MooMoo SSL Schannel +local-http https Server-localhost-lastSAN-sv.pem @@ -40,10 +41,6 @@ CURL_SSL_BACKEND=schannel --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --ssl-revoke-best-effort https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test31 b/tests/data/test31 index 3ceaad0f94..d9d073996b 100644 --- a/tests/data/test31 +++ b/tests/data/test31 @@ -144,11 +144,9 @@ TZ=GMT http://test31.curl:%HTTPPORT/we/want/%TESTNUMBER -b none -c %LOGDIR/jar%TESTNUMBER.txt --resolve test31.curl:%HTTPPORT:127.0.0.1 - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - cookies +local-http diff --git a/tests/data/test310 b/tests/data/test310 index b9f1850ead..f7427981cc 100644 --- a/tests/data/test310 +++ b/tests/data/test310 @@ -26,6 +26,7 @@ MooMoo SSL !Schannel +local-http https Server-localhost-sv.pem @@ -36,10 +37,6 @@ simple HTTPS GET --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test311 b/tests/data/test311 index a3f9ed0e27..e163412741 100644 --- a/tests/data/test311 +++ b/tests/data/test311 @@ -17,6 +17,7 @@ PEM certificate SSL +local-http https Server-localhost0h-sv.pem @@ -27,10 +28,6 @@ HTTPS wrong subjectAltName but right CN --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test312 b/tests/data/test312 index c8c46b8214..5466c3eaab 100644 --- a/tests/data/test312 +++ b/tests/data/test312 @@ -17,6 +17,7 @@ PEM certificate SSL +local-http https Server-localhost.nn-sv.pem @@ -27,10 +28,6 @@ HTTPS GET to localhost and null-prefixed CN cert --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test313 b/tests/data/test313 index 12f91f9659..3d31dc6808 100644 --- a/tests/data/test313 +++ b/tests/data/test313 @@ -13,6 +13,7 @@ CRL SSL +local-http https Server-localhost-sv.pem @@ -23,10 +24,6 @@ CRL test --cacert %SRCDIR/certs/EdelCurlRoot-ca.crt --crlfile %SRCDIR/certs/Server-localhost-sv.crl https://localhost:%HTTPSPORT/%TESTNUMBER -# Ensure that we're running on localhost because we're checking the host name - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test389 b/tests/data/test389 index fcb29f5b8c..2dc0731b8e 100644 --- a/tests/data/test389 +++ b/tests/data/test389 @@ -31,6 +31,9 @@ Funny-head: yesyes http + +local-http + *.localhost is a local host @@ -38,9 +41,6 @@ http http://curlmachine.localhost:%HTTPPORT/%TESTNUMBER # Ensure that we're running on localhost - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - # diff --git a/tests/data/test392 b/tests/data/test392 index 5c1076c82b..d24841c616 100644 --- a/tests/data/test392 +++ b/tests/data/test392 @@ -37,11 +37,9 @@ TZ=GMT http://localhost:%HTTPPORT/%TESTNUMBER -b none http://localhost:%HTTPPORT/%TESTNUMBER - -perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );" - cookies +local-http diff --git a/tests/runtests.pl b/tests/runtests.pl index d906a2757e..4764ba31aa 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -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) { diff --git a/tests/servers.pm b/tests/servers.pm index 88ec10b484..86119c088c 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -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;