Enforce schema validation on the publish and edit API level (#598)

<!-- Provide a brief summary of your changes -->

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
The following PR:
* Enforces schema validation on the API level (requests without schema
or older schema will fail)
* Updates the unit tests and examples to match that

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
**Note this can be considered breaking if clients have not included it
before.**

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [ ] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [ ] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->

---------

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
This commit is contained in:
Radoslav Dimitrov 2025-10-05 15:57:10 +03:00 • committed by GitHub
commit 44950c23bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 244 additions and 21 deletions

View file

@ -53,6 +53,16 @@ var (
)
func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error {
// Validate schema version is provided and supported
// Note: Schema field is also marked as required in the ServerJSON struct definition
// for API-level validation and documentation
if serverJSON.Schema == "" {
return fmt.Errorf("$schema field is required")
}
if !strings.Contains(serverJSON.Schema, model.CurrentSchemaVersion) {
return fmt.Errorf("schema version %s is not supported. Please use schema version %s", serverJSON.Schema, model.CurrentSchemaVersion)
}
// Validate server name exists and format
if _, err := parseServerName(*serverJSON); err != nil {
return err

View file

@ -19,9 +19,51 @@ func TestValidate(t *testing.T) {
serverDetail apiv0.ServerJSON
expectedError string
}{
{
name: "Schema version is required",
serverDetail: apiv0.ServerJSON{
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
URL: "https://github.com/owner/repo",
Source: "github",
},
Version: "1.0.0",
},
expectedError: "$schema field is required",
},
{
name: "Schema version rejects old schema (2025-01-27)",
serverDetail: apiv0.ServerJSON{
Schema: "https://static.modelcontextprotocol.io/schemas/2025-01-27/server.schema.json",
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
URL: "https://github.com/owner/repo",
Source: "github",
},
Version: "1.0.0",
},
expectedError: "schema version https://static.modelcontextprotocol.io/schemas/2025-01-27/server.schema.json is not supported",
},
{
name: "Schema version accepts current schema (2025-09-29)",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
URL: "https://github.com/owner/repo",
Source: "github",
},
Version: "1.0.0",
},
expectedError: "",
},
{
name: "Version rejects top-level version ranges",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -35,6 +77,7 @@ func TestValidate(t *testing.T) {
{
name: "rejects package version ranges",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -56,6 +99,7 @@ func TestValidate(t *testing.T) {
{
name: "Version allows specific versions (semver)",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -77,6 +121,7 @@ func TestValidate(t *testing.T) {
{
name: "Version allows specific non-semver versions",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -98,6 +143,7 @@ func TestValidate(t *testing.T) {
{
name: "Version rejects wildcard and x-range",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -111,6 +157,7 @@ func TestValidate(t *testing.T) {
{
name: "Version rejects wildcard *",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -124,6 +171,7 @@ func TestValidate(t *testing.T) {
{
name: "Version allows freeform version with hyphen not a range",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -137,6 +185,7 @@ func TestValidate(t *testing.T) {
{
name: "Version rejects hyphen range of two versions",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -150,6 +199,7 @@ func TestValidate(t *testing.T) {
{
name: "Version rejects OR range with two versions",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -163,6 +213,7 @@ func TestValidate(t *testing.T) {
{
name: "Version rejects comparator with space",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -177,6 +228,7 @@ func TestValidate(t *testing.T) {
{
name: "server name with two slashes",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/server/path",
Description: "A test server",
Version: "1.0.0",
@ -186,6 +238,7 @@ func TestValidate(t *testing.T) {
{
name: "server name with three slashes",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/server/path/deep",
Description: "A test server",
Version: "1.0.0",
@ -195,6 +248,7 @@ func TestValidate(t *testing.T) {
{
name: "valid server detail with all fields",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -226,6 +280,7 @@ func TestValidate(t *testing.T) {
{
name: "server with invalid repository source",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -239,6 +294,7 @@ func TestValidate(t *testing.T) {
{
name: "server with invalid GitHub URL format",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -252,6 +308,7 @@ func TestValidate(t *testing.T) {
{
name: "server with invalid GitLab URL format",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -265,6 +322,7 @@ func TestValidate(t *testing.T) {
{
name: "server with valid repository subfolder",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -279,6 +337,7 @@ func TestValidate(t *testing.T) {
{
name: "server with repository subfolder containing path traversal",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -293,6 +352,7 @@ func TestValidate(t *testing.T) {
{
name: "server with repository subfolder starting with slash",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -307,6 +367,7 @@ func TestValidate(t *testing.T) {
{
name: "server with repository subfolder ending with slash",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -321,6 +382,7 @@ func TestValidate(t *testing.T) {
{
name: "server with repository subfolder containing invalid characters",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -335,6 +397,7 @@ func TestValidate(t *testing.T) {
{
name: "server with repository subfolder containing empty segments",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -349,6 +412,7 @@ func TestValidate(t *testing.T) {
{
name: "server with valid websiteUrl",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -363,6 +427,7 @@ func TestValidate(t *testing.T) {
{
name: "server with invalid websiteUrl - no scheme",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -377,6 +442,7 @@ func TestValidate(t *testing.T) {
{
name: "server with invalid websiteUrl - invalid scheme",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -391,6 +457,7 @@ func TestValidate(t *testing.T) {
{
name: "server with malformed websiteUrl",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -405,6 +472,7 @@ func TestValidate(t *testing.T) {
{
name: "server with websiteUrl that matches namespace domain",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -419,6 +487,7 @@ func TestValidate(t *testing.T) {
{
name: "server with websiteUrl subdomain that matches namespace",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -433,6 +502,7 @@ func TestValidate(t *testing.T) {
{
name: "server with websiteUrl that does not match namespace",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -447,6 +517,7 @@ func TestValidate(t *testing.T) {
{
name: "package with spaces in name",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -470,6 +541,7 @@ func TestValidate(t *testing.T) {
{
name: "package with reserved version 'latest'",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -494,6 +566,7 @@ func TestValidate(t *testing.T) {
{
name: "multiple packages with one invalid",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -525,6 +598,7 @@ func TestValidate(t *testing.T) {
{
name: "remote with invalid URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -544,6 +618,7 @@ func TestValidate(t *testing.T) {
{
name: "remote with missing scheme",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -563,6 +638,7 @@ func TestValidate(t *testing.T) {
{
name: "remote with localhost url",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -582,6 +658,7 @@ func TestValidate(t *testing.T) {
{
name: "remote with localhost url with port",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -601,6 +678,7 @@ func TestValidate(t *testing.T) {
{
name: "multiple remotes with one invalid",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -624,6 +702,7 @@ func TestValidate(t *testing.T) {
{
name: "server detail with nil packages and remotes",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -639,6 +718,7 @@ func TestValidate(t *testing.T) {
{
name: "server detail with empty packages and remotes slices",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{
@ -677,7 +757,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "valid match - example.com domain",
serverDetail: apiv0.ServerJSON{
Name: "com.example/test-server",
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -690,7 +771,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "valid match - subdomain mcp.example.com",
serverDetail: apiv0.ServerJSON{
Name: "com.example/test-server",
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -703,7 +785,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "valid match - api subdomain",
serverDetail: apiv0.ServerJSON{
Name: "com.example/api-server",
Schema: model.CurrentSchemaURL,
Name: "com.example/api-server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -716,7 +799,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "invalid - wrong domain",
serverDetail: apiv0.ServerJSON{
Name: "com.example/test-server",
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -730,7 +814,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "invalid - different domain entirely",
serverDetail: apiv0.ServerJSON{
Name: "com.microsoft/server",
Schema: model.CurrentSchemaURL,
Name: "com.microsoft/server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -744,7 +829,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "invalid URL format",
serverDetail: apiv0.ServerJSON{
Name: "com.example/test",
Schema: model.CurrentSchemaURL,
Name: "com.example/test",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -758,6 +844,7 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "empty remotes array",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test",
Remotes: []model.Transport{},
},
@ -766,7 +853,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "multiple valid remotes - different subdomains",
serverDetail: apiv0.ServerJSON{
Name: "com.example/server",
Schema: model.CurrentSchemaURL,
Name: "com.example/server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -783,7 +871,8 @@ func TestValidate_RemoteNamespaceMatch(t *testing.T) {
{
name: "one valid, one invalid remote",
serverDetail: apiv0.ServerJSON{
Name: "com.example/server",
Schema: model.CurrentSchemaURL,
Name: "com.example/server",
Remotes: []model.Transport{
{
Type: "streamable-http",
@ -824,21 +913,24 @@ func TestValidate_ServerNameFormat(t *testing.T) {
{
name: "valid namespace/name format",
serverDetail: apiv0.ServerJSON{
Name: "com.example.api/server",
Schema: model.CurrentSchemaURL,
Name: "com.example.api/server",
},
expectError: false,
},
{
name: "valid complex namespace",
serverDetail: apiv0.ServerJSON{
Name: "com.microsoft.azure.service/webapp-server",
Schema: model.CurrentSchemaURL,
Name: "com.microsoft.azure.service/webapp-server",
},
expectError: false,
},
{
name: "empty server name",
serverDetail: apiv0.ServerJSON{
Name: "",
Schema: model.CurrentSchemaURL,
Name: "",
},
expectError: true,
errorMsg: "server name is required",
@ -846,7 +938,8 @@ func TestValidate_ServerNameFormat(t *testing.T) {
{
name: "missing slash separator",
serverDetail: apiv0.ServerJSON{
Name: "com.example.server",
Schema: model.CurrentSchemaURL,
Name: "com.example.server",
},
expectError: true,
errorMsg: "server name must be in format 'dns-namespace/name'",
@ -854,7 +947,8 @@ func TestValidate_ServerNameFormat(t *testing.T) {
{
name: "empty namespace part",
serverDetail: apiv0.ServerJSON{
Name: "/server-name",
Schema: model.CurrentSchemaURL,
Name: "/server-name",
},
expectError: true,
errorMsg: "non-empty namespace and name parts",
@ -862,7 +956,8 @@ func TestValidate_ServerNameFormat(t *testing.T) {
{
name: "empty name part",
serverDetail: apiv0.ServerJSON{
Name: "com.example/",
Schema: model.CurrentSchemaURL,
Name: "com.example/",
},
expectError: true,
errorMsg: "non-empty namespace and name parts",
@ -870,7 +965,8 @@ func TestValidate_ServerNameFormat(t *testing.T) {
{
name: "multiple slashes - should be rejected",
serverDetail: apiv0.ServerJSON{
Name: "com.example/server/path",
Schema: model.CurrentSchemaURL,
Name: "com.example/server/path",
},
expectError: true,
errorMsg: "server name cannot contain multiple slashes",
@ -955,7 +1051,8 @@ func TestValidate_MultipleSlashesInServerName(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
serverDetail := apiv0.ServerJSON{
Name: tt.serverName,
Schema: model.CurrentSchemaURL,
Name: tt.serverName,
}
err := validators.ValidateServerJSON(&serverDetail)
@ -1173,6 +1270,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport stdio without URL should pass",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1191,6 +1289,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport stdio with URL (should fail)",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1211,6 +1310,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport streamable-http with valid URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1230,6 +1330,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport streamable-http with templated URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1253,6 +1354,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport streamable-http without URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1271,6 +1373,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport streamable-http with templated URL missing variables",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1292,6 +1395,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport sse with valid URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1311,6 +1415,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport sse without URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1330,6 +1435,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport unsupported type",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1349,6 +1455,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport streamable-http with valid URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1364,6 +1471,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport streamable-http without URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1379,6 +1487,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport sse with valid URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1394,6 +1503,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport sse without URL",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1409,6 +1519,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport stdio not supported",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1423,6 +1534,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport unsupported type",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1439,6 +1551,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "package transport allows localhost URLs",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1458,6 +1571,7 @@ func TestValidate_TransportValidation(t *testing.T) {
{
name: "remote transport rejects localhost URLs",
serverDetail: apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
@ -1530,6 +1644,7 @@ func TestValidate_RegistryTypesAndUrls(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.tcName, func(t *testing.T) {
serverJSON := apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: tc.name,
Description: "A test server",
Repository: model.Repository{
@ -1566,6 +1681,7 @@ func TestValidate_RegistryTypesAndUrls(t *testing.T) {
func createValidServerWithArgument(arg model.Argument) apiv0.ServerJSON {
return apiv0.ServerJSON{
Schema: model.CurrentSchemaURL,
Name: "com.example/test-server",
Description: "A test server",
Repository: model.Repository{