Merge pull request #51000 from postmasters/master

daemon/config: More tests for DNS addresses
This commit is contained in:
Rob Murray
2025-09-19 10:49:21 +01:00
committed by GitHub

View File

@@ -649,6 +649,26 @@ func TestValidateMinAPIVersion(t *testing.T) {
}
}
func TestConfigDNS(t *testing.T) {
tests := []struct {
doc string
input string
}{
{
doc: "IPv6s with scope IDs",
input: `{"dns": ["::1%eth0", "::1%2"]}`,
},
}
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
var cfg Config
err := json.Unmarshal([]byte(tc.input), &cfg)
assert.Check(t, err == nil, "type: %T", err)
})
}
}
func TestConfigInvalidDNS(t *testing.T) {
tests := []struct {
doc string
@@ -665,6 +685,11 @@ func TestConfigInvalidDNS(t *testing.T) {
input: `{"dns": ["2.2.2.2", "1.1.1.1o"]}`,
expectedErr: `ParseAddr("1.1.1.1o"): unexpected character (at "o")`,
},
{
doc: "IPv4 with scope ID",
input: `{"dns": ["1.1.1.1%eth0"]}`,
expectedErr: `ParseAddr("1.1.1.1%eth0"): unexpected character (at "%eth0")`,
},
}
for _, tc := range tests {