ElektraInitiative / libelektra

Elektra serves as a universal and secure framework to access configuration settings in a global, hierarchical key database.
https://www.libelektra.org
BSD 3-Clause "New" or "Revised" License
208 stars 123 forks source link

More network/ipaddr tests #1643

Closed markus2330 closed 4 years ago

markus2330 commented 7 years ago

Tests from http://download.dartware.com/thirdparty/test-ipv6-regex.pl

ipv6test(False,"");# empty string
ipv6test(True,"::1");# loopback, compressed, non-routable
ipv6test(True,"::");# unspecified, compressed, non-routable
ipv6test(True,"0:0:0:0:0:0:0:1");# loopback, full
ipv6test(True,"0:0:0:0:0:0:0:0");# unspecified, full
ipv6test(True,"2001:DB8:0:0:8:800:200C:417A");# unicast, full
ipv6test(True,"FF01:0:0:0:0:0:0:101");# multicast, full
ipv6test(True,"2001:DB8::8:800:200C:417A");# unicast, compressed
ipv6test(True,"FF01::101");# multicast, compressed
ipv6test(False,"2001:DB8:0:0:8:800:200C:417A:221");# unicast, full
ipv6test(False,"FF01::101::2");# multicast, compressed
ipv6test(True,"fe80::217:f2ff:fe07:ed62");

ipv6test(True,"2001:0000:1234:0000:0000:C1C0:ABCD:0876");
ipv6test(True,"3ffe:0b00:0000:0000:0001:0000:0000:000a");
ipv6test(True,"FF02:0000:0000:0000:0000:0000:0000:0001");
ipv6test(True,"0000:0000:0000:0000:0000:0000:0000:0001");
ipv6test(True,"0000:0000:0000:0000:0000:0000:0000:0000");
ipv6test(False,"02001:0000:1234:0000:0000:C1C0:ABCD:0876");# extra 0 not allowed!
ipv6test(False,"2001:0000:1234:0000:00001:C1C0:ABCD:0876");# extra 0 not allowed!
#ipv6test(True," 2001:0000:1234:0000:0000:C1C0:ABCD:0876");# leading space
#ipv6test(True,"2001:0000:1234:0000:0000:C1C0:ABCD:0876");# trailing space
#ipv6test(True," 2001:0000:1234:0000:0000:C1C0:ABCD:0876  ");# leading and trailing space
ipv6test(False,"2001:0000:1234:0000:0000:C1C0:ABCD:0876  0");# junk after valid address
ipv6test(False,"2001:0000:1234: 0000:0000:C1C0:ABCD:0876");# internal space

ipv6test(False,"3ffe:0b00:0000:0001:0000:0000:000a");# seven segments
ipv6test(False,"FF02:0000:0000:0000:0000:0000:0000:0000:0001");# nine segments
ipv6test(False,"3ffe:b00::1::a");# double "::"
ipv6test(False,"::1111:2222:3333:4444:5555:6666::");# double "::"
ipv6test(True,"2::10");
ipv6test(True,"ff02::1");
ipv6test(True,"fe80::");
ipv6test(True,"2002::");
ipv6test(True,"2001:db8::");
ipv6test(True,"2001:0db8:1234::");
ipv6test(True,"::ffff:0:0");
ipv6test(True,"::1");
ipv6test(True,"1:2:3:4:5:6:7:8");
ipv6test(True,"1:2:3:4:5:6::8");
ipv6test(True,"1:2:3:4:5::8");
ipv6test(True,"1:2:3:4::8");
ipv6test(True,"1:2:3::8");
ipv6test(True,"1:2::8");
ipv6test(True,"1::8");
ipv6test(True,"1::2:3:4:5:6:7");
ipv6test(True,"1::2:3:4:5:6");
ipv6test(True,"1::2:3:4:5");
ipv6test(True,"1::2:3:4");
ipv6test(True,"1::2:3");
ipv6test(True,"1::8");
ipv6test(True,"::2:3:4:5:6:7:8");
ipv6test(True,"::2:3:4:5:6:7");
ipv6test(True,"::2:3:4:5:6");
ipv6test(True,"::2:3:4:5");
ipv6test(True,"::2:3:4");
ipv6test(True,"::2:3");
ipv6test(True,"::8");
ipv6test(True,"1:2:3:4:5:6::");
ipv6test(True,"1:2:3:4:5::");
ipv6test(True,"1:2:3:4::");
ipv6test(True,"1:2:3::");
ipv6test(True,"1:2::");
ipv6test(True,"1::");
ipv6test(True,"1:2:3:4:5::7:8");
ipv6test(False,"1:2:3::4:5::7:8");# Double "::"
ipv6test(False,"12345::6:7:8");
ipv6test(True,"1:2:3:4::7:8");
ipv6test(True,"1:2:3::7:8");
ipv6test(True,"1:2::7:8");
ipv6test(True,"1::7:8");

