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

Function TestMCPServerConfigs

enterprise/dbcrypt/dbcrypt_internal_test.go:919–1056  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

917}
918
919func TestMCPServerConfigs(t *testing.T) {
920 t.Parallel()
921 ctx := context.Background()
922
923 const (
924 //nolint:gosec // test credentials
925 oauthSecret = "my-oauth-secret"
926 apiKeyValue = "my-api-key"
927 customHeaders = `{"X-Custom":"header-value"}`
928 )
929 // insertConfig is a small helper that creates an MCP server
930 // config through the encrypted store with secret fields set.
931 insertConfig := func(t *testing.T, crypt *dbCrypt, ciphers []Cipher) database.MCPServerConfig {
932 t.Helper()
933 cfg := dbgen.MCPServerConfig(t, crypt, database.MCPServerConfig{
934 Description: "test description",
935 AuthType: "oauth2",
936 OAuth2ClientID: "client-id",
937 OAuth2ClientSecret: oauthSecret,
938 APIKeyValue: apiKeyValue,
939 CustomHeaders: customHeaders,
940 Availability: "force_on",
941 })
942 requireMCPServerConfigDecrypted(t, cfg, ciphers, oauthSecret, apiKeyValue, customHeaders)
943 return cfg
944 }
945
946 t.Run("InsertMCPServerConfig", func(t *testing.T) {
947 t.Parallel()
948 db, crypt, ciphers := setup(t)
949 cfg := insertConfig(t, crypt, ciphers)
950 requireMCPServerConfigRawEncrypted(ctx, t, db, cfg.ID, ciphers, oauthSecret, apiKeyValue, customHeaders)
951 })
952
953 t.Run("GetMCPServerConfigByID", func(t *testing.T) {
954 t.Parallel()
955 db, crypt, ciphers := setup(t)
956 cfg := insertConfig(t, crypt, ciphers)
957
958 got, err := crypt.GetMCPServerConfigByID(ctx, cfg.ID)
959 require.NoError(t, err)
960 requireMCPServerConfigDecrypted(t, got, ciphers, oauthSecret, apiKeyValue, customHeaders)
961 requireMCPServerConfigRawEncrypted(ctx, t, db, cfg.ID, ciphers, oauthSecret, apiKeyValue, customHeaders)
962 })
963
964 t.Run("GetMCPServerConfigBySlug", func(t *testing.T) {
965 t.Parallel()
966 db, crypt, ciphers := setup(t)
967 cfg := insertConfig(t, crypt, ciphers)
968
969 got, err := crypt.GetMCPServerConfigBySlug(ctx, cfg.Slug)
970 require.NoError(t, err)
971 requireMCPServerConfigDecrypted(t, got, ciphers, oauthSecret, apiKeyValue, customHeaders)
972 requireMCPServerConfigRawEncrypted(ctx, t, db, cfg.ID, ciphers, oauthSecret, apiKeyValue, customHeaders)
973 })
974
975 t.Run("GetMCPServerConfigs", func(t *testing.T) {
976 t.Parallel()

Callers

nothing calls this directly

Calls 14

MCPServerConfigFunction · 0.92
setupFunction · 0.70
HelperMethod · 0.65
RunMethod · 0.65
GetMCPServerConfigsMethod · 0.65

Tested by

no test coverage detected