@@ -133,26 +133,29 @@ func TestExpMcpServer(t *testing.T) {
133
133
require .Equal (t ,1.0 ,initializeResponse ["id" ])
134
134
require .NotNil (t ,initializeResponse ["result" ])
135
135
})
136
+ }
136
137
137
- t .Run ("NoCredentials" ,func (t * testing.T ) {
138
- t .Parallel ()
138
+ func TestExpMcpServerNoCredentials (t * testing.T ) {
139
+ // Ensure that no credentials are set from the environment.
140
+ t .Setenv ("CODER_AGENT_TOKEN" ,"" )
141
+ t .Setenv ("CODER_AGENT_TOKEN_FILE" ,"" )
142
+ t .Setenv ("CODER_SESSION_TOKEN" ,"" )
139
143
140
- ctx := testutil .Context (t ,testutil .WaitShort )
141
- cancelCtx ,cancel := context .WithCancel (ctx )
142
- t .Cleanup (cancel )
144
+ ctx := testutil .Context (t ,testutil .WaitShort )
145
+ cancelCtx ,cancel := context .WithCancel (ctx )
146
+ t .Cleanup (cancel )
143
147
144
- client := coderdtest .New (t ,nil )
145
- inv ,root := clitest .New (t ,"exp" ,"mcp" ,"server" )
146
- inv = inv .WithContext (cancelCtx )
148
+ client := coderdtest .New (t ,nil )
149
+ inv ,root := clitest .New (t ,"exp" ,"mcp" ,"server" )
150
+ inv = inv .WithContext (cancelCtx )
147
151
148
- pty := ptytest .New (t )
149
- inv .Stdin = pty .Input ()
150
- inv .Stdout = pty .Output ()
151
- clitest .SetupConfig (t ,client ,root )
152
+ pty := ptytest .New (t )
153
+ inv .Stdin = pty .Input ()
154
+ inv .Stdout = pty .Output ()
155
+ clitest .SetupConfig (t ,client ,root )
152
156
153
- err := inv .Run ()
154
- assert .ErrorContains (t ,err ,"are not logged in" )
155
- })
157
+ err := inv .Run ()
158
+ assert .ErrorContains (t ,err ,"are not logged in" )
156
159
}
157
160
158
161
//nolint:tparallel,paralleltest