# IPv4 addresses as dotted-quads
ipv6test(True,"1:2:3:4:5:6:1.2.3.4");
ipv6test(True,"1:2:3:4:5::1.2.3.4");
ipv6test(True,"1:2:3:4::1.2.3.4");
ipv6test(True,"1:2:3::1.2.3.4");
ipv6test(True,"1:2::1.2.3.4");
ipv6test(True,"1::1.2.3.4");
ipv6test(True,"1:2:3:4::5:1.2.3.4");
ipv6test(True,"1:2:3::5:1.2.3.4");
ipv6test(True,"1:2::5:1.2.3.4");
ipv6test(True,"1::5:1.2.3.4");
ipv6test(True,"1::5:11.22.33.44");
ipv6test(False,"1::5:400.2.3.4");
ipv6test(False,"1::5:260.2.3.4");
ipv6test(False,"1::5:256.2.3.4");
ipv6test(False,"1::5:1.256.3.4");
ipv6test(False,"1::5:1.2.256.4");
ipv6test(False,"1::5:1.2.3.256");
ipv6test(False,"1::5:300.2.3.4");
ipv6test(False,"1::5:1.300.3.4");
ipv6test(False,"1::5:1.2.300.4");
ipv6test(False,"1::5:1.2.3.300");
ipv6test(False,"1::5:900.2.3.4");
ipv6test(False,"1::5:1.900.3.4");
ipv6test(False,"1::5:1.2.900.4");
ipv6test(False,"1::5:1.2.3.900");
ipv6test(False,"1::5:300.300.300.300");
ipv6test(False,"1::5:3000.30.30.30");
ipv6test(False,"1::400.2.3.4");
ipv6test(False,"1::260.2.3.4");
ipv6test(False,"1::256.2.3.4");
ipv6test(False,"1::1.256.3.4");
ipv6test(False,"1::1.2.256.4");
ipv6test(False,"1::1.2.3.256");
ipv6test(False,"1::300.2.3.4");
ipv6test(False,"1::1.300.3.4");
ipv6test(False,"1::1.2.300.4");
ipv6test(False,"1::1.2.3.300");
ipv6test(False,"1::900.2.3.4");
ipv6test(False,"1::1.900.3.4");
ipv6test(False,"1::1.2.900.4");
ipv6test(False,"1::1.2.3.900");
ipv6test(False,"1::300.300.300.300");
ipv6test(False,"1::3000.30.30.30");
ipv6test(False,"::400.2.3.4");
ipv6test(False,"::260.2.3.4");
ipv6test(False,"::256.2.3.4");
ipv6test(False,"::1.256.3.4");
ipv6test(False,"::1.2.256.4");
ipv6test(False,"::1.2.3.256");
ipv6test(False,"::300.2.3.4");
ipv6test(False,"::1.300.3.4");
ipv6test(False,"::1.2.300.4");
ipv6test(False,"::1.2.3.300");
ipv6test(False,"::900.2.3.4");
ipv6test(False,"::1.900.3.4");
ipv6test(False,"::1.2.900.4");
ipv6test(False,"::1.2.3.900");
ipv6test(False,"::300.300.300.300");
ipv6test(False,"::3000.30.30.30");
ipv6test(True,"fe80::217:f2ff:254.7.237.98");
ipv6test(True,"::ffff:192.168.1.26");
ipv6test(False,"2001:1:1:1:1:1:255Z255X255Y255");# garbage instead of "." in IPv4
ipv6test(False,"::ffff:192x168.1.26");# ditto
ipv6test(True,"::ffff:192.168.1.1");
ipv6test(True,"0:0:0:0:0:0:13.1.68.3");# IPv4-compatible IPv6 address, full, deprecated
ipv6test(True,"0:0:0:0:0:FFFF:129.144.52.38");# IPv4-mapped IPv6 address, full
ipv6test(True,"::13.1.68.3");# IPv4-compatible IPv6 address, compressed, deprecated
ipv6test(True,"::FFFF:129.144.52.38");# IPv4-mapped IPv6 address, compressed
ipv6test(True,"fe80:0:0:0:204:61ff:254.157.241.86");
ipv6test(True,"fe80::204:61ff:254.157.241.86");
ipv6test(True,"::ffff:12.34.56.78");
ipv6test(False,"::ffff:2.3.4");
ipv6test(False,"::ffff:257.1.2.3");
ipv6test(False,"1.2.3.4");

ipv6test(False,"1.2.3.4:1111:2222:3333:4444::5555");  # Aeron
ipv6test(False,"1.2.3.4:1111:2222:3333::5555");
ipv6test(False,"1.2.3.4:1111:2222::5555");
ipv6test(False,"1.2.3.4:1111::5555");
ipv6test(False,"1.2.3.4::5555");
ipv6test(False,"1.2.3.4::");

# Testing IPv4 addresses represented as dotted-quads
# Leading zero's in IPv4 addresses not allowed: some systems treat the leading "0" in ".086" as the start of an octal number
# Update: The BNF in RFC-3986 explicitly defines the dec-octet (for IPv4 addresses) not to have a leading zero
ipv6test(False,"fe80:0000:0000:0000:0204:61ff:254.157.241.086");
ipv6test(True,"::ffff:192.0.2.128");   # but this is OK, since there's a single digit
ipv6test(False,"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:6666:00.00.00.00");
ipv6test(False,"1111:2222:3333:4444:5555:6666:000.000.000.000");
ipv6test(False,"1111:2222:3333:4444:5555:6666:256.256.256.256");

