(t *testing.T)
| 917 | } |
| 918 | |
| 919 | func 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() |
nothing calls this directly
no test coverage detected