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)
| 13077 | // handler itself has no auth check, so this test protects against a future |
| 13078 | // route restructuring that would accidentally expose these settings. |
| 13079 | func 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 | |
| 13099 | func TestChatWorkspaceTTL(t *testing.T) { |
| 13100 | t.Parallel() |
nothing calls this directly
no test coverage detected