Skip to content

Commit a07cf50

Browse files
Rebase the mcp/registry dependency to v1.3.3 (#297)
* Rebase to the new upstram version Signed-off-by: Radoslav Dimitrov <[email protected]> * Fix validation errors Signed-off-by: Radoslav Dimitrov <[email protected]> * Move the schema update script to a unit test Signed-off-by: Radoslav Dimitrov <[email protected]> * Rebase to main Signed-off-by: Radoslav Dimitrov <[email protected]> * chore: update tool lists for MCP servers\n\nWarning added for servers:\n- sqlite\n\nAutomatically updated using 'thv mcp list' command.\n\nCo-authored-by: rdimitrov <[email protected]> * Add type converter functions Signed-off-by: Radoslav Dimitrov <[email protected]> * Bump to mcp/registry v1.3.5 and go 1.24.6 Signed-off-by: Radoslav Dimitrov <[email protected]> * Add fixtures to ensure proper conversion between the 2 types Signed-off-by: Radoslav Dimitrov <[email protected]> * Split the converters into a separate package with separate files Signed-off-by: Radoslav Dimitrov <[email protected]> * Populate the Title property on the upstream format Signed-off-by: Radoslav Dimitrov <[email protected]> * Handle permissions, provenance and args Signed-off-by: Radoslav Dimitrov <[email protected]> * Use converters for generating the official registry format Signed-off-by: Radoslav Dimitrov <[email protected]> * Remove leftover methods Signed-off-by: Radoslav Dimitrov <[email protected]> * Do not store the transport type in extensions Signed-off-by: Radoslav Dimitrov <[email protected]> * Do not set a default port for serverjson url Signed-off-by: Radoslav Dimitrov <[email protected]> * Add integration tests for going back and forth Signed-off-by: Radoslav Dimitrov <[email protected]> * Fix the linting errors Signed-off-by: Radoslav Dimitrov <[email protected]> * chore: update tool lists for MCP servers\n\nWarning added for servers:\n- plotting\n\nAutomatically updated using 'thv mcp list' command.\n\nCo-authored-by: rdimitrov <[email protected]> * Address Claude's feedback Signed-off-by: Radoslav Dimitrov <[email protected]> --------- Signed-off-by: Radoslav Dimitrov <[email protected]> Co-authored-by: GitHub Action <[email protected]>
1 parent 1758f35 commit a07cf50

33 files changed

+3660
-602
lines changed

Taskfile.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,6 @@ tasks:
260260
cmds:
261261
- ./{{.BUILD_DIR}}/registry-builder version
262262

263-
sync-schema:
264-
desc: Sync schema reference with Go dependency version
265-
cmds:
266-
- echo "🔄 Syncing schema version with Go dependency..."
267-
- ./scripts/sync-schema-version.sh
268-
- echo "✅ Schema sync complete. Run 'task validate' to verify."
269-
270263
watch:
271264
desc: Watch for changes and rebuild (requires entr)
272265
cmds:

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module github.com/stacklok/toolhive-registry
22

3-
go 1.24.5
3+
go 1.24.6
44

55
require (
66
github.com/google/go-cmp v0.7.0
7-
github.com/google/uuid v1.6.0
8-
github.com/modelcontextprotocol/registry v1.0.0
7+
github.com/modelcontextprotocol/registry v1.3.5
98
github.com/spf13/cobra v1.10.1
109
github.com/stacklok/toolhive v0.3.7
1110
github.com/stretchr/testify v1.11.1
@@ -60,7 +59,7 @@ require (
6059
github.com/felixge/httpsnoop v1.0.4 // indirect
6160
github.com/fsnotify/fsnotify v1.9.0 // indirect
6261
github.com/go-chi/chi/v5 v5.2.3 // indirect
63-
github.com/go-jose/go-jose/v4 v4.1.2 // indirect
62+
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
6463
github.com/go-logr/logr v1.4.3 // indirect
6564
github.com/go-logr/stdr v1.2.2 // indirect
6665
github.com/go-logr/zapr v1.3.0 // indirect
@@ -93,6 +92,7 @@ require (
9392
github.com/google/certificate-transparency-go v1.3.2 // indirect
9493
github.com/google/go-containerregistry v0.20.6 // indirect
9594
github.com/google/s2a-go v0.1.9 // indirect
95+
github.com/google/uuid v1.6.0 // indirect
9696
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
9797
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
9898
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
@@ -165,7 +165,7 @@ require (
165165
go.yaml.in/yaml/v3 v3.0.4 // indirect
166166
golang.org/x/crypto v0.42.0 // indirect
167167
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
168-
golang.org/x/mod v0.28.0 // indirect
168+
golang.org/x/mod v0.29.0 // indirect
169169
golang.org/x/net v0.43.0 // indirect
170170
golang.org/x/oauth2 v0.31.0 // indirect
171171
golang.org/x/sync v0.17.0 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
749749
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
750750
github.com/containerd/stargz-snapshotter/estargz v0.16.3 h1:7evrXtoh1mSbGj/pfRccTampEyKpjpOnS3CyiV1Ebr8=
751751
github.com/containerd/stargz-snapshotter/estargz v0.16.3/go.mod h1:uyr4BfYfOj3G9WBVE8cOlQmXAbPN9VEQpBBeJIuOipU=
752-
github.com/coreos/go-oidc/v3 v3.15.0 h1:R6Oz8Z4bqWR7VFQ+sPSvZPQv4x8M+sJkDO5ojgwlyAg=
753-
github.com/coreos/go-oidc/v3 v3.15.0/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
752+
github.com/coreos/go-oidc/v3 v3.16.0 h1:qRQUCFstKpXwmEjDQTIbyY/5jF00+asXzSkmkoa/mow=
753+
github.com/coreos/go-oidc/v3 v3.16.0/go.mod h1:wqPbKFrVnE90vty060SB40FCJ8fTHTxSwyXJqZH+sI8=
754754
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
755755
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
756756
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 h1:uX1JmpONuD549D73r6cgnxyUu18Zb7yHAy5AYU0Pm4Q=
@@ -828,8 +828,8 @@ github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmn
828828
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
829829
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
830830
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
831-
github.com/go-jose/go-jose/v4 v4.1.2 h1:TK/7NqRQZfgAh+Td8AlsrvtPoUyiHh0LqVvokh+1vHI=
832-
github.com/go-jose/go-jose/v4 v4.1.2/go.mod h1:22cg9HWM1pOlnRiY+9cQYJ9XHmya1bYW8OeDM6Ku6Oo=
831+
github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
832+
github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
833833
github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U=
834834
github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk=
835835
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -1070,8 +1070,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
10701070
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
10711071
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
10721072
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
1073-
github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs=
1074-
github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
1073+
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
1074+
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=
10751075
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
10761076
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
10771077
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b h1:ZGiXF8sz7PDk6RgkP+A/SFfUD0ZR/AgG6SpRNEDKZy8=
@@ -1131,8 +1131,8 @@ github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7z
11311131
github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko=
11321132
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
11331133
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
1134-
github.com/modelcontextprotocol/registry v1.0.0 h1:RxTSh2tC05Mlc3B2AzY/Oos1Fthuwe+OrK6a/17OCRE=
1135-
github.com/modelcontextprotocol/registry v1.0.0/go.mod h1:D6U1q6wYKYMA58q2gZz4eFsghr+fTkZQY8/ZFwTOT1Q=
1134+
github.com/modelcontextprotocol/registry v1.3.5 h1:M1ZTKPkxVICKlFBYio01/CkHbpjMcaGjLFF5M5QgZxc=
1135+
github.com/modelcontextprotocol/registry v1.3.5/go.mod h1:68KOBW2R5FX53BTrid2OFvPoCKEEYZk6z8LUa2ahLM0=
11361136
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
11371137
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
11381138
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
@@ -1434,8 +1434,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
14341434
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
14351435
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
14361436
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
1437-
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
1438-
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
1437+
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
1438+
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
14391439
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
14401440
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
14411441
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
package converters
2+
3+
import (
4+
"encoding/json"
5+
"os"
6+
"path/filepath"
7+
"testing"
8+
9+
upstream "github.com/modelcontextprotocol/registry/pkg/api/v0"
10+
"github.com/stacklok/toolhive/pkg/registry"
11+
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
13+
)
14+
15+
// TestConverters_Fixtures validates converter functions using JSON fixture files
16+
// This provides a clear, maintainable way to test conversions with real-world data
17+
func TestConverters_Fixtures(t *testing.T) {
18+
t.Parallel()
19+
20+
tests := []struct {
21+
name string
22+
fixtureDir string
23+
inputFile string
24+
expectedFile string
25+
serverName string
26+
convertFunc string // "ImageToServer", "ServerToImage", "RemoteToServer", "ServerToRemote"
27+
validateFunc func(t *testing.T, input, output []byte)
28+
}{
29+
{
30+
name: "ImageMetadata to ServerJSON - GitHub",
31+
fixtureDir: "testdata/image_to_server",
32+
inputFile: "input_github.json",
33+
expectedFile: "expected_github.json",
34+
serverName: "github",
35+
convertFunc: "ImageToServer",
36+
validateFunc: validateImageToServerConversion,
37+
},
38+
{
39+
name: "ServerJSON to ImageMetadata - GitHub",
40+
fixtureDir: "testdata/server_to_image",
41+
inputFile: "input_github.json",
42+
expectedFile: "expected_github.json",
43+
serverName: "",
44+
convertFunc: "ServerToImage",
45+
validateFunc: validateServerToImageConversion,
46+
},
47+
{
48+
name: "RemoteServerMetadata to ServerJSON - Example",
49+
fixtureDir: "testdata/remote_to_server",
50+
inputFile: "input_example.json",
51+
expectedFile: "expected_example.json",
52+
serverName: "example-remote",
53+
convertFunc: "RemoteToServer",
54+
validateFunc: validateRemoteToServerConversion,
55+
},
56+
{
57+
name: "ServerJSON to RemoteServerMetadata - Example",
58+
fixtureDir: "testdata/server_to_remote",
59+
inputFile: "input_example.json",
60+
expectedFile: "expected_example.json",
61+
serverName: "",
62+
convertFunc: "ServerToRemote",
63+
validateFunc: validateServerToRemoteConversion,
64+
},
65+
}
66+
67+
for _, tt := range tests {
68+
t.Run(tt.name, func(t *testing.T) {
69+
t.Parallel()
70+
71+
// Read input fixture
72+
inputPath := filepath.Join(tt.fixtureDir, tt.inputFile)
73+
inputData, err := os.ReadFile(inputPath)
74+
require.NoError(t, err, "Failed to read input fixture: %s", inputPath)
75+
76+
// Read expected output fixture
77+
expectedPath := filepath.Join(tt.fixtureDir, tt.expectedFile)
78+
expectedData, err := os.ReadFile(expectedPath)
79+
require.NoError(t, err, "Failed to read expected fixture: %s", expectedPath)
80+
81+
// Perform conversion based on type
82+
var actualData []byte
83+
switch tt.convertFunc {
84+
case "ImageToServer":
85+
actualData = convertImageToServer(t, inputData, tt.serverName)
86+
case "ServerToImage":
87+
actualData = convertServerToImage(t, inputData)
88+
case "RemoteToServer":
89+
actualData = convertRemoteToServer(t, inputData, tt.serverName)
90+
case "ServerToRemote":
91+
actualData = convertServerToRemote(t, inputData)
92+
default:
93+
t.Fatalf("Unknown conversion function: %s", tt.convertFunc)
94+
}
95+
96+
// Compare output with expected
97+
var expected, actual interface{}
98+
require.NoError(t, json.Unmarshal(expectedData, &expected), "Failed to parse expected JSON")
99+
require.NoError(t, json.Unmarshal(actualData, &actual), "Failed to parse actual JSON")
100+
101+
// Deep equal comparison
102+
assert.Equal(t, expected, actual, "Conversion output doesn't match expected fixture")
103+
104+
// Run additional validation if provided
105+
if tt.validateFunc != nil {
106+
tt.validateFunc(t, inputData, actualData)
107+
}
108+
})
109+
}
110+
}
111+
112+
// Helper functions for conversions
113+
114+
func convertImageToServer(t *testing.T, inputData []byte, serverName string) []byte {
115+
t.Helper()
116+
var imageMetadata registry.ImageMetadata
117+
require.NoError(t, json.Unmarshal(inputData, &imageMetadata))
118+
119+
serverJSON, err := ImageMetadataToServerJSON(serverName, &imageMetadata)
120+
require.NoError(t, err)
121+
122+
output, err := json.MarshalIndent(serverJSON, "", " ")
123+
require.NoError(t, err)
124+
return output
125+
}
126+
127+
func convertServerToImage(t *testing.T, inputData []byte) []byte {
128+
t.Helper()
129+
var serverJSON upstream.ServerJSON
130+
require.NoError(t, json.Unmarshal(inputData, &serverJSON))
131+
132+
imageMetadata, err := ServerJSONToImageMetadata(&serverJSON)
133+
require.NoError(t, err)
134+
135+
output, err := json.MarshalIndent(imageMetadata, "", " ")
136+
require.NoError(t, err)
137+
return output
138+
}
139+
140+
func convertRemoteToServer(t *testing.T, inputData []byte, serverName string) []byte {
141+
t.Helper()
142+
var remoteMetadata registry.RemoteServerMetadata
143+
require.NoError(t, json.Unmarshal(inputData, &remoteMetadata))
144+
145+
serverJSON, err := RemoteServerMetadataToServerJSON(serverName, &remoteMetadata)
146+
require.NoError(t, err)
147+
148+
output, err := json.MarshalIndent(serverJSON, "", " ")
149+
require.NoError(t, err)
150+
return output
151+
}
152+
153+
func convertServerToRemote(t *testing.T, inputData []byte) []byte {
154+
t.Helper()
155+
var serverJSON upstream.ServerJSON
156+
require.NoError(t, json.Unmarshal(inputData, &serverJSON))
157+
158+
remoteMetadata, err := ServerJSONToRemoteServerMetadata(&serverJSON)
159+
require.NoError(t, err)
160+
161+
output, err := json.MarshalIndent(remoteMetadata, "", " ")
162+
require.NoError(t, err)
163+
return output
164+
}
165+
166+
// Validation functions - additional checks beyond JSON equality
167+
168+
func validateImageToServerConversion(t *testing.T, inputData, outputData []byte) {
169+
t.Helper()
170+
var input registry.ImageMetadata
171+
var output upstream.ServerJSON
172+
173+
require.NoError(t, json.Unmarshal(inputData, &input))
174+
require.NoError(t, json.Unmarshal(outputData, &output))
175+
176+
// Verify core mappings
177+
assert.Equal(t, input.Description, output.Description, "Description should match")
178+
assert.Len(t, output.Packages, 1, "Should have exactly one package")
179+
assert.Equal(t, input.Image, output.Packages[0].Identifier, "Image identifier should match")
180+
assert.Equal(t, input.Transport, output.Packages[0].Transport.Type, "Transport type should match")
181+
182+
// Verify environment variables count
183+
assert.Len(t, output.Packages[0].EnvironmentVariables, len(input.EnvVars),
184+
"Environment variables count should match")
185+
186+
// Verify publisher extensions exist
187+
require.NotNil(t, output.Meta, "Meta should not be nil")
188+
require.NotNil(t, output.Meta.PublisherProvided, "PublisherProvided should not be nil")
189+
190+
stacklokData, ok := output.Meta.PublisherProvided["io.github.stacklok"].(map[string]interface{})
191+
require.True(t, ok, "Should have io.github.stacklok namespace")
192+
193+
extensions, ok := stacklokData[input.Image].(map[string]interface{})
194+
require.True(t, ok, "Should have image-specific extensions")
195+
196+
// Verify key extension fields
197+
assert.Equal(t, input.Status, extensions["status"], "Status should be in extensions")
198+
assert.Equal(t, input.Tier, extensions["tier"], "Tier should be in extensions")
199+
assert.NotNil(t, extensions["tools"], "Tools should be in extensions")
200+
assert.NotNil(t, extensions["tags"], "Tags should be in extensions")
201+
}
202+
203+
func validateServerToImageConversion(t *testing.T, inputData, outputData []byte) {
204+
t.Helper()
205+
var input upstream.ServerJSON
206+
var output registry.ImageMetadata
207+
208+
require.NoError(t, json.Unmarshal(inputData, &input))
209+
require.NoError(t, json.Unmarshal(outputData, &output))
210+
211+
// Verify core mappings
212+
assert.Equal(t, input.Description, output.Description, "Description should match")
213+
require.Len(t, input.Packages, 1, "Input should have exactly one package")
214+
assert.Equal(t, input.Packages[0].Identifier, output.Image, "Image identifier should match")
215+
assert.Equal(t, input.Packages[0].Transport.Type, output.Transport, "Transport type should match")
216+
217+
// Verify environment variables were extracted
218+
assert.Len(t, output.EnvVars, len(input.Packages[0].EnvironmentVariables),
219+
"Environment variables count should match")
220+
}
221+
222+
func validateRemoteToServerConversion(t *testing.T, inputData, outputData []byte) {
223+
t.Helper()
224+
var input registry.RemoteServerMetadata
225+
var output upstream.ServerJSON
226+
227+
require.NoError(t, json.Unmarshal(inputData, &input))
228+
require.NoError(t, json.Unmarshal(outputData, &output))
229+
230+
// Verify core mappings
231+
assert.Equal(t, input.Description, output.Description, "Description should match")
232+
require.Len(t, output.Remotes, 1, "Should have exactly one remote")
233+
assert.Equal(t, input.URL, output.Remotes[0].URL, "Remote URL should match")
234+
assert.Equal(t, input.Transport, output.Remotes[0].Type, "Transport type should match")
235+
236+
// Verify headers count
237+
assert.Len(t, output.Remotes[0].Headers, len(input.Headers),
238+
"Headers count should match")
239+
}
240+
241+
func validateServerToRemoteConversion(t *testing.T, inputData, outputData []byte) {
242+
t.Helper()
243+
var input upstream.ServerJSON
244+
var output registry.RemoteServerMetadata
245+
246+
require.NoError(t, json.Unmarshal(inputData, &input))
247+
require.NoError(t, json.Unmarshal(outputData, &output))
248+
249+
// Verify core mappings
250+
assert.Equal(t, input.Description, output.Description, "Description should match")
251+
require.Len(t, input.Remotes, 1, "Input should have exactly one remote")
252+
assert.Equal(t, input.Remotes[0].URL, output.URL, "Remote URL should match")
253+
assert.Equal(t, input.Remotes[0].Type, output.Transport, "Transport type should match")
254+
255+
// Verify headers were extracted
256+
assert.Len(t, output.Headers, len(input.Remotes[0].Headers),
257+
"Headers count should match")
258+
}

0 commit comments

Comments
 (0)