109 lines
2.5 KiB
Bash
Executable File
109 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# test_cli_flags.sh — smoke test for sovereign_browser CLI flags
|
|
#
|
|
# Tests --version, --help, and flag validation without launching the GUI
|
|
# (these flags exit before gtk_init). Run from the project root:
|
|
#
|
|
# ./tests/test_cli_flags.sh
|
|
#
|
|
# Exit code: 0 = all passed, 1 = any failed.
|
|
|
|
set -euo pipefail
|
|
|
|
BIN="./sovereign_browser"
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
ok() {
|
|
echo " PASS: $1"
|
|
PASS=$((PASS + 1))
|
|
}
|
|
|
|
fail() {
|
|
echo " FAIL: $1"
|
|
FAIL=$((FAIL + 1))
|
|
}
|
|
|
|
echo "=== CLI Flags Smoke Test ==="
|
|
|
|
# --version should print version and exit 0
|
|
echo "[1] --version"
|
|
out=$("$BIN" --version 2>&1) || true
|
|
if echo "$out" | grep -q "^sovereign_browser v"; then
|
|
ok "--version prints version string"
|
|
else
|
|
fail "--version output unexpected: $out"
|
|
fi
|
|
|
|
# -V short form
|
|
echo "[2] -V"
|
|
out=$("$BIN" -V 2>&1) || true
|
|
if echo "$out" | grep -q "^sovereign_browser v"; then
|
|
ok "-V works as short form"
|
|
else
|
|
fail "-V output unexpected: $out"
|
|
fi
|
|
|
|
# --help should print usage and exit 0
|
|
echo "[3] --help"
|
|
out=$("$BIN" --help 2>&1) || true
|
|
if echo "$out" | grep -q "Usage: sovereign_browser"; then
|
|
ok "--help prints usage"
|
|
else
|
|
fail "--help output unexpected"
|
|
fi
|
|
|
|
# -h short form
|
|
echo "[4] -h"
|
|
out=$("$BIN" -h 2>&1) || true
|
|
if echo "$out" | grep -q "Usage: sovereign_browser"; then
|
|
ok "-h works as short form"
|
|
else
|
|
fail "-h output unexpected"
|
|
fi
|
|
|
|
# Unknown flag should exit non-zero
|
|
echo "[5] unknown flag"
|
|
if "$BIN" --nonexistent-flag 2>/dev/null; then
|
|
fail "unknown flag should exit non-zero"
|
|
else
|
|
ok "unknown flag exits non-zero"
|
|
fi
|
|
|
|
# --login-method with invalid method should exit non-zero
|
|
echo "[6] invalid login method"
|
|
if "$BIN" --login-method bogus 2>/dev/null; then
|
|
fail "invalid login method should exit non-zero"
|
|
else
|
|
ok "invalid login method exits non-zero"
|
|
fi
|
|
|
|
# --login-method local without --nsec/--privkey should exit non-zero
|
|
echo "[7] local method without credentials"
|
|
if "$BIN" --login-method local 2>/dev/null; then
|
|
fail "local method without credentials should exit non-zero"
|
|
else
|
|
ok "local method without credentials exits non-zero"
|
|
fi
|
|
|
|
# --port out of range should exit non-zero
|
|
echo "[8] invalid port"
|
|
if "$BIN" --port 99999 2>/dev/null; then
|
|
fail "invalid port should exit non-zero"
|
|
else
|
|
ok "invalid port exits non-zero"
|
|
fi
|
|
|
|
# --max-tabs 0 should exit non-zero
|
|
echo "[9] invalid max-tabs"
|
|
if "$BIN" --max-tabs 0 2>/dev/null; then
|
|
fail "max-tabs 0 should exit non-zero"
|
|
else
|
|
ok "max-tabs 0 exits non-zero"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Results: $PASS passed, $FAIL failed ==="
|
|
exit $((FAIL > 0 ? 1 : 0))
|