# Not testing address with subnet mask
# ipv6test(True,"2001:0DB8:0000:CD30:0000:0000:0000:0000/60");# full, with prefix
# ipv6test(True,"2001:0DB8::CD30:0:0:0:0/60");# compressed, with prefix
# ipv6test(True,"2001:0DB8:0:CD30::/60");# compressed, with prefix #2
# ipv6test(True,"::/128");# compressed, unspecified address type, non-routable
# ipv6test(True,"::1/128");# compressed, loopback address type, non-routable
# ipv6test(True,"FF00::/8");# compressed, multicast address type
# ipv6test(True,"FE80::/10");# compressed, link-local unicast, non-routable
# ipv6test(True,"FEC0::/10");# compressed, site-local unicast, deprecated
# ipv6test(False,"124.15.6.89/60");# standard IPv4, prefix not allowed

ipv6test(True,"fe80:0000:0000:0000:0204:61ff:fe9d:f156");
ipv6test(True,"fe80:0:0:0:204:61ff:fe9d:f156");
ipv6test(True,"fe80::204:61ff:fe9d:f156");
ipv6test(True,"::1");
ipv6test(True,"fe80::");
ipv6test(True,"fe80::1");
ipv6test(False,":");
ipv6test(True,"::ffff:c000:280");

# Aeron supplied these test cases
ipv6test(False,"1111:2222:3333:4444::5555:");
ipv6test(False,"1111:2222:3333::5555:");
ipv6test(False,"1111:2222::5555:");
ipv6test(False,"1111::5555:");
ipv6test(False,"::5555:");
ipv6test(False,":::");
ipv6test(False,"1111:");
ipv6test(False,":");

ipv6test(False,":1111:2222:3333:4444::5555");
ipv6test(False,":1111:2222:3333::5555");
ipv6test(False,":1111:2222::5555");
ipv6test(False,":1111::5555");
ipv6test(False,":::5555");
ipv6test(False,":::");

# Additional test cases
# from http://rt.cpan.org/Public/Bug/Display.html?id=50693

ipv6test(True,"2001:0db8:85a3:0000:0000:8a2e:0370:7334");
ipv6test(True,"2001:db8:85a3:0:0:8a2e:370:7334");
ipv6test(True,"2001:db8:85a3::8a2e:370:7334");
ipv6test(True,"2001:0db8:0000:0000:0000:0000:1428:57ab");
ipv6test(True,"2001:0db8:0000:0000:0000::1428:57ab");
ipv6test(True,"2001:0db8:0:0:0:0:1428:57ab");
ipv6test(True,"2001:0db8:0:0::1428:57ab");
ipv6test(True,"2001:0db8::1428:57ab");
ipv6test(True,"2001:db8::1428:57ab");
ipv6test(True,"0000:0000:0000:0000:0000:0000:0000:0001");
ipv6test(True,"::1");
ipv6test(True,"::ffff:0c22:384e");
ipv6test(True,"2001:0db8:1234:0000:0000:0000:0000:0000");
ipv6test(True,"2001:0db8:1234:ffff:ffff:ffff:ffff:ffff");
ipv6test(True,"2001:db8:a::123");
ipv6test(True,"fe80::");

ipv6test(False,"123");
ipv6test(False,"ldkfj");
ipv6test(False,"2001::FFD3::57ab");
ipv6test(False,"2001:db8:85a3::8a2e:37023:7334");
ipv6test(False,"2001:db8:85a3::8a2e:370k:7334");
ipv6test(False,"1:2:3:4:5:6:7:8:9");
ipv6test(False,"1::2::3");
ipv6test(False,"1:::3:4:5");
ipv6test(False,"1:2:3::4:5:6:7:8:9");

# New from Aeron
ipv6test(True,"1111:2222:3333:4444:5555:6666:7777:8888");
ipv6test(True,"1111:2222:3333:4444:5555:6666:7777::");
ipv6test(True,"1111:2222:3333:4444:5555:6666::");
ipv6test(True,"1111:2222:3333:4444:5555::");
ipv6test(True,"1111:2222:3333:4444::");
ipv6test(True,"1111:2222:3333::");
ipv6test(True,"1111:2222::");
ipv6test(True,"1111::");
# ipv6test(True,"::");     #duplicate
ipv6test(True,"1111:2222:3333:4444:5555:6666::8888");
ipv6test(True,"1111:2222:3333:4444:5555::8888");
ipv6test(True,"1111:2222:3333:4444::8888");
ipv6test(True,"1111:2222:3333::8888");
ipv6test(True,"1111:2222::8888");
ipv6test(True,"1111::8888");
ipv6test(True,"::8888");
ipv6test(True,"1111:2222:3333:4444:5555::7777:8888");
ipv6test(True,"1111:2222:3333:4444::7777:8888");
ipv6test(True,"1111:2222:3333::7777:8888");
ipv6test(True,"1111:2222::7777:8888");
ipv6test(True,"1111::7777:8888");
ipv6test(True,"::7777:8888");
ipv6test(True,"1111:2222:3333:4444::6666:7777:8888");
ipv6test(True,"1111:2222:3333::6666:7777:8888");
ipv6test(True,"1111:2222::6666:7777:8888");
ipv6test(True,"1111::6666:7777:8888");
ipv6test(True,"::6666:7777:8888");
ipv6test(True,"1111:2222:3333::5555:6666:7777:8888");
ipv6test(True,"1111:2222::5555:6666:7777:8888");
ipv6test(True,"1111::5555:6666:7777:8888");
ipv6test(True,"::5555:6666:7777:8888");
ipv6test(True,"1111:2222::4444:5555:6666:7777:8888");
ipv6test(True,"1111::4444:5555:6666:7777:8888");
ipv6test(True,"::4444:5555:6666:7777:8888");
ipv6test(True,"1111::3333:4444:5555:6666:7777:8888");
ipv6test(True,"::3333:4444:5555:6666:7777:8888");
ipv6test(True,"::2222:3333:4444:5555:6666:7777:8888");
ipv6test(True,"1111:2222:3333:4444:5555:6666:123.123.123.123");
ipv6test(True,"1111:2222:3333:4444:5555::123.123.123.123");
ipv6test(True,"1111:2222:3333:4444::123.123.123.123");
ipv6test(True,"1111:2222:3333::123.123.123.123");
ipv6test(True,"1111:2222::123.123.123.123");
ipv6test(True,"1111::123.123.123.123");
ipv6test(True,"::123.123.123.123");
ipv6test(True,"1111:2222:3333:4444::6666:123.123.123.123");
ipv6test(True,"1111:2222:3333::6666:123.123.123.123");
ipv6test(True,"1111:2222::6666:123.123.123.123");
ipv6test(True,"1111::6666:123.123.123.123");
ipv6test(True,"::6666:123.123.123.123");
ipv6test(True,"1111:2222:3333::5555:6666:123.123.123.123");
ipv6test(True,"1111:2222::5555:6666:123.123.123.123");
ipv6test(True,"1111::5555:6666:123.123.123.123");
ipv6test(True,"::5555:6666:123.123.123.123");
ipv6test(True,"1111:2222::4444:5555:6666:123.123.123.123");
ipv6test(True,"1111::4444:5555:6666:123.123.123.123");
ipv6test(True,"::4444:5555:6666:123.123.123.123");
ipv6test(True,"1111::3333:4444:5555:6666:123.123.123.123");
ipv6test(True,"::2222:3333:4444:5555:6666:123.123.123.123");

# Playing with combinations of "0" and "::"
# NB: these are all sytactically correct, but are bad form
#   because "0" adjacent to "::" should be combined into "::"
ipv6test(True,"::0:0:0:0:0:0:0");
ipv6test(True,"::0:0:0:0:0:0");
ipv6test(True,"::0:0:0:0:0");
ipv6test(True,"::0:0:0:0");
ipv6test(True,"::0:0:0");
ipv6test(True,"::0:0");
ipv6test(True,"::0");
ipv6test(True,"0:0:0:0:0:0:0::");
ipv6test(True,"0:0:0:0:0:0::");
ipv6test(True,"0:0:0:0:0::");
ipv6test(True,"0:0:0:0::");
ipv6test(True,"0:0:0::");
ipv6test(True,"0:0::");
ipv6test(True,"0::");

# New invalid from Aeron
# Invalid data
ipv6test(False,"XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX");

# Too many components
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:8888:9999");
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:8888::");
ipv6test(False,"::2222:3333:4444:5555:6666:7777:8888:9999");

# Too few components
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777");
ipv6test(False,"1111:2222:3333:4444:5555:6666");
ipv6test(False,"1111:2222:3333:4444:5555");
ipv6test(False,"1111:2222:3333:4444");
ipv6test(False,"1111:2222:3333");
ipv6test(False,"1111:2222");
ipv6test(False,"1111");

# Missing :
ipv6test(False,"11112222:3333:4444:5555:6666:7777:8888");
ipv6test(False,"1111:22223333:4444:5555:6666:7777:8888");
ipv6test(False,"1111:2222:33334444:5555:6666:7777:8888");
ipv6test(False,"1111:2222:3333:44445555:6666:7777:8888");
ipv6test(False,"1111:2222:3333:4444:55556666:7777:8888");
ipv6test(False,"1111:2222:3333:4444:5555:66667777:8888");
ipv6test(False,"1111:2222:3333:4444:5555:6666:77778888");

