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

Function TestMCPServerConfigsUniqueSlug

coderd/mcp_test.go:482–518  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

480}
481
482func TestMCPServerConfigsUniqueSlug(t *testing.T) {
483 t.Parallel()
484
485 ctx := testutil.Context(t, testutil.WaitLong)
486 client := newMCPClient(t)
487 _ = coderdtest.CreateFirstUser(t, client)
488
489 _, err := client.CreateMCPServerConfig(ctx, codersdk.CreateMCPServerConfigRequest{
490 DisplayName: "First",
491 Slug: "test-server",
492 Transport: "streamable_http",
493 URL: "https://mcp.example.com/first",
494 AuthType: "none",
495 Availability: "default_off",
496 Enabled: true,
497 ToolAllowList: []string{},
498 ToolDenyList: []string{},
499 })
500 require.NoError(t, err)
501
502 // Attempt to create another config with the same slug.
503 _, err = client.CreateMCPServerConfig(ctx, codersdk.CreateMCPServerConfigRequest{
504 DisplayName: "Second",
505 Slug: "test-server",
506 Transport: "streamable_http",
507 URL: "https://mcp.example.com/second",
508 AuthType: "none",
509 Availability: "default_off",
510 Enabled: true,
511 ToolAllowList: []string{},
512 ToolDenyList: []string{},
513 })
514 require.Error(t, err)
515 var sdkErr *codersdk.Error
516 require.ErrorAs(t, err, &sdkErr)
517 require.Equal(t, http.StatusConflict, sdkErr.StatusCode())
518}
519
520func TestMCPServerConfigsOAuth2Disconnect(t *testing.T) {
521 t.Parallel()

Callers

nothing calls this directly

Calls 7

StatusCodeMethod · 0.95
ContextFunction · 0.92
CreateFirstUserFunction · 0.92
newMCPClientFunction · 0.85
CreateMCPServerConfigMethod · 0.80
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected