Stub route discovery in network QR tests
This commit is contained in:
1 parent
ef81d37a87
commit
5b22f50be3
1 file changed
+10
-5
@@ -8,6 +8,12 @@ tmp=$(mktemp -d)
|
|||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
mkdir -p "$tmp/bin"
|
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'
|
cat >"$tmp/bin/nmcli" <<'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [[ $* == *"DEVICE,TYPE,STATE"* ]]; then
|
if [[ $* == *"DEVICE,TYPE,STATE"* ]]; then
|
||||||
@@ -28,13 +34,13 @@ payload=$(</dev/stdin)
|
|||||||
printf '%s' "$payload" >"$QR_PAYLOAD_FILE"
|
printf '%s' "$payload" >"$QR_PAYLOAD_FILE"
|
||||||
printf '## \n ## \n ##\n'
|
printf '## \n ## \n ##\n'
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$tmp/bin/nmcli" "$tmp/bin/qrencode"
|
chmod +x "$tmp/bin/ip" "$tmp/bin/nmcli" "$tmp/bin/qrencode"
|
||||||
|
|
||||||
run_success_case() {
|
run_success_case() {
|
||||||
local description=$1 fields=$2 expected_payload=$3
|
local description=$1 fields=$2 expected_payload=$3
|
||||||
shift 3
|
shift 3
|
||||||
local output meta matrix payload arg with_meta=false
|
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
|
for arg in "$@"; do
|
||||||
[[ $arg == "--meta" ]] && with_meta=true || expected_iface=$arg
|
[[ $arg == "--meta" ]] && with_meta=true || expected_iface=$arg
|
||||||
@@ -49,9 +55,8 @@ run_success_case() {
|
|||||||
meta=$(head -n1 <<<"$output")
|
meta=$(head -n1 <<<"$output")
|
||||||
matrix=$(tail -n +2 <<<"$output")
|
matrix=$(tail -n +2 <<<"$output")
|
||||||
|
|
||||||
# The meta line leads with the shared interface, security, and SSID. With
|
# The metadata reports the requested interface, or the connected Wi-Fi
|
||||||
# no interface argument the helper detects one from the live host, so that
|
# interface supplied by the nmcli stub when no interface was requested.
|
||||||
# field is only pinned when the case pinned it.
|
|
||||||
expected_security=${expected_payload#WIFI:T:}
|
expected_security=${expected_payload#WIFI:T:}
|
||||||
expected_security=${expected_security%%;*}
|
expected_security=${expected_security%%;*}
|
||||||
expected_ssid=$(head -n1 <<<"$fields")
|
expected_ssid=$(head -n1 <<<"$fields")
|
||||||
|
|||||||
Reference in new issue
Block a user