Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apitypes/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ const APIVersionV1 = "v1"
// so they can decide whether, and at which version, to use the HTTP API instead of falling back to the gRPC API.
type CapabilitiesResponse struct {
// APIVersions lists the HTTP API versions the Coordinator supports, e.g. ["v1"].
APIVersions []string `json:"apiVersions"`
APIVersions []string `json:"api_versions"`
}
28 changes: 28 additions & 0 deletions apitypes/capabilities_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2026 Edgeless Systems GmbH
// SPDX-License-Identifier: BUSL-1.1

package apitypes

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// TestCapabilitiesResponseFieldName pins the wire field name, which is part of the API contract and can't be changed once clients rely on it.
func TestCapabilitiesResponseFieldName(t *testing.T) {
data, err := json.Marshal(CapabilitiesResponse{APIVersions: []string{APIVersionV1}})
require.NoError(t, err)

assert.JSONEq(t, `{"api_versions":["v1"]}`, string(data))
}

// TestCapabilitiesResponseIgnoresUnknownFields pins the rule that lets a Coordinator extend this response without breaking older clients.
func TestCapabilitiesResponseIgnoresUnknownFields(t *testing.T) {
var resp CapabilitiesResponse
require.NoError(t, json.Unmarshal([]byte(`{"api_versions":["v1"],"something_new":42}`), &resp))

assert.Equal(t, []string{APIVersionV1}, resp.APIVersions)
}
Loading