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,6 +680,14 @@ 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 )
684693
@@ -888,9 +897,12 @@ def test_create_vpc(
888897 test_linode_client ,
889898 linode_and_vpc_for_legacy_interface_tests_offline ,
890899 ):
891- vpc , subnet , linode , _ = (
892- linode_and_vpc_for_legacy_interface_tests_offline
893- )
900+ (
901+ vpc ,
902+ subnet ,
903+ linode ,
904+ _ ,
905+ ) = linode_and_vpc_for_legacy_interface_tests_offline
894906
895907 config : Config = linode .configs [0 ]
896908
@@ -927,11 +939,30 @@ def test_create_vpc(
927939 assert vpc_range_ip .address_range == "10.0.0.5/32"
928940 assert not vpc_range_ip .active
929941
942+ assert isinstance (vpc .ipv6 , list )
943+ assert len (vpc .ipv6 ) > 0
944+ assert isinstance (vpc .ipv6 [0 ].range , str )
945+ assert ":" in vpc .ipv6 [0 ].range
946+
930947 # TODO:: Add `VPCIPAddress.filters.linode_id == linode.id` filter back
931948
932949 # Attempt to resolve the IP from /vpcs/ips
933950 all_vpc_ips = test_linode_client .vpcs .ips ()
934- assert all_vpc_ips [0 ].dict == vpc_ip .dict
951+ matched_ip = next (
952+ (
953+ ip
954+ for ip in all_vpc_ips
955+ if ip .address == vpc_ip .address
956+ and ip .vpc_id == vpc_ip .vpc_id
957+ and ip .linode_id == vpc_ip .linode_id
958+ ),
959+ None ,
960+ )
961+
962+ assert (
963+ matched_ip is not None
964+ ), f"Expected VPC IP { vpc_ip .address } not found in /vpcs/ips"
965+ assert matched_ip .dict == vpc_ip .dict
935966
936967 # Test getting the ips under this specific VPC
937968 vpc_ips = vpc .ips
@@ -941,13 +972,50 @@ def test_create_vpc(
941972 assert vpc_ips [0 ].linode_id == linode .id
942973 assert vpc_ips [0 ].nat_1_1 == linode .ips .ipv4 .public [0 ].address
943974
975+ # Validate VPC IPv6 IPs from /vpcs/ips
976+ all_vpc_ipv6 = test_linode_client .get ("/vpcs/ipv6s" )["data" ]
977+
978+ # Find matching VPC IPv6 entry
979+ matched_ipv6 = next (
980+ (
981+ ip
982+ for ip in all_vpc_ipv6
983+ if ip ["vpc_id" ] == vpc .id
984+ and ip ["linode_id" ] == linode .id
985+ and ip ["interface_id" ] == interface .id
986+ and ip ["subnet_id" ] == subnet .id
987+ ),
988+ None ,
989+ )
990+
991+ assert (
992+ matched_ipv6
993+ ), f"No VPC IPv6 found for Linode { linode .id } in VPC { vpc .id } "
994+
995+ assert matched_ipv6 ["ipv6_range" ].count (":" ) >= 2
996+ assert not matched_ipv6 ["ipv6_is_public" ]
997+
998+ ipv6_addresses = matched_ipv6 .get ("ipv6_addresses" , [])
999+ assert (
1000+ isinstance (ipv6_addresses , list ) and ipv6_addresses
1001+ ), "No IPv6 addresses found"
1002+
1003+ slaac = ipv6_addresses [0 ]
1004+ assert (
1005+ isinstance (slaac .get ("slaac_address" ), str )
1006+ and ":" in slaac ["slaac_address" ]
1007+ )
1008+
9441009 def test_update_vpc (
9451010 self ,
9461011 linode_and_vpc_for_legacy_interface_tests_offline ,
9471012 ):
948- vpc , subnet , linode , _ = (
949- linode_and_vpc_for_legacy_interface_tests_offline
950- )
1013+ (
1014+ vpc ,
1015+ subnet ,
1016+ linode ,
1017+ _ ,
1018+ ) = linode_and_vpc_for_legacy_interface_tests_offline
9511019
9521020 config : Config = linode .configs [0 ]
9531021
0 commit comments