Files
docker-agent/pkg/a2a/server_test.go
T
David Gageot ee47fa04e1 Fix A2A agent card advertising unroutable wildcard address
Replace wildcard listen addresses (::, 0.0.0.0) with localhost in the
agent card URL so clients can actually reach the server. Also switch
TCP listeners to tcp4 to avoid binding to IPv6 on dual-stack systems.

Fixes #1679

Assisted-By: cagent
2026-02-10 19:24:54 +01:00

34 lines
808 B
Go

package a2a
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRoutableAddr(t *testing.T) {
t.Parallel()
tests := []struct {
name string
addr string
want string
}{
{"ipv6 wildcard", "[::]:8080", "localhost:8080"},
{"ipv4 wildcard", "0.0.0.0:8080", "localhost:8080"},
{"empty host", ":8080", "localhost:8080"},
{"localhost stays", "localhost:8080", "localhost:8080"},
{"ipv4 loopback stays", "127.0.0.1:8080", "127.0.0.1:8080"},
{"specific ip stays", "192.168.1.1:9090", "192.168.1.1:9090"},
{"hostname stays", "my-host:8080", "my-host:8080"},
{"invalid addr returned as-is", "not-a-host-port", "not-a-host-port"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, routableAddr(tt.addr))
})
}
}