Adds testing for IPv6.

Currently IPv4 is hardcoded, meaning IPv6 should not work even for
the loopback interface.
This commit is contained in:
Carlos Nihelton 2022-06-08 12:17:23 -03:00
parent 4c9a99e9ce
commit 0263924386
No known key found for this signature in database
GPG Key ID: 6FE346D245197E9A
1 changed files with 16 additions and 12 deletions

View File

@ -250,20 +250,24 @@ if [ "${RELEASE%.*}" -ge 20 ]; then
# Assert that only loopback interface is accepted.
interfaces=($(ip --json link show up | jq -r '.[]["ifname"] | select ( . != null )'))
for if in ${interfaces[@]}; do
for ipv in 4 6; do
curl_ec=0
timeout 10s curl "http://localhost:$port/meta/status" --interface $if || curl_ec=$?
# Loopback should exit 0
timeout 10s \
curl -$ipv "http://localhost:$port/meta/status" --interface $if \
|| curl_ec=$?
# Loopback should exit 0 on IPv4
if [ $if = "lo" ]; then
if [ $curl_ec -ne 0 ]; then
if [ $curl_ec -ne 0 -a $ipv -eq 4 ]; then
loopback_failed=1
fi
# Other interfaces shoud not
# Everything else should not.
else
if [ $curl_ec -eq 0 ]; then
unallowed_failed=1
fi
fi
done
done
kill $subiquity_pid
if [ $loopback_failed -ne 0 ]; then
echo "Loopback was expected to connect"