testenv/ starts two real NetBox 4.7 instances (v2 and v1 token), SSH targets on public, mgmt, and prod networks, a jump host, an IPv6-only host, a static host, and a client with ssh, sftp, scp, tmux, zellij, bash, zsh, and fish. A seed script fills NetBox through the REST API. 141 end-to-end checks cover cache and refresh filters, connecting, all resolver strategies, multiple instances, shortcuts and rewrites, SSH options and rules, static hosts, sftp/scp incl. IPv6 and jump hosts, tunnels, local notes and NetBox comments, completion and shell hooks, the TUI (driven through tmux), the configurator, and uninstall. Local only: testenv/up.sh, test.sh, shell.sh, down.sh. Not part of CI/CD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.2 KiB
Bash
65 lines
2.2 KiB
Bash
# The interactive TUI, driven through tmux: search, connect, sftp, tunnel, edit.
|
|
config <<'EOF'
|
|
resolver:
|
|
strategies: [management_subnet, primary_ip]
|
|
management_subnets: [10.231.1.0/24]
|
|
ssh:
|
|
default_user: ops
|
|
forwards:
|
|
web: {local: "18085:127.0.0.1:8081"}
|
|
EOF
|
|
check "refresh" netssh cache refresh
|
|
export TMUX_TMPDIR="$HOME/tmux"
|
|
mkdir -p "$TMUX_TMPDIR"
|
|
|
|
screen() { tmux capture-pane -p -t tui; }
|
|
shows() { screen | grep -qF -- "$1"; }
|
|
tui() { # start netssh in a fresh tmux session
|
|
tmux kill-server 2>/dev/null
|
|
tmux new-session -d -s tui -x 160 -y 40 -e HOME="$HOME" -e XDG_CONFIG_HOME="$XDG_CONFIG_HOME" -e XDG_CACHE_HOME="$XDG_CACHE_HOME" netssh
|
|
wait_for 10 shows "Search hostname"
|
|
}
|
|
step() { # NAME TEXT — wait until the pane shows TEXT
|
|
if wait_for 15 shows "$2"; then ok "$1"; else bad "$1" "$(screen)"; fi
|
|
}
|
|
|
|
tui && ok "TUI starts" || bad "TUI starts" "$(screen)"
|
|
tmux send-keys -t tui "fsn1-pve2"
|
|
step "search shows the host" "fsn/fsn1-pve2.hoster.test"
|
|
tmux send-keys -t tui Enter
|
|
sleep 1
|
|
tmux send-keys -t tui "hostname" Enter
|
|
step "enter connects" "fsn1-pve2"
|
|
tmux send-keys -t tui "exit" Enter
|
|
|
|
tui
|
|
tmux send-keys -t tui "fsn1-pve3"
|
|
wait_for 10 shows "fsn/fsn1-pve3.hoster.test"
|
|
tmux send-keys -t tui C-o
|
|
step "ctrl+o opens sftp" "sftp>"
|
|
tmux send-keys -t tui "pwd" Enter
|
|
step "sftp works" "Remote working directory: /home/ops"
|
|
tmux send-keys -t tui "bye" Enter
|
|
|
|
tui
|
|
tmux send-keys -t tui "fsn1-pve1"
|
|
wait_for 10 shows "fsn/fsn1-pve1.hoster.test"
|
|
tmux send-keys -t tui C-t
|
|
step "ctrl+t lists configured forwards" "forwards: web"
|
|
tmux send-keys -t tui "web" Enter
|
|
step "tunnel notice" "forwarding -L 18085:127.0.0.1:8081"
|
|
expect_out "tunnel from the TUI works" "hello from fsn1-pve1" curl -s --retry 10 --retry-connrefused --retry-delay 1 http://127.0.0.1:18085/
|
|
tmux send-keys -t tui C-c
|
|
|
|
tui
|
|
tmux send-keys -t tui "fsn1-pve1"
|
|
wait_for 10 shows "fsn/fsn1-pve1.hoster.test"
|
|
tmux send-keys -t tui C-e
|
|
step "ctrl+e opens the editor" "Connect as: ops@fsn/fsn1-pve1.hoster.test:22"
|
|
tmux send-keys -t tui C-u "admin@fsn/fsn1-pve1.hoster.test:22" Enter
|
|
sleep 1
|
|
tmux send-keys -t tui "whoami" Enter
|
|
step "edited user is used" "admin"
|
|
tmux send-keys -t tui "exit" Enter
|
|
tmux kill-server 2>/dev/null
|