Merge pull request #756 from TimWolla/rfc3849

Use documentation IPv6 addresses (RFC 3849) in tests
This commit is contained in:
aboch 2016-01-26 11:32:26 -05:00
commit d25e25ccb9
5 changed files with 21 additions and 21 deletions

View File

@ -69,7 +69,7 @@ func TestValidateAndIsV6(t *testing.T) {
t.Fatalf("incorrect ip version returned") t.Fatalf("incorrect ip version returned")
} }
orig := i.Pool orig := i.Pool
if i.Pool, err = types.ParseCIDR("2003::33/64"); err != nil { if i.Pool, err = types.ParseCIDR("2001:db8::33/64"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if !i.IsV6() { if !i.IsV6() {
@ -83,7 +83,7 @@ func TestValidateAndIsV6(t *testing.T) {
} }
// incongruent gw ver // incongruent gw ver
if i.Gateway, err = types.ParseCIDR("2001::45/65"); err != nil { if i.Gateway, err = types.ParseCIDR("2001:db8::45/65"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err = i.Validate(); err == nil { if err = i.Validate(); err == nil {
@ -92,7 +92,7 @@ func TestValidateAndIsV6(t *testing.T) {
i.Gateway = nil i.Gateway = nil
// incongruent secondary ip ver // incongruent secondary ip ver
if i.AuxAddresses["ip2"], err = types.ParseCIDR("2002::44/80"); err != nil { if i.AuxAddresses["ip2"], err = types.ParseCIDR("2001:db8::44/80"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err = i.Validate(); err == nil { if err = i.Validate(); err == nil {

View File

@ -112,8 +112,8 @@ func TestCreateFullOptionsLabels(t *testing.T) {
} }
bndIPs := "127.0.0.1" bndIPs := "127.0.0.1"
nwV6s := "2100:2400:2600:2700:2800::/80" nwV6s := "2001:db8:2600:2700:2800::/80"
gwV6s := "2100:2400:2600:2700:2800::25/80" gwV6s := "2001:db8:2600:2700:2800::25/80"
nwV6, _ := types.ParseCIDR(nwV6s) nwV6, _ := types.ParseCIDR(nwV6s)
gwV6, _ := types.ParseCIDR(gwV6s) gwV6, _ := types.ParseCIDR(gwV6s)
@ -191,7 +191,7 @@ func TestCreateFullOptionsLabels(t *testing.T) {
if !nwV6.Contains(te.Interface().AddressIPv6().IP) { if !nwV6.Contains(te.Interface().AddressIPv6().IP) {
t.Fatalf("endpoint got assigned address outside of container network(%s): %s", nwV6.String(), te.Interface().AddressIPv6()) t.Fatalf("endpoint got assigned address outside of container network(%s): %s", nwV6.String(), te.Interface().AddressIPv6())
} }
if te.Interface().AddressIPv6().IP.String() != "2100:2400:2600:2700:2800:aabb:ccdd:eeff" { if te.Interface().AddressIPv6().IP.String() != "2001:db8:2600:2700:2800:aabb:ccdd:eeff" {
t.Fatalf("Unexpected endpoint IPv6 address: %v", te.Interface().AddressIPv6().IP) t.Fatalf("Unexpected endpoint IPv6 address: %v", te.Interface().AddressIPv6().IP)
} }
} }
@ -736,18 +736,18 @@ func TestValidateConfig(t *testing.T) {
} }
// Test v6 gw // Test v6 gw
_, v6nw, _ := net.ParseCIDR("2001:1234:ae:b004::/64") _, v6nw, _ := net.ParseCIDR("2001:db8:ae:b004::/64")
c = networkConfiguration{ c = networkConfiguration{
EnableIPv6: true, EnableIPv6: true,
AddressIPv6: v6nw, AddressIPv6: v6nw,
DefaultGatewayIPv6: net.ParseIP("2001:1234:ac:b004::bad:a55"), DefaultGatewayIPv6: net.ParseIP("2001:db8:ac:b004::bad:a55"),
} }
err = c.Validate() err = c.Validate()
if err == nil { if err == nil {
t.Fatalf("Failed to detect invalid v6 default gateway") t.Fatalf("Failed to detect invalid v6 default gateway")
} }
c.DefaultGatewayIPv6 = net.ParseIP("2001:1234:ae:b004::bad:a55") c.DefaultGatewayIPv6 = net.ParseIP("2001:db8:ae:b004::bad:a55")
err = c.Validate() err = c.Validate()
if err != nil { if err != nil {
t.Fatalf("Unexpected validation error on v6 default gateway") t.Fatalf("Unexpected validation error on v6 default gateway")

View File

@ -78,7 +78,7 @@ func TestGetAddressVersion(t *testing.T) {
if v6 != getAddressVersion(net.ParseIP("ff01::1")) { if v6 != getAddressVersion(net.ParseIP("ff01::1")) {
t.Fatalf("Failed to detect IPv6 version") t.Fatalf("Failed to detect IPv6 version")
} }
if v6 != getAddressVersion(net.ParseIP("2001:56::76:51")) { if v6 != getAddressVersion(net.ParseIP("2001:db8::76:51")) {
t.Fatalf("Failed to detect IPv6 version") t.Fatalf("Failed to detect IPv6 version")
} }
} }
@ -515,11 +515,11 @@ func TestRemoveSubnet(t *testing.T) {
{localAddressSpace, "192.168.0.0/16", false}, {localAddressSpace, "192.168.0.0/16", false},
{localAddressSpace, "172.17.0.0/16", false}, {localAddressSpace, "172.17.0.0/16", false},
{localAddressSpace, "10.0.0.0/8", false}, {localAddressSpace, "10.0.0.0/8", false},
{localAddressSpace, "2002:1:2:3:4:5:ffff::/112", false}, {localAddressSpace, "2001:db8:1:2:3:4:ffff::/112", false},
{"splane", "172.17.0.0/16", false}, {"splane", "172.17.0.0/16", false},
{"splane", "10.0.0.0/8", false}, {"splane", "10.0.0.0/8", false},
{"splane", "2002:1:2:3:4:5:6::/112", true}, {"splane", "2001:db8:1:2:3:4:5::/112", true},
{"splane", "2002:1:2:3:4:5:ffff::/112", true}, {"splane", "2001:db8:1:2:3:4:ffff::/112", true},
} }
poolIDs := make([]string, len(input)) poolIDs := make([]string, len(input))

View File

@ -202,7 +202,7 @@ func printIpamInfo(list []*IpamInfo) string {
} }
func TestEndpointMarshalling(t *testing.T) { func TestEndpointMarshalling(t *testing.T) {
ip, nw6, err := net.ParseCIDR("2001:3002:4003::122/64") ip, nw6, err := net.ParseCIDR("2001:db8:4003::122/64")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -180,13 +180,13 @@ func TestCompareIPMask(t *testing.T) {
ms: 0, ms: 0,
}, },
{ // ip and mask as v6 { // ip and mask as v6
ip: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), ip: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0}, mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
is: 0, is: 0,
ms: 0, ms: 0,
}, },
{ {
ip: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), ip: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
mask: []byte{0xff, 0xff, 0xff, 0}, mask: []byte{0xff, 0xff, 0xff, 0},
isErr: true, isErr: true,
}, },
@ -244,7 +244,7 @@ func TestUtilGetHostPortionIP(t *testing.T) {
host: net.IPv4(0, 0, 0, 4)[12:], host: net.IPv4(0, 0, 0, 4)[12:],
}, },
{ // ip and mask as v6 { // ip and mask as v6
ip: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), ip: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0}, mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
host: net.ParseIP("0::AB:00CD"), host: net.ParseIP("0::AB:00CD"),
}, },
@ -261,7 +261,7 @@ func TestUtilGetHostPortionIP(t *testing.T) {
} }
// ip as v6 and mask as v4 are not compatible // ip as v6 and mask as v4 are not compatible
if _, err := GetHostPartIP(net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil { if _, err := GetHostPartIP(net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
t.Fatalf("Unexpected success") t.Fatalf("Unexpected success")
} }
// ip as v4 and non conventional mask // ip as v4 and non conventional mask
@ -326,9 +326,9 @@ func TestUtilGetBroadcastIP(t *testing.T) {
bcast: net.IPv4(172, 28, 255, 255)[12:], bcast: net.IPv4(172, 28, 255, 255)[12:],
}, },
{ // ip and mask as v6 { // ip and mask as v6
ip: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), ip: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0}, mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
bcast: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEFF:FFFF"), bcast: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEFF:FFFF"),
}, },
} }
@ -343,7 +343,7 @@ func TestUtilGetBroadcastIP(t *testing.T) {
} }
// ip as v6 and mask as v4 are not compatible // ip as v6 and mask as v4 are not compatible
if _, err := GetBroadcastIP(net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil { if _, err := GetBroadcastIP(net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
t.Fatalf("Unexpected success") t.Fatalf("Unexpected success")
} }
// ip as v4 and non conventional mask // ip as v4 and non conventional mask