MCPcopy Index your code
hub / github.com/coder/coder / TestParseSSHConfigOption

Function TestParseSSHConfigOption

codersdk/deployment_test.go:152–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestParseSSHConfigOption(t *testing.T) {
153 t.Parallel()
154
155 testCases := []struct {
156 name string
157 option string
158 wantKey string
159 wantValue string
160 wantErr bool
161 }{
162 {
163 name: "ProxyCommandWithSpaces",
164 option: "ProxyCommand=ssh -W %h:%p bastion",
165 wantKey: "ProxyCommand",
166 wantValue: "ssh -W %h:%p bastion",
167 },
168 {
169 name: "SetEnvWithEquals",
170 option: "SetEnv=FOO=bar BAZ=qux",
171 wantKey: "SetEnv",
172 wantValue: "FOO=bar BAZ=qux",
173 },
174 {
175 name: "SetEnvWithSpaceSeparator",
176 option: "SetEnv FOO=bar BAZ=qux",
177 wantKey: "SetEnv",
178 wantValue: "FOO=bar BAZ=qux",
179 },
180 {
181 name: "HostName",
182 option: "HostName example.com",
183 wantKey: "HostName",
184 wantValue: "example.com",
185 },
186 {
187 name: "NewlineInValue",
188 option: "ProxyCommand=echo hi\nHost *",
189 wantErr: true,
190 },
191 {
192 name: "CarriageReturnInValue",
193 option: "ProxyCommand=echo hi\rHost *",
194 wantErr: true,
195 },
196 {
197 name: "NULInValue",
198 option: "ProxyCommand=echo hi\x00Host *",
199 wantErr: true,
200 },
201 {
202 name: "NewlineInKey",
203 option: "Proxy\nCommand=value",
204 wantErr: true,
205 },
206 {
207 name: "CarriageReturnInKey",
208 option: "Proxy\rCommand=value",
209 wantErr: true,

Callers

nothing calls this directly

Calls 4

ParseSSHConfigOptionFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected