mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli): support header and header-command in config-ssh (#10413)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
co-authored by
Mathias Fredriksson
parent
d6cdaae8b1
commit
d3ccb07361
@@ -462,6 +462,9 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
|
||||
"# Last config-ssh options:",
|
||||
"# :wait=yes",
|
||||
"# :ssh-host-prefix=coder-test.",
|
||||
"# :header=X-Test-Header=foo",
|
||||
"# :header=X-Test-Header2=bar",
|
||||
"# :header-command=printf h1=v1 h2=\"v2\" h3='v3'",
|
||||
"#",
|
||||
headerEnd,
|
||||
"",
|
||||
@@ -471,6 +474,9 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
|
||||
"--yes",
|
||||
"--wait=yes",
|
||||
"--ssh-host-prefix", "coder-test.",
|
||||
"--header", "X-Test-Header=foo",
|
||||
"--header", "X-Test-Header2=bar",
|
||||
"--header-command", "printf h1=v1 h2=\"v2\" h3='v3'",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -563,6 +569,55 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
|
||||
regexMatch: "ProxyCommand /foo/bar/coder",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Header",
|
||||
args: []string{
|
||||
"--yes",
|
||||
"--header", "X-Test-Header=foo",
|
||||
"--header", "X-Test-Header2=bar",
|
||||
},
|
||||
wantErr: false,
|
||||
hasAgent: true,
|
||||
wantConfig: wantConfig{
|
||||
regexMatch: `ProxyCommand .* --header "X-Test-Header=foo" --header "X-Test-Header2=bar" ssh`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Header command",
|
||||
args: []string{
|
||||
"--yes",
|
||||
"--header-command", "printf h1=v1",
|
||||
},
|
||||
wantErr: false,
|
||||
hasAgent: true,
|
||||
wantConfig: wantConfig{
|
||||
regexMatch: `ProxyCommand .* --header-command "printf h1=v1" ssh`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Header command with double quotes",
|
||||
args: []string{
|
||||
"--yes",
|
||||
"--header-command", "printf h1=v1 h2=\"v2\"",
|
||||
},
|
||||
wantErr: false,
|
||||
hasAgent: true,
|
||||
wantConfig: wantConfig{
|
||||
regexMatch: `ProxyCommand .* --header-command "printf h1=v1 h2=\\\"v2\\\"" ssh`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Header command with single quotes",
|
||||
args: []string{
|
||||
"--yes",
|
||||
"--header-command", "printf h1=v1 h2='v2'",
|
||||
},
|
||||
wantErr: false,
|
||||
hasAgent: true,
|
||||
wantConfig: wantConfig{
|
||||
regexMatch: `ProxyCommand .* --header-command "printf h1=v1 h2='v2'" ssh`,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
Reference in New Issue
Block a user