diff --git a/test/shell.d/network-qr-test.sh b/test/shell.d/network-qr-test.sh index 7c64ef28..071950a9 100644 --- a/test/shell.d/network-qr-test.sh +++ b/test/shell.d/network-qr-test.sh @@ -8,6 +8,12 @@ tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT mkdir -p "$tmp/bin" +# Loopback is never wireless, so exercise the connected-Wi-Fi fallback. +cat >"$tmp/bin/ip" <<'EOF' +#!/bin/bash +printf '1.1.1.1 dev lo\n' +EOF + cat >"$tmp/bin/nmcli" <<'EOF' #!/bin/bash if [[ $* == *"DEVICE,TYPE,STATE"* ]]; then @@ -28,13 +34,13 @@ payload=$("$QR_PAYLOAD_FILE" printf '## \n ## \n ##\n' EOF -chmod +x "$tmp/bin/nmcli" "$tmp/bin/qrencode" +chmod +x "$tmp/bin/ip" "$tmp/bin/nmcli" "$tmp/bin/qrencode" run_success_case() { local description=$1 fields=$2 expected_payload=$3 shift 3 local output meta matrix payload arg with_meta=false - local expected_matrix expected_security expected_ssid expected_iface="*" + local expected_matrix expected_security expected_ssid expected_iface="wlan0" for arg in "$@"; do [[ $arg == "--meta" ]] && with_meta=true || expected_iface=$arg @@ -49,9 +55,8 @@ run_success_case() { meta=$(head -n1 <<<"$output") matrix=$(tail -n +2 <<<"$output") - # The meta line leads with the shared interface, security, and SSID. With - # no interface argument the helper detects one from the live host, so that - # field is only pinned when the case pinned it. + # The metadata reports the requested interface, or the connected Wi-Fi + # interface supplied by the nmcli stub when no interface was requested. expected_security=${expected_payload#WIFI:T:} expected_security=${expected_security%%;*} expected_ssid=$(head -n1 <<<"$fields")