From 750a90d7b4fd4f547f1f7e41aef89ac2812967de Mon Sep 17 00:00:00 2001 From: Andreas Loeffler Date: Mon, 28 Sep 2026 14:23:44 +0200 Subject: [PATCH] test(ssh): add AddHost cases for lowercase host and End-marker boundary Covers two scenarios that upstream fix #1277 addresses but did not have explicit AddHost-level tests for: - 'Host addition with lowercase host entries': verifies that a config using lowercase 'host' keywords is correctly detected as a section boundary so the new entry is inserted at the top rather than appended. - 'Host addition does not corrupt existing Devsy block followed by plain host': verifies that a '# Devsy End' comment line preceding a new Host stanza does not cause the insert position to back up into the previous Devsy block. --- pkg/ssh/config_test.go | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/pkg/ssh/config_test.go b/pkg/ssh/config_test.go index c4230dab59..e793c66d84 100644 --- a/pkg/ssh/config_test.go +++ b/pkg/ssh/config_test.go @@ -266,6 +266,92 @@ Host existingtesthost Host existinghost User existinguser`, + }, + { + name: "Host addition with lowercase host entries", + config: `host 192.168.1.1 + User alice + Port 22 + +host myserver + User bob`, + execPath: testExecPath, + host: testHostBasic, + user: testUser, + context: testContextAlt, + workspace: testWorkspaceAlt, + workdir: "", + command: "", + gpgagent: false, + agentForwarding: true, + devsyHome: "", + provider: "", + expected: `# Devsy Start testhost +Host testhost + ForwardAgent yes + LogLevel error + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + HostKeyAlgorithms rsa-sha2-256,rsa-sha2-512,ssh-rsa + ProxyCommand "/path/to/exec" workspace ssh --stdio --context testcontext --user testuser testworkspace + User testuser +# Devsy End testhost +host 192.168.1.1 + User alice + Port 22 + +host myserver + User bob`, + }, + { + name: "Host addition does not corrupt existing Devsy block followed by plain host", + config: `host plain-host + User alice + +# Devsy Start existing.devsy +Host existing.devsy + ForwardAgent yes + LogLevel error + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + HostKeyAlgorithms rsa-sha2-256,rsa-sha2-512,ssh-rsa + ProxyCommand "/path/to/exec" workspace ssh --stdio --context ctx --user user existing + User user +# Devsy End existing.devsy`, + execPath: testExecPath, + host: testHostBasic, + user: testUser, + context: testContextAlt, + workspace: testWorkspaceAlt, + workdir: "", + command: "", + gpgagent: false, + agentForwarding: true, + devsyHome: "", + provider: "", + expected: `# Devsy Start testhost +Host testhost + ForwardAgent yes + LogLevel error + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + HostKeyAlgorithms rsa-sha2-256,rsa-sha2-512,ssh-rsa + ProxyCommand "/path/to/exec" workspace ssh --stdio --context testcontext --user testuser testworkspace + User testuser +# Devsy End testhost +host plain-host + User alice + +# Devsy Start existing.devsy +Host existing.devsy + ForwardAgent yes + LogLevel error + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + HostKeyAlgorithms rsa-sha2-256,rsa-sha2-512,ssh-rsa + ProxyCommand "/path/to/exec" workspace ssh --stdio --context ctx --user user existing + User user +# Devsy End existing.devsy`, }, { name: "Host addition after top level includes",