Rename api/v1 -> api/v0 to match API paths (#320)
This PR renames the API paths from v1 to v0 to align with the actual API versioning scheme.
This commit is contained in:
parent
099a2d702e
commit
c0a94cca8c
1 changed files with 176 additions and 177 deletions
|
|
@ -17,7 +17,7 @@ import (
|
|||
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
|
||||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -29,33 +29,33 @@ type MockRegistryService struct {
|
|||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) List(cursor string, limit int) ([]apiv1.ServerRecord, string, error) {
|
||||
func (m *MockRegistryService) List(cursor string, limit int) ([]apiv0.ServerRecord, string, error) {
|
||||
args := m.Called(cursor, limit)
|
||||
return args.Get(0).([]apiv1.ServerRecord), args.String(1), args.Error(2)
|
||||
return args.Get(0).([]apiv0.ServerRecord), args.String(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) GetByID(id string) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) GetByID(id string) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(id)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) Publish(request apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) Publish(request apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(request)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) EditServer(id string, request apiv1.PublishRequest) (*apiv1.ServerRecord, error) {
|
||||
func (m *MockRegistryService) EditServer(id string, request apiv0.PublishRequest) (*apiv0.ServerRecord, error) {
|
||||
args := m.Called(id, request)
|
||||
if args.Get(0) == nil {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
return args.Get(0).(*apiv1.ServerRecord), args.Error(1)
|
||||
return args.Get(0).(*apiv0.ServerRecord), args.Error(1)
|
||||
}
|
||||
|
||||
// Helper function to generate a valid JWT token for testing
|
||||
|
|
@ -88,7 +88,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "successful publish with GitHub auth",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.example/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -110,13 +110,13 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(&apiv1.ServerRecord{}, nil)
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(&apiv0.ServerRecord{}, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "successful publish with no auth (AuthMethodNone)",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "example/test-server",
|
||||
Description: "A test server without auth",
|
||||
|
|
@ -137,13 +137,13 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(&apiv1.ServerRecord{}, nil)
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(&apiv0.ServerRecord{}, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "missing authorization header",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
authHeader: "", // Empty auth header
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnprocessableEntity,
|
||||
|
|
@ -151,7 +151,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "invalid authorization header format",
|
||||
requestBody: apiv1.PublishRequest{},
|
||||
requestBody: apiv0.PublishRequest{},
|
||||
authHeader: "InvalidFormat",
|
||||
setupMocks: func(_ *MockRegistryService) {},
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
|
|
@ -159,7 +159,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "invalid token",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -175,7 +175,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "permission denied",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "io.github.other/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -201,7 +201,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "registry service error",
|
||||
requestBody: apiv1.PublishRequest{
|
||||
requestBody: apiv0.PublishRequest{
|
||||
Server: model.ServerJSON{
|
||||
Name: "example/test-server",
|
||||
Description: "A test server",
|
||||
|
|
@ -222,7 +222,7 @@ func TestPublishEndpoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.On("Publish", mock.AnythingOfType("v1.PublishRequest")).Return(nil, errors.New("cannot publish duplicate version"))
|
||||
registry.On("Publish", mock.AnythingOfType("v0.PublishRequest")).Return(nil, errors.New("cannot publish duplicate version"))
|
||||
},
|
||||
expectedStatus: http.StatusBadRequest,
|
||||
expectedError: "Failed to publish server",
|
||||
|
|
|
|||
Loading…
Reference in a new issue