1+ import ipaddress
12import time
23from test .integration .conftest import get_region
34from test .integration .helpers import (
@@ -651,7 +652,7 @@ def __assert_public(iface: LinodeInterface):
651652 __assert_base (iface )
652653
653654 assert not iface .default_route .ipv4
654- assert iface .default_route .ipv6
655+ assert not iface .default_route .ipv6
655656
656657 assert len (iface .public .ipv4 .addresses ) == 0
657658 assert len (iface .public .ipv4 .shared ) == 0
@@ -666,7 +667,7 @@ def __assert_vpc(iface: LinodeInterface):
666667 __assert_base (iface )
667668
668669 assert iface .default_route .ipv4
669- assert not iface .default_route .ipv6
670+ assert iface .default_route .ipv6
670671
671672 assert iface .vpc .vpc_id == vpc .id
672673 assert iface .vpc .subnet_id == subnet .id
@@ -679,8 +680,18 @@ def __assert_vpc(iface: LinodeInterface):
679680 assert len (iface .vpc .ipv4 .ranges ) == 1
680681 assert iface .vpc .ipv4 .ranges [0 ].range == "10.0.0.5/32"
681682
683+ assert len (iface .vpc .ipv6 .slaac ) == 1
684+
685+ ipaddress .IPv6Network (iface .vpc .ipv6 .slaac [0 ].range )
686+ ipaddress .IPv6Address (iface .vpc .ipv6 .slaac [0 ].address )
687+
688+ assert len (iface .vpc .ipv6 .ranges ) == 0
689+ assert iface .vpc .ipv6 .is_public is False
690+
682691 def __assert_vlan (iface : LinodeInterface ):
683692 __assert_base (iface )
693+ print (iface .__dict__ )
694+ print (vars (iface .default_route ))
684695
685696 assert not iface .default_route .ipv4
686697 assert not iface .default_route .ipv6
@@ -888,9 +899,12 @@ def test_create_vpc(
888899 test_linode_client ,
889900 linode_and_vpc_for_legacy_interface_tests_offline ,
890901 ):
891- vpc , subnet , linode , _ = (
892- linode_and_vpc_for_legacy_interface_tests_offline
893- )
902+ (
903+ vpc ,
904+ subnet ,
905+ linode ,
906+ _ ,
907+ ) = linode_and_vpc_for_legacy_interface_tests_offline
894908
895909 config : Config = linode .configs [0 ]
896910
@@ -927,11 +941,30 @@ def test_create_vpc(
927941 assert vpc_range_ip .address_range == "10.0.0.5/32"
928942 assert not vpc_range_ip .active
929943
944+ assert isinstance (vpc .ipv6 , list )
945+ assert len (vpc .ipv6 ) > 0
946+ assert isinstance (vpc .ipv6 [0 ].range , str )
947+ assert ":" in vpc .ipv6 [0 ].range
948+
930949 # TODO:: Add `VPCIPAddress.filters.linode_id == linode.id` filter back
931950
932951 # Attempt to resolve the IP from /vpcs/ips
933952 all_vpc_ips = test_linode_client .vpcs .ips ()
934- assert all_vpc_ips [0 ].dict == vpc_ip .dict
953+ matched_ip = next (
954+ (
955+ ip
956+ for ip in all_vpc_ips
957+ if ip .address == vpc_ip .address
958+ and ip .vpc_id == vpc_ip .vpc_id
959+ and ip .linode_id == vpc_ip .linode_id
960+ ),
961+ None ,
962+ )
963+
964+ assert (
965+ matched_ip is not None
966+ ), f"Expected VPC IP { vpc_ip .address } not found in /vpcs/ips"
967+ assert matched_ip .dict == vpc_ip .dict
935968
936969 # Test getting the ips under this specific VPC
937970 vpc_ips = vpc .ips
@@ -941,13 +974,50 @@ def test_create_vpc(
941974 assert vpc_ips [0 ].linode_id == linode .id
942975 assert vpc_ips [0 ].nat_1_1 == linode .ips .ipv4 .public [0 ].address
943976
977+ # Validate VPC IPv6 IPs from /vpcs/ips
978+ all_vpc_ipv6 = test_linode_client .get ("/vpcs/ipv6s" )["data" ]
979+
980+ # Find matching VPC IPv6 entry
981+ matched_ipv6 = next (
982+ (
983+ ip
984+ for ip in all_vpc_ipv6
985+ if ip ["vpc_id" ] == vpc .id
986+ and ip ["linode_id" ] == linode .id
987+ and ip ["interface_id" ] == interface .id
988+ and ip ["subnet_id" ] == subnet .id
989+ ),
990+ None ,
991+ )
992+
993+ assert (
994+ matched_ipv6
995+ ), f"No VPC IPv6 found for Linode { linode .id } in VPC { vpc .id } "
996+
997+ assert matched_ipv6 ["ipv6_range" ].count (":" ) >= 2
998+ assert not matched_ipv6 ["ipv6_is_public" ]
999+
1000+ ipv6_addresses = matched_ipv6 .get ("ipv6_addresses" , [])
1001+ assert (
1002+ isinstance (ipv6_addresses , list ) and ipv6_addresses
1003+ ), "No IPv6 addresses found"
1004+
1005+ slaac = ipv6_addresses [0 ]
1006+ assert (
1007+ isinstance (slaac .get ("slaac_address" ), str )
1008+ and ":" in slaac ["slaac_address" ]
1009+ )
1010+
9441011 def test_update_vpc (
9451012 self ,
9461013 linode_and_vpc_for_legacy_interface_tests_offline ,
9471014 ):
948- vpc , subnet , linode , _ = (
949- linode_and_vpc_for_legacy_interface_tests_offline
950- )
1015+ (
1016+ vpc ,
1017+ subnet ,
1018+ linode ,
1019+ _ ,
1020+ ) = linode_and_vpc_for_legacy_interface_tests_offline
9511021
9521022 config : Config = linode .configs [0 ]
9531023
0 commit comments