# Missing : intended for ::
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:8888:");
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:");
ipv6test(False,"1111:2222:3333:4444:5555:6666:");
ipv6test(False,"1111:2222:3333:4444:5555:");
ipv6test(False,"1111:2222:3333:4444:");
ipv6test(False,"1111:2222:3333:");
ipv6test(False,"1111:2222:");
ipv6test(False,"1111:");
ipv6test(False,":");
ipv6test(False,":8888");
ipv6test(False,":7777:8888");
ipv6test(False,":6666:7777:8888");
ipv6test(False,":5555:6666:7777:8888");
ipv6test(False,":4444:5555:6666:7777:8888");
ipv6test(False,":3333:4444:5555:6666:7777:8888");
ipv6test(False,":2222:3333:4444:5555:6666:7777:8888");
ipv6test(False,":1111:2222:3333:4444:5555:6666:7777:8888");

# :::
ipv6test(False,":::2222:3333:4444:5555:6666:7777:8888");
ipv6test(False,"1111:::3333:4444:5555:6666:7777:8888");
ipv6test(False,"1111:2222:::4444:5555:6666:7777:8888");
ipv6test(False,"1111:2222:3333:::5555:6666:7777:8888");
ipv6test(False,"1111:2222:3333:4444:::6666:7777:8888");
ipv6test(False,"1111:2222:3333:4444:5555:::7777:8888");
ipv6test(False,"1111:2222:3333:4444:5555:6666:::8888");
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:::");

# Double ::");
ipv6test(False,"::2222::4444:5555:6666:7777:8888");
ipv6test(False,"::2222:3333::5555:6666:7777:8888");
ipv6test(False,"::2222:3333:4444::6666:7777:8888");
ipv6test(False,"::2222:3333:4444:5555::7777:8888");
ipv6test(False,"::2222:3333:4444:5555:7777::8888");
ipv6test(False,"::2222:3333:4444:5555:7777:8888::");

ipv6test(False,"1111::3333::5555:6666:7777:8888");
ipv6test(False,"1111::3333:4444::6666:7777:8888");
ipv6test(False,"1111::3333:4444:5555::7777:8888");
ipv6test(False,"1111::3333:4444:5555:6666::8888");
ipv6test(False,"1111::3333:4444:5555:6666:7777::");

ipv6test(False,"1111:2222::4444::6666:7777:8888");
ipv6test(False,"1111:2222::4444:5555::7777:8888");
ipv6test(False,"1111:2222::4444:5555:6666::8888");
ipv6test(False,"1111:2222::4444:5555:6666:7777::");

ipv6test(False,"1111:2222:3333::5555::7777:8888");
ipv6test(False,"1111:2222:3333::5555:6666::8888");
ipv6test(False,"1111:2222:3333::5555:6666:7777::");

ipv6test(False,"1111:2222:3333:4444::6666::8888");
ipv6test(False,"1111:2222:3333:4444::6666:7777::");

ipv6test(False,"1111:2222:3333:4444:5555::7777::");

# Too many components"
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:6666::1.2.3.4");
ipv6test(False,"::2222:3333:4444:5555:6666:7777:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:6666:1.2.3.4.5");

# Too few components
ipv6test(False,"1111:2222:3333:4444:5555:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:1.2.3.4");
ipv6test(False,"1111:2222:3333:1.2.3.4");
ipv6test(False,"1111:2222:1.2.3.4");
ipv6test(False,"1111:1.2.3.4");
ipv6test(False,"1.2.3.4");

# Missing :
ipv6test(False,"11112222:3333:4444:5555:6666:1.2.3.4");
ipv6test(False,"1111:22223333:4444:5555:6666:1.2.3.4");
ipv6test(False,"1111:2222:33334444:5555:6666:1.2.3.4");
ipv6test(False,"1111:2222:3333:44445555:6666:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:55556666:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:66661.2.3.4");

# Missing .
ipv6test(False,"1111:2222:3333:4444:5555:6666:255255.255.255");
ipv6test(False,"1111:2222:3333:4444:5555:6666:255.255255.255");
ipv6test(False,"1111:2222:3333:4444:5555:6666:255.255.255255");

# Missing : intended for ::
ipv6test(False,":1.2.3.4");
ipv6test(False,":6666:1.2.3.4");
ipv6test(False,":5555:6666:1.2.3.4");
ipv6test(False,":4444:5555:6666:1.2.3.4");
ipv6test(False,":3333:4444:5555:6666:1.2.3.4");
ipv6test(False,":2222:3333:4444:5555:6666:1.2.3.4");
ipv6test(False,":1111:2222:3333:4444:5555:6666:1.2.3.4");

# :::
ipv6test(False,":::2222:3333:4444:5555:6666:1.2.3.4");
ipv6test(False,"1111:::3333:4444:5555:6666:1.2.3.4");
ipv6test(False,"1111:2222:::4444:5555:6666:1.2.3.4");
ipv6test(False,"1111:2222:3333:::5555:6666:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:::6666:1.2.3.4");
ipv6test(False,"1111:2222:3333:4444:5555:::1.2.3.4");

# Double ::
ipv6test(False,"::2222::4444:5555:6666:1.2.3.4");
ipv6test(False,"::2222:3333::5555:6666:1.2.3.4");
ipv6test(False,"::2222:3333:4444::6666:1.2.3.4");
ipv6test(False,"::2222:3333:4444:5555::1.2.3.4");

