mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: Add deployment side config-ssh options (#6613)
* feat: Allow setting deployment wide ssh config settings * feat: config-ssh respects deployment ssh config * The '.' is now configurable * Move buildinfo into deployment.go
This commit is contained in:
@ -3,6 +3,9 @@ package codersdk_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/cli/clibase"
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
@ -105,3 +108,82 @@ func TestDeploymentValues_HighlyConfigurable(t *testing.T) {
|
||||
t.Errorf("Excluded option %q is not in the deployment config. Remove it?", opt)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSSHConfig_ParseOptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
ConfigOptions clibase.Strings
|
||||
ExpectError bool
|
||||
Expect map[string]string
|
||||
}{
|
||||
{
|
||||
Name: "Empty",
|
||||
ConfigOptions: []string{},
|
||||
Expect: map[string]string{},
|
||||
},
|
||||
{
|
||||
Name: "Whitespace",
|
||||
ConfigOptions: []string{
|
||||
"test value",
|
||||
},
|
||||
Expect: map[string]string{
|
||||
"test": "value",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SimpleValueEqual",
|
||||
ConfigOptions: []string{
|
||||
"test=value",
|
||||
},
|
||||
Expect: map[string]string{
|
||||
"test": "value",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SimpleValues",
|
||||
ConfigOptions: []string{
|
||||
"test=value",
|
||||
"foo=bar",
|
||||
},
|
||||
Expect: map[string]string{
|
||||
"test": "value",
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ValueWithQuote",
|
||||
ConfigOptions: []string{
|
||||
"bar=buzz=bazz",
|
||||
},
|
||||
Expect: map[string]string{
|
||||
"bar": "buzz=bazz",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "NoEquals",
|
||||
ConfigOptions: []string{
|
||||
"foobar",
|
||||
},
|
||||
ExpectError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
tt := tt
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := codersdk.SSHConfig{
|
||||
SSHConfigOptions: tt.ConfigOptions,
|
||||
}
|
||||
got, err := c.ParseOptions()
|
||||
if tt.ExpectError {
|
||||
require.Error(t, err, tt.ConfigOptions.String())
|
||||
} else {
|
||||
require.NoError(t, err, tt.ConfigOptions.String())
|
||||
require.Equalf(t, tt.Expect, got, tt.ConfigOptions.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user