MCPcopy Index your code
hub / github.com/coder/coder / TestChatAdvisorConfig_UnauthenticatedFails

Function TestChatAdvisorConfig_UnauthenticatedFails

coderd/exp_chats_test.go:13079–13097  ·  view source on GitHub ↗

TestChatAdvisorConfig_UnauthenticatedFails pins that the advisor config endpoints are gated by apiKeyMiddleware at the /chats route level. The handler itself has no auth check, so this test protects against a future route restructuring that would accidentally expose these settings.

(t *testing.T)

Source from the content-addressed store, hash-verified

13077// handler itself has no auth check, so this test protects against a future
13078// route restructuring that would accidentally expose these settings.
13079func TestChatAdvisorConfig_UnauthenticatedFails(t *testing.T) {
13080 t.Parallel()
13081 ctx := testutil.Context(t, testutil.WaitLong)
13082
13083 adminClient := newChatClient(t)
13084 coderdtest.CreateFirstUser(t, adminClient.Client)
13085
13086 anonClient := codersdk.NewExperimentalClient(codersdk.New(adminClient.URL))
13087 _, err := anonClient.GetChatAdvisorConfig(ctx)
13088 var sdkErr *codersdk.Error
13089 require.ErrorAs(t, err, &sdkErr)
13090 require.Equal(t, http.StatusUnauthorized, sdkErr.StatusCode())
13091
13092 err = anonClient.UpdateChatAdvisorConfig(ctx, codersdk.UpdateAdvisorConfigRequest{
13093 Enabled: true,
13094 })
13095 require.ErrorAs(t, err, &sdkErr)
13096 require.Equal(t, http.StatusUnauthorized, sdkErr.StatusCode())
13097}
13098
13099func TestChatWorkspaceTTL(t *testing.T) {
13100 t.Parallel()

Callers

nothing calls this directly

Calls 9

GetChatAdvisorConfigMethod · 0.95
StatusCodeMethod · 0.95
ContextFunction · 0.92
CreateFirstUserFunction · 0.92
NewExperimentalClientFunction · 0.92
NewFunction · 0.92
newChatClientFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected