@@ -73,6 +73,7 @@ func TestRun(t *testing.T) {
73
73
assertNotNilNotEmpty (t ,bun .Workspace .TemplateFileBase64 ,"workspace template file should be present" )
74
74
require .NotNil (t ,bun .Workspace .Parameters ,"workspace parameters should be present" )
75
75
assertNotNilNotEmpty (t ,bun .Agent .Agent ,"agent should be present" )
76
+ assertSanitizedAgent (t ,* bun .Agent .Agent )
76
77
assertNotNilNotEmpty (t ,bun .Agent .ListeningPorts ,"agent listening ports should be present" )
77
78
assertNotNilNotEmpty (t ,bun .Agent .Logs ,"agent logs should be present" )
78
79
assertNotNilNotEmpty (t ,bun .Agent .AgentMagicsockHTML ,"agent magicsock should be present" )
@@ -163,13 +164,18 @@ func assertSanitizedWorkspace(t *testing.T, ws codersdk.Workspace) {
163
164
t .Helper ()
164
165
for _ ,res := range ws .LatestBuild .Resources {
165
166
for _ ,agt := range res .Agents {
166
- for k ,v := range agt .EnvironmentVariables {
167
- assert .Equal (t ,"***REDACTED***" ,v ,"environment variable %q not sanitized" ,k )
168
- }
167
+ assertSanitizedAgent (t ,agt )
169
168
}
170
169
}
171
170
}
172
171
172
+ func assertSanitizedAgent (t * testing.T ,agt codersdk.WorkspaceAgent ) {
173
+ t .Helper ()
174
+ for k ,v := range agt .EnvironmentVariables {
175
+ assert .Equal (t ,"***REDACTED***" ,v ,"agent %q environment variable %q not sanitized" ,agt .Name ,k )
176
+ }
177
+ }
178
+
173
179
func setupWorkspaceAndAgent (ctx context.Context ,t * testing.T ,client * codersdk.Client ,db database.Store ,user codersdk.CreateFirstUserResponse ) (codersdk.Workspace , codersdk.WorkspaceAgent ) {
174
180
// This is a valid zip file
175
181
zipBytes := make ([]byte ,22 )