ipv6test(False,"1111::3333::5555:6666:1.2.3.4");
ipv6test(False,"1111::3333:4444::6666:1.2.3.4");
ipv6test(False,"1111::3333:4444:5555::1.2.3.4");

ipv6test(False,"1111:2222::4444::6666:1.2.3.4");
ipv6test(False,"1111:2222::4444:5555::1.2.3.4");

ipv6test(False,"1111:2222:3333::5555::1.2.3.4");

# Missing parts
ipv6test(False,"::.");
ipv6test(False,"::..");
ipv6test(False,"::...");
ipv6test(False,"::1...");
ipv6test(False,"::1.2..");
ipv6test(False,"::1.2.3.");
ipv6test(False,"::.2..");
ipv6test(False,"::.2.3.");
ipv6test(False,"::.2.3.4");
ipv6test(False,"::..3.");
ipv6test(False,"::..3.4");
ipv6test(False,"::...4");

# Extra : in front
ipv6test(False,":1111:2222:3333:4444:5555:6666:7777::");
ipv6test(False,":1111:2222:3333:4444:5555:6666::");
ipv6test(False,":1111:2222:3333:4444:5555::");
ipv6test(False,":1111:2222:3333:4444::");
ipv6test(False,":1111:2222:3333::");
ipv6test(False,":1111:2222::");
ipv6test(False,":1111::");
ipv6test(False,":::");
ipv6test(False,":1111:2222:3333:4444:5555:6666::8888");
ipv6test(False,":1111:2222:3333:4444:5555::8888");
ipv6test(False,":1111:2222:3333:4444::8888");
ipv6test(False,":1111:2222:3333::8888");
ipv6test(False,":1111:2222::8888");
ipv6test(False,":1111::8888");
ipv6test(False,":::8888");
ipv6test(False,":1111:2222:3333:4444:5555::7777:8888");
ipv6test(False,":1111:2222:3333:4444::7777:8888");
ipv6test(False,":1111:2222:3333::7777:8888");
ipv6test(False,":1111:2222::7777:8888");
ipv6test(False,":1111::7777:8888");
ipv6test(False,":::7777:8888");
ipv6test(False,":1111:2222:3333:4444::6666:7777:8888");
ipv6test(False,":1111:2222:3333::6666:7777:8888");
ipv6test(False,":1111:2222::6666:7777:8888");
ipv6test(False,":1111::6666:7777:8888");
ipv6test(False,":::6666:7777:8888");
ipv6test(False,":1111:2222:3333::5555:6666:7777:8888");
ipv6test(False,":1111:2222::5555:6666:7777:8888");
ipv6test(False,":1111::5555:6666:7777:8888");
ipv6test(False,":::5555:6666:7777:8888");
ipv6test(False,":1111:2222::4444:5555:6666:7777:8888");
ipv6test(False,":1111::4444:5555:6666:7777:8888");
ipv6test(False,":::4444:5555:6666:7777:8888");
ipv6test(False,":1111::3333:4444:5555:6666:7777:8888");
ipv6test(False,":::3333:4444:5555:6666:7777:8888");
ipv6test(False,":::2222:3333:4444:5555:6666:7777:8888");
ipv6test(False,":1111:2222:3333:4444:5555:6666:1.2.3.4");
ipv6test(False,":1111:2222:3333:4444:5555::1.2.3.4");
ipv6test(False,":1111:2222:3333:4444::1.2.3.4");
ipv6test(False,":1111:2222:3333::1.2.3.4");
ipv6test(False,":1111:2222::1.2.3.4");
ipv6test(False,":1111::1.2.3.4");
ipv6test(False,":::1.2.3.4");
ipv6test(False,":1111:2222:3333:4444::6666:1.2.3.4");
ipv6test(False,":1111:2222:3333::6666:1.2.3.4");
ipv6test(False,":1111:2222::6666:1.2.3.4");
ipv6test(False,":1111::6666:1.2.3.4");
ipv6test(False,":::6666:1.2.3.4");
ipv6test(False,":1111:2222:3333::5555:6666:1.2.3.4");
ipv6test(False,":1111:2222::5555:6666:1.2.3.4");
ipv6test(False,":1111::5555:6666:1.2.3.4");
ipv6test(False,":::5555:6666:1.2.3.4");
ipv6test(False,":1111:2222::4444:5555:6666:1.2.3.4");
ipv6test(False,":1111::4444:5555:6666:1.2.3.4");
ipv6test(False,":::4444:5555:6666:1.2.3.4");
ipv6test(False,":1111::3333:4444:5555:6666:1.2.3.4");
ipv6test(False,":::2222:3333:4444:5555:6666:1.2.3.4");

# Extra : at end
ipv6test(False,"1111:2222:3333:4444:5555:6666:7777:::");
ipv6test(False,"1111:2222:3333:4444:5555:6666:::");
ipv6test(False,"1111:2222:3333:4444:5555:::");
ipv6test(False,"1111:2222:3333:4444:::");
ipv6test(False,"1111:2222:3333:::");
ipv6test(False,"1111:2222:::");
ipv6test(False,"1111:::");
ipv6test(False,":::");
ipv6test(False,"1111:2222:3333:4444:5555:6666::8888:");
ipv6test(False,"1111:2222:3333:4444:5555::8888:");
ipv6test(False,"1111:2222:3333:4444::8888:");
ipv6test(False,"1111:2222:3333::8888:");
ipv6test(False,"1111:2222::8888:");
ipv6test(False,"1111::8888:");
ipv6test(False,"::8888:");
ipv6test(False,"1111:2222:3333:4444:5555::7777:8888:");
ipv6test(False,"1111:2222:3333:4444::7777:8888:");
ipv6test(False,"1111:2222:3333::7777:8888:");
ipv6test(False,"1111:2222::7777:8888:");
ipv6test(False,"1111::7777:8888:");
ipv6test(False,"::7777:8888:");
ipv6test(False,"1111:2222:3333:4444::6666:7777:8888:");
ipv6test(False,"1111:2222:3333::6666:7777:8888:");
ipv6test(False,"1111:2222::6666:7777:8888:");
ipv6test(False,"1111::6666:7777:8888:");
ipv6test(False,"::6666:7777:8888:");
ipv6test(False,"1111:2222:3333::5555:6666:7777:8888:");
ipv6test(False,"1111:2222::5555:6666:7777:8888:");
ipv6test(False,"1111::5555:6666:7777:8888:");
ipv6test(False,"::5555:6666:7777:8888:");
ipv6test(False,"1111:2222::4444:5555:6666:7777:8888:");
ipv6test(False,"1111::4444:5555:6666:7777:8888:");
ipv6test(False,"::4444:5555:6666:7777:8888:");
ipv6test(False,"1111::3333:4444:5555:6666:7777:8888:");
ipv6test(False,"::3333:4444:5555:6666:7777:8888:");
ipv6test(False,"::2222:3333:4444:5555:6666:7777:8888:");

# Additional cases: http://crisp.tweakblogs.net/blog/2031/ipv6-validation-%28and-caveats%29.html
ipv6test(True,"0:a:b:c:d:e:f::");
ipv6test(True,"::0:a:b:c:d:e:f"); # syntactically correct, but bad form (::0:... could be combined)
ipv6test(True,"a:b:c:d:e:f:0::");
ipv6test(False,"':10.0.0.1");
ghost commented 6 years ago

I checked in those tests: 343c1222387b85cc6882792960e7f202b39b76e1

There are some test failures though: If I add those tests to the ipaddr plugin (which does a regex check) these failures happen:

