Skip to content

[v0.2] Add the ProxyJump integration matrix - #33

Merged
Lingbou merged 1 commit into
mainfrom
feat/jump-integration-matrix
Sep 30, 2026
Merged

Lingbou merged 1 commit into
mainfrom
feat/jump-integration-matrix

Conversation

@Lingbou

@Lingbou Lingbou commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Parent: #1

Closes #14

The matrix

tests/proxyjump_sshd.rs now covers, against containerized sshd on a private Docker network:

Scenario Shape Assertion
line_connects_through_a_single_containerized_jump_host 1 hop exit 0
line_connects_through_two_containerized_jump_hosts 2 hops exit 0
line_connects_through_three_containerized_jump_hosts 3 hops exit 0 (recursive escaping)
line_connects_through_a_saved_profile_jump_host profile-backed hop (#12 end to end) exit 0
line_reports_rejected_credentials unauthorized key exit 255, Permission denied
line_reports_an_unavailable_hop second hop stopped exit 255, forwarding diagnostic
line_reports_a_reversed_chain hops swapped exit 255, diagnostics name the unreachable host

Every failing scenario also asserts that no ssh process from the chain outlives the failure, so a broken chain cannot leave a child holding the terminal. The whole suite runs in about eight seconds, and the fixture now takes a hop count plus small mutators (use_saved_profile_hop, use_unauthorized_identity, stop_hop, reverse_chain) instead of one hard-coded shape.

The bug this found

The stopped-hop scenario returned exit 0. OpenSSH expands %h/%p across the entire ProxyCommand value, nested quotes included, so in ssh -o ProxyCommand="ssh ... -W %h:%p -- hop1" -W %h:%p -- hop2 the inner %h:%p was expanded against the target, not hop 2. The second hop therefore forwarded straight to the target: the connection succeeded, the hop was silently skipped, and it only looked correct because the target's sshd accepted the same key.

The fix doubles the percent signs in the embedded command (shell_quote_nested), so the outer pass turns %%h:%%p into %h:%p and the nested OpenSSH process expands it against its own destination. Each nesting level escapes once more, which the three-hop case now pins down. ADR-0002 records the rule.

This is exactly the class of defect the ticket existed to catch: it is invisible to command-shape unit tests and to a happy-path integration test.

Note on terminal cleanup

The integration tests use line <name>, the CLI connect path, which never enters raw mode or the alternate screen — so there is no terminal state to restore at that level, and the asserted property there is process cleanup (no surviving ssh). Terminal restoration belongs to the TUI path (TuiSession::suspend/resume/Drop), which #3 moved behind the platform seam and covered with its own tests.

Verification

  • cargo test --all-targets --locked (123 lib tests, seven containerized integration tests, every other suite), cargo clippy --all-targets --all-features --locked -- -D warnings, cargo +1.88.0 check --all-targets --locked, cargo fmt --check.

OpenSSH expands %h/%p across the whole ProxyCommand value, nested
commands included, so the escaped inner tokens now survive the outer
pass and each hop forwards to its own destination. Without this the
second hop connected to the target directly and the hop was skipped.

The integration fixture grows into the matrix from #14: one, two, and
three hops, a saved-profile hop, rejected credentials, a stopped hop,
and a reversed chain, each also asserting no ssh outlives the failure.

Refs #14

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou
Lingbou merged commit e608b3f into main Sep 30, 2026
11 checks passed
@Lingbou
Lingbou deleted the feat/jump-integration-matrix branch September 30, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v0.2] Add the ProxyJump integration matrix

1 participant