mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
Revert "Revert "feat: Support config files with viper"" (#4693)
This commit is contained in:
47
coderd/deploymentconfig_test.go
Normal file
47
coderd/deploymentconfig_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
package coderd_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/cli/config"
|
||||
"github.com/coder/coder/cli/deployment"
|
||||
"github.com/coder/coder/coderd/coderdtest"
|
||||
"github.com/coder/coder/testutil"
|
||||
)
|
||||
|
||||
func TestDeploymentConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
hi := "hi"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
vip := deployment.NewViper()
|
||||
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||
fs.String(config.FlagName, hi, "usage")
|
||||
cfg, err := deployment.Config(fs, vip)
|
||||
require.NoError(t, err)
|
||||
// values should be returned
|
||||
cfg.AccessURL.Value = hi
|
||||
// values should not be returned
|
||||
cfg.OAuth2GithubClientSecret.Value = hi
|
||||
cfg.OIDCClientSecret.Value = hi
|
||||
cfg.PostgresURL.Value = hi
|
||||
cfg.SCIMAPIKey.Value = hi
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{
|
||||
DeploymentConfig: &cfg,
|
||||
})
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
scrubbed, err := client.DeploymentConfig(ctx)
|
||||
require.NoError(t, err)
|
||||
// ensure normal values pass through
|
||||
require.EqualValues(t, hi, scrubbed.AccessURL.Value)
|
||||
// ensure secrets are removed
|
||||
require.Empty(t, scrubbed.OAuth2GithubClientSecret.Value)
|
||||
require.Empty(t, scrubbed.OIDCClientSecret.Value)
|
||||
require.Empty(t, scrubbed.PostgresURL.Value)
|
||||
require.Empty(t, scrubbed.SCIMAPIKey.Value)
|
||||
}
|
Reference in New Issue
Block a user