ipv6 address “::” returned -1 instead of 1
ipv6 address “FF01::101::2” returned 1 instead of -1
ipv6 address “3ffe:b00::1::a” returned 1 instead of -1
ipv6 address “::2:3:4:5:6:7:8” returned -1 instead of 1
ipv6 address “1:2:3:4:5:6:1.2.3.4” returned -1 instead of 1
ipv6 address “1:2:3:4:5::1.2.3.4” returned -1 instead of 1
ipv6 address “1:2:3:4::5:1.2.3.4” returned -1 instead of 1
ipv6 address “0:0:0:0:0:0:13.1.68.3” returned -1 instead of 1
ipv6 address “0:0:0:0:0:FFFF:129.144.52.38” returned -1 instead of 1
ipv6 address “fe80:0:0:0:204:61ff:254.157.241.86” returned -1 instead of 1
ipv6 address “1111:2222:3333:4444::5555:” returned 1 instead of -1
ipv6 address “1111:2222:3333::5555:” returned 1 instead of -1
ipv6 address “1111:2222::5555:” returned 1 instead of -1
ipv6 address “1111::5555:” returned 1 instead of -1
ipv6 address “:1111:2222:3333:4444::5555” returned 1 instead of -1
ipv6 address “:1111:2222:3333::5555” returned 1 instead of -1
ipv6 address “:1111:2222::5555” returned 1 instead of -1
ipv6 address “:1111::5555” returned 1 instead of -1
ipv6 address “:::5555” returned 1 instead of -1
ipv6 address “2001::FFD3::57ab” returned 1 instead of -1
ipv6 address “1::2::3” returned 1 instead of -1
ipv6 address “1:::3:4:5” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444:5555:6666:7777::” returned -1 instead of 1
ipv6 address “::2222:3333:4444:5555:6666:7777:8888” returned -1 instead of 1
ipv6 address “1111:2222:3333:4444:5555:6666:123.123.123.123” returned -1 instead of 1
ipv6 address “1111:2222:3333:4444:5555::123.123.123.123” returned -1 instead of 1
ipv6 address “1111:2222:3333:4444::6666:123.123.123.123” returned -1 instead of 1
ipv6 address “1111:2222:3333::5555:6666:123.123.123.123” returned -1 instead of 1
ipv6 address “1111:2222::4444:5555:6666:123.123.123.123” returned -1 instead of 1
ipv6 address “1111::3333:4444:5555:6666:123.123.123.123” returned -1 instead of 1
ipv6 address “::2222:3333:4444:5555:6666:123.123.123.123” returned -1 instead of 1
ipv6 address “::0:0:0:0:0:0:0” returned -1 instead of 1
ipv6 address “0:0:0:0:0:0:0::” returned -1 instead of 1
ipv6 address “1111:2222:3333:4444:5555:6666:7777:” returned 1 instead of -1
ipv6 address “:2222:3333:4444:5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “1111::3333::5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “1111::3333:4444::6666:7777:8888” returned 1 instead of -1
ipv6 address “1111::3333:4444:5555::7777:8888” returned 1 instead of -1
ipv6 address “1111::3333:4444:5555:6666::8888” returned 1 instead of -1
ipv6 address “1111:2222::4444::6666:7777:8888” returned 1 instead of -1
ipv6 address “1111:2222::4444:5555::7777:8888” returned 1 instead of -1
ipv6 address “1111:2222::4444:5555:6666::8888” returned 1 instead of -1
ipv6 address “1111:2222:3333::5555::7777:8888” returned 1 instead of -1
ipv6 address “1111:2222:3333::5555:6666::8888” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444::6666::8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333:4444:5555::8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333:4444::8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333::8888” returned 1 instead of -1
ipv6 address “:1111:2222::8888” returned 1 instead of -1
ipv6 address “:1111::8888” returned 1 instead of -1
ipv6 address “:::8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333:4444::7777:8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333::7777:8888” returned 1 instead of -1
ipv6 address “:1111:2222::7777:8888” returned 1 instead of -1
ipv6 address “:1111::7777:8888” returned 1 instead of -1
ipv6 address “:::7777:8888” returned 1 instead of -1
ipv6 address “:1111:2222:3333::6666:7777:8888” returned 1 instead of -1
ipv6 address “:1111:2222::6666:7777:8888” returned 1 instead of -1
ipv6 address “:1111::6666:7777:8888” returned 1 instead of -1
ipv6 address “:::6666:7777:8888” returned 1 instead of -1
ipv6 address “:1111:2222::5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “:1111::5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “:::5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “:1111::4444:5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “:::4444:5555:6666:7777:8888” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444:5555:::” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444:::” returned 1 instead of -1
ipv6 address “1111:2222:3333:::” returned 1 instead of -1
ipv6 address “1111:2222:::” returned 1 instead of -1
ipv6 address “1111:::” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444:5555::8888:” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444::8888:” returned 1 instead of -1
ipv6 address “1111:2222:3333::8888:” returned 1 instead of -1
ipv6 address “1111:2222::8888:” returned 1 instead of -1
ipv6 address “1111::8888:” returned 1 instead of -1
ipv6 address “1111:2222:3333:4444::7777:8888:” returned 1 instead of -1
ipv6 address “1111:2222:3333::7777:8888:” returned 1 instead of -1
ipv6 address “1111:2222::7777:8888:” returned 1 instead of -1
ipv6 address “1111::7777:8888:” returned 1 instead of -1
ipv6 address “1111:2222:3333::6666:7777:8888:” returned 1 instead of -1
ipv6 address “1111:2222::6666:7777:8888:” returned 1 instead of -1
ipv6 address “1111::6666:7777:8888:” returned 1 instead of -1
ipv6 address “1111:2222::5555:6666:7777:8888:” returned 1 instead of -1
ipv6 address “1111::5555:6666:7777:8888:” returned 1 instead of -1
ipv6 address “1111::4444:5555:6666:7777:8888:” returned 1 instead of -1
ipv6 address “0:a:b:c:d:e:f::” returned -1 instead of 1
ipv6 address “::0:a:b:c:d:e:f” returned -1 instead of 1
ipv6 address “a:b:c:d:e:f:0::” returned -1 instead of 1

I decided to include it into the network plugin only which yield the following errors:

ipv6 address “02001:0000:1234:0000:0000:C1C0:ABCD:0876” returned 1 instead of -1
ipv6 address “2001:0000:1234:0000:00001:C1C0:ABCD:0876” returned 1 instead of -1

This seems to be a bug of the netdb.h library?

markus2330 commented 6 years ago

@tom-wa any idea about the regex problems?

This seems to be a bug of the netdb.h library?

Maybe the tests are wrong? Why are these invalid IPv6 addresses?

ghost commented 6 years ago

They both have trailing zeros

1st test: 02001 2nd test: 00001

ghost commented 6 years ago

On some travis builds also these tests fail (used in the network):

// Testing IPv4 addresses represented as dotted-quads
// Leading zero's in IPv4 addresses not allowed: some systems treat the leading "0" in ".086" as the start of an octal number
// Update: The BNF in RFC-3986 explicitly defines the dec-octet (for IPv4 addresses) not to have a leading zero

testIPv6("fe80:0000:0000:0000:0204:61ff:254.157.241.086", -1);
testIPv6("1111:2222:3333:4444:5555:6666:00.00.00.00", -1);
testIPv6("1111:2222:3333:4444:5555:6666:000.000.000.000", -1);

I also exclude those tests as there is no way to fix it since its in the library.

stale[bot] commented 4 years ago

I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:

stale[bot] commented 4 years ago

I closed this issue now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart: