Clean up schema by simplifying version structure (#379)
## Summary Simplified the schema structure by: - Replacing `version_detail.version` with direct `version` field - Removing unused `release_date` field from seed data - Updating all API types, models, and tests to match new structure - Maintaining backwards compatibility in API responses This change makes the schema more intuitive and reduces nesting depth.
This commit is contained in:
parent
f51c187e52
commit
f975e68cf2
26 changed files with 540 additions and 1973 deletions
|
|
@ -309,9 +309,7 @@ func createServerJSON(
|
||||||
URL: repoURL,
|
URL: repoURL,
|
||||||
Source: repoSource,
|
Source: repoSource,
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: version,
|
||||||
Version: version,
|
|
||||||
},
|
|
||||||
Packages: []model.Package{pkg},
|
Packages: []model.Package{pkg},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1980
data/seed.json
1980
data/seed.json
File diff suppressed because it is too large
Load diff
|
|
@ -19,9 +19,7 @@ Server authors SHOULD use [semantic versions](https://semver.org/) following the
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3"
|
||||||
"version": "1.2.3"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -30,9 +28,7 @@ Server authors SHOULD use versions aligned with their underlying packages to red
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3",
|
||||||
"version": "1.2.3"
|
|
||||||
},
|
|
||||||
"packages": [{
|
"packages": [{
|
||||||
"registry_name": "npm",
|
"registry_name": "npm",
|
||||||
"name": "@myorg/my-server",
|
"name": "@myorg/my-server",
|
||||||
|
|
@ -46,9 +42,7 @@ If server authors expect to have multiple registry versions for the same package
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3-1",
|
||||||
"version": "1.2.3-1"
|
|
||||||
},
|
|
||||||
"packages": [{
|
"packages": [{
|
||||||
"registry_name": "npm",
|
"registry_name": "npm",
|
||||||
"name": "@myorg/my-server",
|
"name": "@myorg/my-server",
|
||||||
|
|
@ -111,9 +105,7 @@ Registry clients SHOULD:
|
||||||
### Alignment Examples
|
### Alignment Examples
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3-1",
|
||||||
"version": "1.2.3-1"
|
|
||||||
},
|
|
||||||
"packages": [{
|
"packages": [{
|
||||||
"registry_name": "npm",
|
"registry_name": "npm",
|
||||||
"name": "@myorg/k8s-server",
|
"name": "@myorg/k8s-server",
|
||||||
|
|
@ -136,9 +128,7 @@ Existing servers with non-semantic versions will continue to work without change
|
||||||
**Package and server versions aligned**:
|
**Package and server versions aligned**:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3",
|
||||||
"version": "1.2.3"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -153,9 +143,7 @@ Existing servers with non-semantic versions will continue to work without change
|
||||||
**Server metadata changes without package updates**:
|
**Server metadata changes without package updates**:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.2.3-1",
|
||||||
"version": "1.2.3-1"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -172,9 +160,7 @@ Note: `1.2.3-1` is considered lower than `1.2.3` in semver ordering. Publish pre
|
||||||
**Remote servers without package dependencies**:
|
**Remote servers without package dependencies**:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "2.1.0",
|
||||||
"version": "2.1.0"
|
|
||||||
},
|
|
||||||
"remotes": [
|
"remotes": [
|
||||||
{
|
{
|
||||||
"transport_type": "sse",
|
"transport_type": "sse",
|
||||||
|
|
@ -193,9 +179,7 @@ Version strategy options:
|
||||||
**Different package versions**:
|
**Different package versions**:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version_detail": {
|
"version": "1.3.0",
|
||||||
"version": "1.3.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,7 @@ You can also add custom metadata to servers using the `_meta` field. For example
|
||||||
"name": "io.github.yourname/weather-server",
|
"name": "io.github.yourname/weather-server",
|
||||||
"description": "MCP server for weather data access",
|
"description": "MCP server for weather data access",
|
||||||
"status": "active",
|
"status": "active",
|
||||||
"version_detail": {
|
"version": "1.0.0",
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ Keep your package version and server.json version in sync:
|
||||||
- name: Update server.json version
|
- name: Update server.json version
|
||||||
run: |
|
run: |
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
jq --arg version "$VERSION" '.version_detail.version = $version' server.json > tmp.json
|
jq --arg version "$VERSION" '.version = $version' server.json > tmp.json
|
||||||
mv tmp.json server.json
|
mv tmp.json server.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,7 @@ This creates a `server.json` with auto-detected values. You'll see something lik
|
||||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
|
||||||
"name": "io.github.yourname/your-server",
|
"name": "io.github.yourname/your-server",
|
||||||
"description": "A description of your MCP server",
|
"description": "A description of your MCP server",
|
||||||
"version_detail": {
|
"version": "1.0.0",
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,7 @@ curl https://registry.example.com/v0/servers?limit=10
|
||||||
"name": "io.modelcontextprotocol/filesystem",
|
"name": "io.modelcontextprotocol/filesystem",
|
||||||
"description": "Filesystem operations server",
|
"description": "Filesystem operations server",
|
||||||
"status": "active",
|
"status": "active",
|
||||||
"version_detail": {
|
"version": "1.0.2"
|
||||||
"version": "1.0.2",
|
|
||||||
"is_latest": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,7 @@ paths:
|
||||||
repository:
|
repository:
|
||||||
url: "https://github.com/modelcontextprotocol/servers"
|
url: "https://github.com/modelcontextprotocol/servers"
|
||||||
source: "github"
|
source: "github"
|
||||||
version_detail:
|
version: "1.0.2"
|
||||||
version: "1.0.2"
|
|
||||||
packages:
|
packages:
|
||||||
- registry_type: "npm"
|
- registry_type: "npm"
|
||||||
registry_base_url: "https://registry.npmjs.org"
|
registry_base_url: "https://registry.npmjs.org"
|
||||||
|
|
@ -120,8 +119,7 @@ paths:
|
||||||
repository:
|
repository:
|
||||||
url: "https://github.com/example/mcp-demo"
|
url: "https://github.com/example/mcp-demo"
|
||||||
source: "github"
|
source: "github"
|
||||||
version_detail:
|
version: "1.0.0"
|
||||||
version: "1.0.0"
|
|
||||||
packages:
|
packages:
|
||||||
- registry_type: "npm"
|
- registry_type: "npm"
|
||||||
registry_base_url: "https://registry.npmjs.org"
|
registry_base_url: "https://registry.npmjs.org"
|
||||||
|
|
@ -213,7 +211,7 @@ components:
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- description
|
- description
|
||||||
- version_detail
|
- version
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -231,8 +229,10 @@ components:
|
||||||
example: "active"
|
example: "active"
|
||||||
repository:
|
repository:
|
||||||
$ref: '#/components/schemas/Repository'
|
$ref: '#/components/schemas/Repository'
|
||||||
version_detail:
|
version:
|
||||||
$ref: '#/components/schemas/VersionDetail'
|
type: string
|
||||||
|
example: "1.0.2"
|
||||||
|
description: "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification."
|
||||||
created_at:
|
created_at:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|
@ -240,26 +240,6 @@ components:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|
||||||
VersionDetail:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- version
|
|
||||||
- release_date
|
|
||||||
- is_latest
|
|
||||||
properties:
|
|
||||||
version:
|
|
||||||
type: string
|
|
||||||
example: "1.0.2"
|
|
||||||
description: Equivalent of Implementation.version in MCP specification.
|
|
||||||
release_date:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
example: "2023-06-15T10:30:00Z"
|
|
||||||
description: Datetime that the MCP server version was published to the registry.
|
|
||||||
is_latest:
|
|
||||||
type: boolean
|
|
||||||
example: true
|
|
||||||
description: Whether the MCP server version is the latest version available in the registry.
|
|
||||||
|
|
||||||
ServerList:
|
ServerList:
|
||||||
type: object
|
type: object
|
||||||
|
|
@ -535,10 +515,5 @@ components:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Whether this is the latest version of the server
|
description: Whether this is the latest version of the server
|
||||||
example: true
|
example: true
|
||||||
release_date:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
description: Release date of the server version
|
|
||||||
example: "2023-12-01T10:30:00Z"
|
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
additionalProperties: true
|
additionalProperties: true
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ mcp-publisher init [options]
|
||||||
{
|
{
|
||||||
"name": "io.github.username/server-name",
|
"name": "io.github.username/server-name",
|
||||||
"description": "TODO: Add server description",
|
"description": "TODO: Add server description",
|
||||||
"version_detail": { "version": "1.0.0" },
|
"version": "1.0.0",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@ The official registry has some more restrictions on top of this. See the [offici
|
||||||
"url": "https://github.com/modelcontextprotocol/servers",
|
"url": "https://github.com/modelcontextprotocol/servers",
|
||||||
"source": "github"
|
"source": "github"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "1.0.2",
|
||||||
"version": "1.0.2"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -79,9 +77,7 @@ For MCP servers located within a subdirectory of a larger repository (monorepo s
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"subfolder": "src/everything"
|
"subfolder": "src/everything"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "0.6.2",
|
||||||
"version": "0.6.2"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -113,9 +109,7 @@ Suppose your MCP server application requires a `mcp start` CLI arguments to star
|
||||||
{
|
{
|
||||||
"name": "io.github.joelverhagen/knapcode-samplemcpserver",
|
"name": "io.github.joelverhagen/knapcode-samplemcpserver",
|
||||||
"description": "Sample NuGet MCP server for a random number and random weather",
|
"description": "Sample NuGet MCP server for a random number and random weather",
|
||||||
"version_detail": {
|
"version": "0.4.0-beta",
|
||||||
"version": "0.4.0-beta"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "nuget",
|
"registry_type": "nuget",
|
||||||
|
|
@ -165,9 +159,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "b94b5f7e-c7c6-d760-2c78-a5e9b8a5b8c9"
|
"id": "b94b5f7e-c7c6-d760-2c78-a5e9b8a5b8c9"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "1.0.2",
|
||||||
"version": "1.0.2"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -267,9 +259,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "xyz789ab-cdef-0123-4567-890ghijklmno"
|
"id": "xyz789ab-cdef-0123-4567-890ghijklmno"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "2.0.0",
|
||||||
"version": "2.0.0"
|
|
||||||
},
|
|
||||||
"remotes": [
|
"remotes": [
|
||||||
{
|
{
|
||||||
"type": "sse",
|
"type": "sse",
|
||||||
|
|
@ -302,9 +292,7 @@ This will essentially instruct the MCP client to execute `dnx Knapcode.SampleMcp
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "def456gh-ijkl-7890-mnop-qrstuvwxyz12"
|
"id": "def456gh-ijkl-7890-mnop-qrstuvwxyz12"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "0.5.0",
|
||||||
"version": "0.5.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "pypi",
|
"registry_type": "pypi",
|
||||||
|
|
@ -358,9 +346,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "example-nuget-id-0000-1111-222222222222"
|
"id": "example-nuget-id-0000-1111-222222222222"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "0.5.0",
|
||||||
"version": "0.5.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "nuget",
|
"registry_type": "nuget",
|
||||||
|
|
@ -408,9 +394,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "ghi789jk-lmno-1234-pqrs-tuvwxyz56789"
|
"id": "ghi789jk-lmno-1234-pqrs-tuvwxyz56789"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "3.1.0",
|
||||||
"version": "3.1.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "oci",
|
"registry_type": "oci",
|
||||||
|
|
@ -521,9 +505,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "klm012no-pqrs-3456-tuvw-xyz789abcdef"
|
"id": "klm012no-pqrs-3456-tuvw-xyz789abcdef"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "1.5.0",
|
||||||
"version": "1.5.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -606,9 +588,7 @@ The `dnx` tool ships with the .NET 10 SDK, starting with Preview 6.
|
||||||
"url": "https://github.com/modelcontextprotocol/text-editor-mcpb",
|
"url": "https://github.com/modelcontextprotocol/text-editor-mcpb",
|
||||||
"source": "github"
|
"source": "github"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "1.0.2",
|
||||||
"version": "1.0.2"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "mcpb",
|
"registry_type": "mcpb",
|
||||||
|
|
@ -649,9 +629,7 @@ Some CLI tools bundle an MCP server, without a standalone MCP package or a publi
|
||||||
"name": "io.snyk/cli-mcp",
|
"name": "io.snyk/cli-mcp",
|
||||||
"description": "MCP server provided by the Snyk CLI",
|
"description": "MCP server provided by the Snyk CLI",
|
||||||
"status": "active",
|
"status": "active",
|
||||||
"version_detail": {
|
"version": "1.1298.0",
|
||||||
"version": "1.1298.0"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
@ -688,9 +666,7 @@ Some CLI tools bundle an MCP server, without a standalone MCP package or a publi
|
||||||
"source": "github",
|
"source": "github",
|
||||||
"id": "legacy-abc123-def456-789012-345678-901234567890"
|
"id": "legacy-abc123-def456-789012-345678-901234567890"
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": "0.9.5",
|
||||||
"version": "0.9.5"
|
|
||||||
},
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"registry_type": "npm",
|
"registry_type": "npm",
|
||||||
|
|
|
||||||
|
|
@ -35,27 +35,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"VersionDetail": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "Version information for this server. Defined as an object to allow for downstream extensibility (e.g. release_date)",
|
|
||||||
"required": [
|
|
||||||
"version"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"version": {
|
|
||||||
"type": "string",
|
|
||||||
"maxLength": 255,
|
|
||||||
"example": "1.0.2",
|
|
||||||
"description": "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification. Non-semantic versions are allowed but may not sort predictably."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Server": {
|
"Server": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
"version_detail"
|
"version"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
|
|
@ -83,8 +68,11 @@
|
||||||
"$ref": "#/$defs/Repository",
|
"$ref": "#/$defs/Repository",
|
||||||
"description": "Optional repository metadata for the MCP server source code. Recommended for transparency and security inspection."
|
"description": "Optional repository metadata for the MCP server source code. Recommended for transparency and security inspection."
|
||||||
},
|
},
|
||||||
"version_detail": {
|
"version": {
|
||||||
"$ref": "#/$defs/VersionDetail"
|
"type": "string",
|
||||||
|
"maxLength": 255,
|
||||||
|
"example": "1.0.2",
|
||||||
|
"description": "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification. Non-semantic versions are allowed but may not sort predictably."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "domdomegg/test-server",
|
ID: "domdomegg/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
published, err := registryService.Publish(testServer)
|
published, err := registryService.Publish(testServer)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
@ -56,9 +54,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "other/test-server",
|
ID: "other/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
otherPublished, err := registryService.Publish(otherServer)
|
otherPublished, err := registryService.Publish(otherServer)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
@ -78,9 +74,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "domdomegg/deleted-server",
|
ID: "domdomegg/deleted-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
deletedPublished, err := registryService.Publish(deletedServer)
|
deletedPublished, err := registryService.Publish(deletedServer)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
@ -120,9 +114,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "domdomegg/test-server",
|
ID: "domdomegg/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.1",
|
||||||
Version: "1.0.1",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
serverID: testServerID,
|
serverID: testServerID,
|
||||||
expectedStatus: http.StatusOK,
|
expectedStatus: http.StatusOK,
|
||||||
|
|
@ -141,7 +133,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/test-server",
|
Name: "io.github.domdomegg/test-server",
|
||||||
Description: "Test server",
|
Description: "Test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: testServerID,
|
serverID: testServerID,
|
||||||
expectedStatus: http.StatusUnauthorized,
|
expectedStatus: http.StatusUnauthorized,
|
||||||
|
|
@ -153,7 +145,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/test-server",
|
Name: "io.github.domdomegg/test-server",
|
||||||
Description: "Test server",
|
Description: "Test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: testServerID,
|
serverID: testServerID,
|
||||||
expectedStatus: http.StatusUnauthorized,
|
expectedStatus: http.StatusUnauthorized,
|
||||||
|
|
@ -175,7 +167,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/test-server",
|
Name: "io.github.domdomegg/test-server",
|
||||||
Description: "Updated test server",
|
Description: "Updated test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: testServerID,
|
serverID: testServerID,
|
||||||
expectedStatus: http.StatusForbidden,
|
expectedStatus: http.StatusForbidden,
|
||||||
|
|
@ -197,7 +189,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.other/test-server",
|
Name: "io.github.other/test-server",
|
||||||
Description: "Updated test server",
|
Description: "Updated test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: otherServerID,
|
serverID: otherServerID,
|
||||||
expectedStatus: http.StatusForbidden,
|
expectedStatus: http.StatusForbidden,
|
||||||
|
|
@ -219,7 +211,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/nonexistent-server",
|
Name: "io.github.domdomegg/nonexistent-server",
|
||||||
Description: "Updated test server",
|
Description: "Updated test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: "550e8400-e29b-41d4-a716-446655440999", // Non-existent ID
|
serverID: "550e8400-e29b-41d4-a716-446655440999", // Non-existent ID
|
||||||
expectedStatus: http.StatusNotFound,
|
expectedStatus: http.StatusNotFound,
|
||||||
|
|
@ -241,7 +233,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "invalid-name-format", // Missing namespace/name format
|
Name: "invalid-name-format", // Missing namespace/name format
|
||||||
Description: "Test server",
|
Description: "Test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
serverID: testServerID,
|
serverID: testServerID,
|
||||||
expectedStatus: http.StatusBadRequest,
|
expectedStatus: http.StatusBadRequest,
|
||||||
|
|
@ -269,9 +261,7 @@ func TestEditServerEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "domdomegg/deleted-server",
|
ID: "domdomegg/deleted-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.1",
|
||||||
Version: "1.0.1",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
serverID: deletedServerID,
|
serverID: deletedServerID,
|
||||||
expectedStatus: http.StatusBadRequest,
|
expectedStatus: http.StatusBadRequest,
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "testuser/test-mcp-server",
|
ID: "testuser/test-mcp-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate valid JWT token
|
// Generate valid JWT token
|
||||||
|
|
@ -97,7 +95,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, publishReq.Name, response.Name)
|
assert.Equal(t, publishReq.Name, response.Name)
|
||||||
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
|
assert.Equal(t, publishReq.Version, response.Version)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("successful publish with none auth (no prefix)", func(t *testing.T) {
|
t.Run("successful publish with none auth (no prefix)", func(t *testing.T) {
|
||||||
|
|
@ -109,9 +107,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server",
|
ID: "example/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate valid JWT token with wildcard permission
|
// Generate valid JWT token with wildcard permission
|
||||||
|
|
@ -166,7 +162,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/test-server",
|
Name: "io.github.domdomegg/test-server",
|
||||||
Description: "Test server",
|
Description: "Test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := json.Marshal(publishReq)
|
body, err := json.Marshal(publishReq)
|
||||||
|
|
@ -187,9 +183,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "io.github.other/test-server",
|
Name: "io.github.other/test-server",
|
||||||
Description: "A test server",
|
Description: "A test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Repository: model.Repository{
|
Repository: model.Repository{
|
||||||
URL: "https://github.com/example/test-server",
|
URL: "https://github.com/example/test-server",
|
||||||
Source: "github",
|
Source: "github",
|
||||||
|
|
@ -225,9 +219,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/airtable-mcp-server",
|
Name: "io.github.domdomegg/airtable-mcp-server",
|
||||||
Description: "A test server with MCPB package",
|
Description: "A test server with MCPB package",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.7.2",
|
||||||
Version: "1.7.2",
|
|
||||||
},
|
|
||||||
Status: model.StatusActive,
|
Status: model.StatusActive,
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
|
|
@ -269,7 +261,7 @@ func TestPublishIntegration(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, publishReq.Name, response.Name)
|
assert.Equal(t, publishReq.Name, response.Name)
|
||||||
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
|
assert.Equal(t, publishReq.Version, response.Version)
|
||||||
assert.Len(t, response.Packages, 1)
|
assert.Len(t, response.Packages, 1)
|
||||||
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
|
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,7 @@ func TestPublishRegistryValidation(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-with-npm",
|
Name: "com.example/test-server-with-npm",
|
||||||
Description: "A test server with invalid npm package reference",
|
Description: "A test server with invalid npm package reference",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
RegistryType: model.RegistryTypeNPM,
|
RegistryType: model.RegistryTypeNPM,
|
||||||
|
|
@ -90,9 +88,7 @@ func TestPublishRegistryValidation(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-mcpb-validation",
|
Name: "com.example/test-server-mcpb-validation",
|
||||||
Description: "A test server with MCPB package and registry validation enabled",
|
Description: "A test server with MCPB package and registry validation enabled",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "0.0.36",
|
||||||
Version: "0.0.36",
|
|
||||||
},
|
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
RegistryType: model.RegistryTypeMCPB,
|
RegistryType: model.RegistryTypeMCPB,
|
||||||
|
|
@ -133,7 +129,7 @@ func TestPublishRegistryValidation(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, publishReq.Name, response.Name)
|
assert.Equal(t, publishReq.Name, response.Name)
|
||||||
assert.Equal(t, publishReq.VersionDetail.Version, response.VersionDetail.Version)
|
assert.Equal(t, publishReq.Version, response.Version)
|
||||||
assert.Len(t, response.Packages, 1)
|
assert.Len(t, response.Packages, 1)
|
||||||
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
|
assert.Equal(t, model.RegistryTypeMCPB, response.Packages[0].RegistryType)
|
||||||
})
|
})
|
||||||
|
|
@ -142,9 +138,7 @@ func TestPublishRegistryValidation(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-multiple-packages",
|
Name: "com.example/test-server-multiple-packages",
|
||||||
Description: "A test server with multiple packages where second fails",
|
Description: "A test server with multiple packages where second fails",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
RegistryType: model.RegistryTypeMCPB,
|
RegistryType: model.RegistryTypeMCPB,
|
||||||
|
|
@ -195,9 +189,7 @@ func TestPublishRegistryValidation(t *testing.T) {
|
||||||
publishReq := apiv0.ServerJSON{
|
publishReq := apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-first-package-fails",
|
Name: "com.example/test-server-first-package-fails",
|
||||||
Description: "A test server where first package fails",
|
Description: "A test server where first package fails",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
RegistryType: model.RegistryTypeNPM,
|
RegistryType: model.RegistryTypeNPM,
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server",
|
ID: "example/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
tokenClaims: &auth.JWTClaims{
|
tokenClaims: &auth.JWTClaims{
|
||||||
AuthMethod: auth.MethodGitHubAT,
|
AuthMethod: auth.MethodGitHubAT,
|
||||||
|
|
@ -89,9 +87,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server",
|
ID: "example/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
tokenClaims: &auth.JWTClaims{
|
tokenClaims: &auth.JWTClaims{
|
||||||
AuthMethod: auth.MethodNone,
|
AuthMethod: auth.MethodNone,
|
||||||
|
|
@ -119,7 +115,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.domdomegg/test-server",
|
Name: "io.github.domdomegg/test-server",
|
||||||
Description: "Test server",
|
Description: "Test server",
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
},
|
},
|
||||||
authHeader: "InvalidFormat",
|
authHeader: "InvalidFormat",
|
||||||
setupRegistryService: func(_ service.RegistryService) {
|
setupRegistryService: func(_ service.RegistryService) {
|
||||||
|
|
@ -133,9 +129,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "test-server",
|
Name: "test-server",
|
||||||
Description: "A test server",
|
Description: "A test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
authHeader: "Bearer invalidToken",
|
authHeader: "Bearer invalidToken",
|
||||||
setupRegistryService: func(_ service.RegistryService) {
|
setupRegistryService: func(_ service.RegistryService) {
|
||||||
|
|
@ -149,9 +143,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "io.github.other/test-server",
|
Name: "io.github.other/test-server",
|
||||||
Description: "A test server",
|
Description: "A test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Repository: model.Repository{
|
Repository: model.Repository{
|
||||||
URL: "https://github.com/example/test-server",
|
URL: "https://github.com/example/test-server",
|
||||||
Source: "github",
|
Source: "github",
|
||||||
|
|
@ -175,9 +167,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "example/test-server",
|
Name: "example/test-server",
|
||||||
Description: "A test server",
|
Description: "A test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Repository: model.Repository{
|
Repository: model.Repository{
|
||||||
URL: "https://github.com/example/test-server",
|
URL: "https://github.com/example/test-server",
|
||||||
Source: "github",
|
Source: "github",
|
||||||
|
|
@ -195,9 +185,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
existingServer := apiv0.ServerJSON{
|
existingServer := apiv0.ServerJSON{
|
||||||
Name: "example/test-server",
|
Name: "example/test-server",
|
||||||
Description: "Existing test server",
|
Description: "Existing test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Repository: model.Repository{
|
Repository: model.Repository{
|
||||||
URL: "https://github.com/example/test-server-existing",
|
URL: "https://github.com/example/test-server-existing",
|
||||||
Source: "github",
|
Source: "github",
|
||||||
|
|
@ -214,9 +202,7 @@ func TestPublishEndpoint(t *testing.T) {
|
||||||
requestBody: apiv0.ServerJSON{
|
requestBody: apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-mcpb",
|
Name: "com.example/test-server-mcpb",
|
||||||
Description: "A test server with MCPB package",
|
Description: "A test server with MCPB package",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Packages: []model.Package{
|
Packages: []model.Package{
|
||||||
{
|
{
|
||||||
RegistryType: model.RegistryTypeMCPB,
|
RegistryType: model.RegistryTypeMCPB,
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server-1",
|
ID: "example/test-server-1",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
server2 := apiv0.ServerJSON{
|
server2 := apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server-2",
|
Name: "com.example/test-server-2",
|
||||||
|
|
@ -53,9 +51,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server-2",
|
ID: "example/test-server-2",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "2.0.0",
|
||||||
Version: "2.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server1)
|
_, _ = registry.Publish(server1)
|
||||||
_, _ = registry.Publish(server2)
|
_, _ = registry.Publish(server2)
|
||||||
|
|
@ -75,9 +71,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server-3",
|
ID: "example/test-server-3",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.5.0",
|
||||||
Version: "1.5.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server)
|
_, _ = registry.Publish(server)
|
||||||
},
|
},
|
||||||
|
|
@ -139,7 +133,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-matching",
|
ID: "example/test-matching",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
server2 := apiv0.ServerJSON{
|
server2 := apiv0.ServerJSON{
|
||||||
Name: "com.example/other-server",
|
Name: "com.example/other-server",
|
||||||
|
|
@ -149,7 +143,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/other",
|
ID: "example/other",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server1)
|
_, _ = registry.Publish(server1)
|
||||||
_, _ = registry.Publish(server2)
|
_, _ = registry.Publish(server2)
|
||||||
|
|
@ -169,7 +163,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/recent",
|
ID: "example/recent",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server)
|
_, _ = registry.Publish(server)
|
||||||
},
|
},
|
||||||
|
|
@ -188,7 +182,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/versioned",
|
ID: "example/versioned",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
server2 := apiv0.ServerJSON{
|
server2 := apiv0.ServerJSON{
|
||||||
Name: "com.example/versioned-server",
|
Name: "com.example/versioned-server",
|
||||||
|
|
@ -198,7 +192,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/versioned",
|
ID: "example/versioned",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "2.0.0"},
|
Version: "2.0.0",
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server1)
|
_, _ = registry.Publish(server1)
|
||||||
_, _ = registry.Publish(server2) // This will be marked as latest
|
_, _ = registry.Publish(server2) // This will be marked as latest
|
||||||
|
|
@ -218,7 +212,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/combined",
|
ID: "example/combined",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
server2 := apiv0.ServerJSON{
|
server2 := apiv0.ServerJSON{
|
||||||
Name: "com.example/other-server",
|
Name: "com.example/other-server",
|
||||||
|
|
@ -228,7 +222,7 @@ func TestServersListEndpoint(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/nomatch",
|
ID: "example/nomatch",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{Version: "1.0.0"},
|
Version: "1.0.0",
|
||||||
}
|
}
|
||||||
_, _ = registry.Publish(server1)
|
_, _ = registry.Publish(server1)
|
||||||
_, _ = registry.Publish(server2)
|
_, _ = registry.Publish(server2)
|
||||||
|
|
@ -342,9 +336,7 @@ func TestServersDetailEndpoint(t *testing.T) {
|
||||||
testServer, err := registryService.Publish(apiv0.ServerJSON{
|
testServer, err := registryService.Publish(apiv0.ServerJSON{
|
||||||
Name: "com.example/test-server",
|
Name: "com.example/test-server",
|
||||||
Description: "A test server",
|
Description: "A test server",
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
@ -430,9 +422,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/integration-test",
|
ID: "example/integration-test",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
published, err := registryService.Publish(testServer)
|
published, err := registryService.Publish(testServer)
|
||||||
|
|
@ -488,7 +478,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
||||||
assert.Equal(t, servers[0].Name, listResp.Servers[0].Name)
|
assert.Equal(t, servers[0].Name, listResp.Servers[0].Name)
|
||||||
assert.Equal(t, servers[0].Description, listResp.Servers[0].Description)
|
assert.Equal(t, servers[0].Description, listResp.Servers[0].Description)
|
||||||
assert.Equal(t, servers[0].Repository, listResp.Servers[0].Repository)
|
assert.Equal(t, servers[0].Repository, listResp.Servers[0].Repository)
|
||||||
assert.Equal(t, servers[0].VersionDetail, listResp.Servers[0].VersionDetail)
|
assert.Equal(t, servers[0].Version, listResp.Servers[0].Version)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -522,7 +512,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
||||||
assert.Equal(t, serverDetail.Name, serverDetailResp.Name)
|
assert.Equal(t, serverDetail.Name, serverDetailResp.Name)
|
||||||
assert.Equal(t, serverDetail.Description, serverDetailResp.Description)
|
assert.Equal(t, serverDetail.Description, serverDetailResp.Description)
|
||||||
assert.Equal(t, serverDetail.Repository, serverDetailResp.Repository)
|
assert.Equal(t, serverDetail.Repository, serverDetailResp.Repository)
|
||||||
assert.Equal(t, serverDetail.VersionDetail, serverDetailResp.VersionDetail)
|
assert.Equal(t, serverDetail.Version, serverDetailResp.Version)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Verify mock expectations
|
// Verify mock expectations
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@ func TestPrometheusHandler(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "example/test-server",
|
ID: "example/test-server",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "2.0.0",
|
||||||
Version: "2.0.0",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ func (db *MemoryDB) matchesFilter(entry *apiv0.ServerJSON, filter *ServerFilter)
|
||||||
|
|
||||||
// Check exact version filter
|
// Check exact version filter
|
||||||
if filter.Version != nil {
|
if filter.Version != nil {
|
||||||
if entry.VersionDetail.Version != *filter.Version {
|
if entry.Version != *filter.Version {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,7 @@ func TestImportService_LocalFile(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "123",
|
ID: "123",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Meta: &apiv0.ServerMeta{
|
Meta: &apiv0.ServerMeta{
|
||||||
Official: &apiv0.RegistryExtensions{
|
Official: &apiv0.RegistryExtensions{
|
||||||
ID: "test-id-1",
|
ID: "test-id-1",
|
||||||
|
|
@ -75,9 +73,7 @@ func TestImportService_HTTPFile(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "123",
|
ID: "123",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "2.0.0",
|
||||||
Version: "2.0.0",
|
|
||||||
},
|
|
||||||
Meta: &apiv0.ServerMeta{
|
Meta: &apiv0.ServerMeta{
|
||||||
Official: &apiv0.RegistryExtensions{
|
Official: &apiv0.RegistryExtensions{
|
||||||
ID: "test-id-2",
|
ID: "test-id-2",
|
||||||
|
|
@ -120,9 +116,7 @@ func TestImportService_RegistryAPI(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "123",
|
ID: "123",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "1.0.0",
|
||||||
Version: "1.0.0",
|
|
||||||
},
|
|
||||||
Meta: &apiv0.ServerMeta{
|
Meta: &apiv0.ServerMeta{
|
||||||
Official: &apiv0.RegistryExtensions{
|
Official: &apiv0.RegistryExtensions{
|
||||||
ID: "api-test-id-1",
|
ID: "api-test-id-1",
|
||||||
|
|
@ -140,9 +134,7 @@ func TestImportService_RegistryAPI(t *testing.T) {
|
||||||
Source: "github",
|
Source: "github",
|
||||||
ID: "456",
|
ID: "456",
|
||||||
},
|
},
|
||||||
VersionDetail: model.VersionDetail{
|
Version: "2.0.0",
|
||||||
Version: "2.0.0",
|
|
||||||
},
|
|
||||||
Meta: &apiv0.ServerMeta{
|
Meta: &apiv0.ServerMeta{
|
||||||
Official: &apiv0.RegistryExtensions{
|
Official: &apiv0.RegistryExtensions{
|
||||||
ID: "api-test-id-2",
|
ID: "api-test-id-2",
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
|
||||||
|
|
||||||
// Check this isn't a duplicate version
|
// Check this isn't a duplicate version
|
||||||
for _, server := range existingServerVersions {
|
for _, server := range existingServerVersions {
|
||||||
existingVersion := server.VersionDetail.Version
|
existingVersion := server.Version
|
||||||
if existingVersion == serverJSON.VersionDetail.Version {
|
if existingVersion == serverJSON.Version {
|
||||||
return nil, database.ErrInvalidVersion
|
return nil, database.ErrInvalidVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,8 +117,8 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
|
||||||
existingPublishedAt = existingLatest.Meta.Official.PublishedAt
|
existingPublishedAt = existingLatest.Meta.Official.PublishedAt
|
||||||
}
|
}
|
||||||
isNewLatest = CompareVersions(
|
isNewLatest = CompareVersions(
|
||||||
serverJSON.VersionDetail.Version,
|
serverJSON.Version,
|
||||||
existingLatest.VersionDetail.Version,
|
existingLatest.Version,
|
||||||
publishTime,
|
publishTime,
|
||||||
existingPublishedAt,
|
existingPublishedAt,
|
||||||
) > 0
|
) > 0
|
||||||
|
|
@ -138,7 +138,6 @@ func (s *registryServiceImpl) Publish(req apiv0.ServerJSON) (*apiv0.ServerJSON,
|
||||||
PublishedAt: publishTime,
|
PublishedAt: publishTime,
|
||||||
UpdatedAt: publishTime,
|
UpdatedAt: publishTime,
|
||||||
IsLatest: isNewLatest,
|
IsLatest: isNewLatest,
|
||||||
ReleaseDate: publishTime.Format(time.RFC3339),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create server in database
|
// Create server in database
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue