mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(support): sanitize agent env (#12554)
This commit is contained in:
@@ -57,6 +57,7 @@ func TestRun(t *testing.T) {
|
||||
require.NotEmpty(t, bun.Network.TailnetDebug)
|
||||
require.NotNil(t, bun.Network.NetcheckLocal)
|
||||
require.NotNil(t, bun.Workspace.Workspace)
|
||||
assertSanitizedWorkspace(t, bun.Workspace.Workspace)
|
||||
require.NotEmpty(t, bun.Workspace.BuildLogs)
|
||||
require.NotNil(t, bun.Workspace.Agent)
|
||||
require.NotEmpty(t, bun.Workspace.AgentStartupLogs)
|
||||
@@ -92,6 +93,7 @@ func TestRun(t *testing.T) {
|
||||
require.NotEmpty(t, bun.Network.CoordinatorDebug)
|
||||
require.NotEmpty(t, bun.Network.TailnetDebug)
|
||||
require.NotNil(t, bun.Workspace)
|
||||
assertSanitizedWorkspace(t, bun.Workspace.Workspace)
|
||||
require.NotEmpty(t, bun.Logs)
|
||||
})
|
||||
|
||||
@@ -140,6 +142,17 @@ func assertSanitizedDeploymentConfig(t *testing.T, dc *codersdk.DeploymentConfig
|
||||
}
|
||||
}
|
||||
|
||||
func assertSanitizedWorkspace(t *testing.T, ws codersdk.Workspace) {
|
||||
t.Helper()
|
||||
for _, res := range ws.LatestBuild.Resources {
|
||||
for _, agt := range res.Agents {
|
||||
for k, v := range agt.EnvironmentVariables {
|
||||
assert.Equal(t, "***REDACTED***", v, "environment variable %q not sanitized", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setupWorkspaceAndAgent(ctx context.Context, t *testing.T, client *codersdk.Client, db database.Store, user codersdk.CreateFirstUserResponse) (codersdk.Workspace, codersdk.WorkspaceAgent) {
|
||||
// This is a valid zip file
|
||||
zipBytes := make([]byte, 22)
|
||||
|
||||
Reference in New Issue
Block a user