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>
41 lines
1.7 KiB
Bash
41 lines
1.7 KiB
Bash
# Port forwards: named, ad hoc, --forward with a shell, port in use.
|
|
config <<'EOF'
|
|
resolver:
|
|
strategies: [management_subnet, primary_ip]
|
|
management_subnets: [10.231.1.0/24]
|
|
ssh:
|
|
default_user: ops
|
|
forwards:
|
|
web: {local: "18081:127.0.0.1:8081"}
|
|
rules:
|
|
- match: {kind: vm, instance: fsn}
|
|
proxy_jump: ops@10.231.0.30
|
|
EOF
|
|
tunnel_test() { # NAME PORT WANT ARGS...
|
|
local name=$1 port=$2 want=$3 pid out
|
|
shift 3
|
|
"$@" >"$HOME/tunnel.log" 2>&1 &
|
|
pid=$!
|
|
if wait_for 15 curl -sf "http://127.0.0.1:$port/"; then
|
|
out=$(curl -s "http://127.0.0.1:$port/")
|
|
[[ $out == *"$want"* ]] && ok "$name" || bad "$name" "curl: $out"
|
|
else
|
|
bad "$name" "tunnel did not open: $(cat "$HOME/tunnel.log")"
|
|
fi
|
|
kill "$pid" 2>/dev/null
|
|
wait "$pid" 2>/dev/null
|
|
}
|
|
tunnel_test "named forward" 18081 "hello from fsn1-pve1" netssh tunnel fsn/fsn1-pve1.hoster.test web
|
|
expect_out "tunnel notice" "forwarding -L 18081:127.0.0.1:8081 via fsn1-pve1.hoster.test" cat "$HOME/tunnel.log"
|
|
tunnel_test "ad hoc spec through the bastion" 18082 "hello from web1" netssh tunnel fsn/web1 18082:127.0.0.1:8081
|
|
tunnel_test "--forward with a remote command" 18081 "hello from fsn1-pve2" netssh --forward web fsn/fsn1-pve2.hoster.test sleep 30
|
|
|
|
netssh tunnel fsn/fsn1-pve1.hoster.test web >/dev/null 2>&1 &
|
|
holder=$!
|
|
wait_for 15 curl -sf http://127.0.0.1:18081/
|
|
expect_fail "port in use fails instead of hanging" "Address in use" timeout 20 netssh tunnel fsn/fsn1-pve2.hoster.test web
|
|
kill "$holder"; wait "$holder" 2>/dev/null
|
|
|
|
expect_fail "unknown forward lists the configured ones" "available: web" netssh tunnel fsn/fsn1-pve1.hoster.test db
|
|
expect_fail "tunnel without forward" "forwards for fsn/fsn1-pve1.hoster.test: web" netssh tunnel fsn/fsn1-pve1.hoster.test
|