mirror of
https://github.com/moby/moby.git
synced 2026-08-13 17:06:44 +00:00
Merge pull request #51000 from postmasters/master
daemon/config: More tests for DNS addresses
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user