mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fbfac21ed4
Add a --dns-search parameter and a DnsSearch configuration field for specifying dns search domains. Docker-DCO-1.1-Signed-off-by: Daniel Norberg <daniel.norberg@gmail.com> (github: danielnorberg)
78 lines
1.5 KiB
Go
78 lines
1.5 KiB
Go
package opts
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateIP4(t *testing.T) {
|
|
if ret, err := ValidateIp4Address(`1.2.3.4`); err != nil || ret == "" {
|
|
t.Fatalf("ValidateIp4Address(`1.2.3.4`) got %s %s", ret, err)
|
|
}
|
|
|
|
if ret, err := ValidateIp4Address(`127.0.0.1`); err != nil || ret == "" {
|
|
t.Fatalf("ValidateIp4Address(`127.0.0.1`) got %s %s", ret, err)
|
|
}
|
|
|
|
if ret, err := ValidateIp4Address(`127`); err == nil || ret != "" {
|
|
t.Fatalf("ValidateIp4Address(`127`) got %s %s", ret, err)
|
|
}
|
|
|
|
if ret, err := ValidateIp4Address(`random invalid string`); err == nil || ret != "" {
|
|
t.Fatalf("ValidateIp4Address(`random invalid string`) got %s %s", ret, err)
|
|
}
|
|
|
|
}
|
|
|
|
func TestValidateDomain(t *testing.T) {
|
|
valid := []string{
|
|
`a`,
|
|
`a.`,
|
|
`1.foo`,
|
|
`17.foo`,
|
|
`foo.bar`,
|
|
`foo.bar.baz`,
|
|
`foo.bar.`,
|
|
`foo.bar.baz`,
|
|
`foo1.bar2`,
|
|
`foo1.bar2.baz`,
|
|
`1foo.2bar.`,
|
|
`1foo.2bar.baz`,
|
|
`foo-1.bar-2`,
|
|
`foo-1.bar-2.baz`,
|
|
`foo-1.bar-2.`,
|
|
`foo-1.bar-2.baz`,
|
|
`1-foo.2-bar`,
|
|
`1-foo.2-bar.baz`,
|
|
`1-foo.2-bar.`,
|
|
`1-foo.2-bar.baz`,
|
|
}
|
|
|
|
invalid := []string{
|
|
``,
|
|
`.`,
|
|
`17`,
|
|
`17.`,
|
|
`.17`,
|
|
`17-.`,
|
|
`17-.foo`,
|
|
`.foo`,
|
|
`foo-.bar`,
|
|
`-foo.bar`,
|
|
`foo.bar-`,
|
|
`foo.bar-.baz`,
|
|
`foo.-bar`,
|
|
`foo.-bar.baz`,
|
|
}
|
|
|
|
for _, domain := range valid {
|
|
if ret, err := ValidateDomain(domain); err != nil || ret == "" {
|
|
t.Fatalf("ValidateDomain(`"+domain+"`) got %s %s", ret, err)
|
|
}
|
|
}
|
|
|
|
for _, domain := range invalid {
|
|
if ret, err := ValidateDomain(domain); err == nil || ret != "" {
|
|
t.Fatalf("ValidateDomain(`"+domain+"`) got %s %s", ret, err)
|
|
}
|
|
}
|
|
}
|