diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index a824ebcd7..b4548c78a 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -65,8 +65,13 @@ load helpers myport=54321 # Container will exit as soon as 'nc' receives input + # We use '-n -v' to give us log messages showing an incoming connection + # and its IP address; the purpose of that is guaranteeing that the + # remote IP is not 127.0.0.1 (podman PR #9052). + # We could get more parseable output by using $NCAT_REMOTE_ADDR, + # but busybox nc doesn't support that. run_podman run -d --userns=keep-id -p 127.0.0.1:$myport:$myport \ - $IMAGE nc -l -p $myport + $IMAGE nc -l -n -v -p $myport cid="$output" # emit random string, and check it @@ -74,7 +79,20 @@ load helpers echo "$teststring" | nc 127.0.0.1 $myport run_podman logs $cid - is "$output" "$teststring" "test string received on container" + # High-level overview of received output. We also check it line by line + # but this is a basic test; if it fails, we can see full output, which + # is helpful because failure here indicates something is VERY wrong. + is "$output" "listening on .*:$myport .*connect to .*$teststring" \ + "Basic check on received output" + + # Line-by-line output check. If any of these fail, we will not see + # the full output of 'nc'. The most important check here is the + # second line, in which we check for a 10.X remote IP (not 127.*) + is "${lines[0]}" "listening on \[::\]:$myport ..." "First line of output" + is "${lines[1]}" \ + "connect to \[::ffff:10\..*\]:$myport from \[::ffff:10\..*\]:" \ + "Second output line from nc" + is "${lines[2]}" "$teststring" "test string received on container" # Clean up run_podman rm $cid