Include cookies when testing services. (#1600)

* Include cookies when testing services.
Some services use various redirects which involve cookies. If we dont
include a cookie jar for these tests, they fail when they should pass.

* Fix potential file handle leak
This commit is contained in:
Tim Wilkinson 2024-10-08 20:59:07 -07:00 committed by GitHub
parent 8c863f35dd
commit 4f6fe904f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -233,7 +233,10 @@ local function get(validate)
hostname = m.hostname
port = m.port
end
local status, effective_url = io.popen("/usr/bin/curl --max-time 10 --retry 0 --connect-timeout 2 --speed-time 5 --speed-limit 1000 --silent --output /dev/null --location --write-out '%{http_code} %{url_effective}' " .. "http://" .. hostname .. ":" .. port .. path):read("*a"):match("^(%d+) (.*)")
local cf = io.popen("/usr/bin/curl --max-time 10 --retry 0 --connect-timeout 2 --speed-time 5 --speed-limit 1000 --silent --output /dev/null --cookie-jar /tmp/service-test-cookies --location --write-out '%{http_code} %{url_effective}' " .. "http://" .. hostname .. ":" .. port .. path)
local status, effective_url = cf:read("*a"):match("^(%d+) (.*)")
cf:close()
os.remove("/tmp/service-test-cookies")
if status == "200" or status == "401" then
vstate[service] = last
elseif status == "301" or status == "302" or status == "303" or status == "307" or status == "308" then