Files
moby/api/server/router/system/info_response_test.go
Sebastiaan van Stijn 6505d3877c API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields
The `BridgeNfIptables` and `BridgeNfIp6tables` fields in the
`GET /info` response were deprecated in API v1.48, and are now omitted
in API v1.50.

With this patch, old API version continue to return the field:

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIp6tables
    false

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIptables
    false

Omitting the field in API v1.50 and above

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIp6tables
    null

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIptables
    null

This reverts commit eacbbdeec6, and re-applies
a variant of 5d2006256f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 19:49:52 +02:00

34 lines
718 B
Go

package system
import (
"encoding/json"
"strings"
"testing"
"github.com/docker/docker/api/types/system"
)
func TestLegacyFields(t *testing.T) {
infoResp := &infoResponse{
Info: &system.Info{
Containers: 10,
},
extraFields: map[string]any{
"LegacyFoo": false,
"LegacyBar": true,
},
}
data, err := json.MarshalIndent(infoResp, "", " ")
if err != nil {
t.Fatal(err)
}
if expected := `"LegacyFoo": false`; !strings.Contains(string(data), expected) {
t.Errorf("legacy fields should contain %s: %s", expected, string(data))
}
if expected := `"LegacyBar": true`; !strings.Contains(string(data), expected) {
t.Errorf("legacy fields should contain %s: %s", expected, string(data))
}
}