|
1 | 1 | package coderd_test
|
2 | 2 |
|
3 |
| -const ( |
4 |
| - secretValue = "********" |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/stretchr/testify/require" |
| 8 | + |
| 9 | + "github.com/coder/coder/cli/deployment" |
| 10 | + "github.com/coder/coder/coderd/coderdtest" |
| 11 | + "github.com/coder/coder/testutil" |
5 | 12 | )
|
6 | 13 |
|
7 |
| -// func TestDeploymentFlagSecrets(t *testing.T) { |
8 |
| -// t.Parallel() |
9 |
| -// hi := "hi" |
10 |
| -// ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
11 |
| -// defer cancel() |
12 |
| -// df := deployment.Flags() |
13 |
| -// // check if copy works for non-secret values |
14 |
| -// df.AccessURL.Value = hi |
15 |
| -// // check if secrets are removed |
16 |
| -// df.OAuth2GithubClientSecret.Value = hi |
17 |
| -// df.OIDCClientSecret.Value = hi |
18 |
| -// df.PostgresURL.Value = hi |
19 |
| -// df.SCIMAuthHeader.Value = hi |
| 14 | +func TestDeploymentConfig(t *testing.T) { |
| 15 | + t.Parallel() |
| 16 | + hi := "hi" |
| 17 | + ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 18 | + defer cancel() |
| 19 | + vip := deployment.NewViper() |
| 20 | + cfg, err := deployment.Config(vip) |
| 21 | + require.NoError(t, err) |
| 22 | + // values should be returned |
| 23 | + cfg.AccessURL = hi |
| 24 | + // values should not be returned |
| 25 | + cfg.OAuth2Github.ClientSecret = hi |
| 26 | + cfg.OIDC.ClientSecret = hi |
| 27 | + cfg.PostgresURL = hi |
| 28 | + cfg.SCIMAuthHeader = hi |
20 | 29 |
|
21 |
| -// client := coderdtest.New(t, &coderdtest.Options{ |
22 |
| -// DeploymentFlags: df, |
23 |
| -// }) |
24 |
| -// _ = coderdtest.CreateFirstUser(t, client) |
25 |
| -// scrubbed, err := client.DeploymentFlags(ctx) |
26 |
| -// require.NoError(t, err) |
27 |
| -// // ensure df is unchanged |
28 |
| -// require.EqualValues(t, hi, df.OAuth2GithubClientSecret.Value) |
29 |
| -// // ensure normal values pass through |
30 |
| -// require.EqualValues(t, hi, scrubbed.AccessURL.Value) |
31 |
| -// // ensure secrets are removed |
32 |
| -// require.EqualValues(t, secretValue, scrubbed.OAuth2GithubClientSecret.Value) |
33 |
| -// require.EqualValues(t, secretValue, scrubbed.OIDCClientSecret.Value) |
34 |
| -// require.EqualValues(t, secretValue, scrubbed.PostgresURL.Value) |
35 |
| -// require.EqualValues(t, secretValue, scrubbed.SCIMAuthHeader.Value) |
36 |
| -// } |
| 30 | + client := coderdtest.New(t, &coderdtest.Options{ |
| 31 | + DeploymentConfig: &cfg, |
| 32 | + }) |
| 33 | + _ = coderdtest.CreateFirstUser(t, client) |
| 34 | + scrubbed, err := client.DeploymentConfig(ctx) |
| 35 | + require.NoError(t, err) |
| 36 | + // ensure normal values pass through |
| 37 | + require.EqualValues(t, hi, scrubbed.AccessURL) |
| 38 | + // ensure secrets are removed |
| 39 | + require.Empty(t, scrubbed.OAuth2Github.ClientSecret) |
| 40 | + require.Empty(t, scrubbed.OIDC.ClientSecret) |
| 41 | + require.Empty(t, scrubbed.PostgresURL) |
| 42 | + require.Empty(t, scrubbed.SCIMAuthHeader) |
| 43 | +} |
0 commit comments