5252 site_type = "core" ,
5353)
5454
55- TEST_NAT_REGION = get_region (
56- LinodeClient (
57- token = get_token (),
58- base_url = get_api_url (),
59- ca_path = get_api_ca_file (),
60- ),
61- {
62- Capability .firewall ,
63- Capability .linodes ,
64- Capability .linode_interfaces ,
65- Capability .natgateway ,
66- Capability .vpcs ,
67- },
68- site_type = "core" ,
69- )
70-
7155
7256def create_linode_func (test_linode_client ):
7357 client = test_linode_client
@@ -156,22 +140,6 @@ def create_firewall_with_device(create_linode_without_firewall):
156140 firewall .delete ()
157141
158142
159- @pytest .fixture
160- def create_nat_vpc (test_linode_client ):
161- client = test_linode_client
162- label = get_test_label (length = 10 )
163-
164- vpc = client .vpcs .create (
165- label = label ,
166- region = TEST_NAT_REGION ,
167- description = "test NAT Gateway VPC" ,
168- ipv6 = [{"range" : "auto" }],
169- )
170- yield vpc
171-
172- vpc .delete ()
173-
174-
175143@pytest .fixture
176144def create_nat_vpc_with_subnet (test_linode_client , create_nat_vpc ):
177145 subnet = create_nat_vpc .subnet_create (
@@ -205,25 +173,6 @@ def create_nat_vpc_with_subnet_and_linode(
205173 instance .delete ()
206174
207175
208- @pytest .fixture
209- def create_nat_gateway (request , test_linode_client ):
210- client = test_linode_client
211- label = "nat-gateway-" + get_test_label (length = 8 )
212- autoscaling = getattr (request , "param" , True )
213-
214- natgateway = client .networking .natgateway_create (
215- label = label ,
216- region = TEST_NAT_REGION ,
217- use_autoscaling = autoscaling ,
218- )
219-
220- yield natgateway
221-
222- # Delete only if NAT Gateway exists (some tests may delete it earlier)
223- if client .load (NATGateway , natgateway .id ):
224- natgateway .delete ()
225-
226-
227176def test_get_networking_rule_versions (test_linode_client , test_firewall ):
228177 firewall = test_linode_client .load (Firewall , test_firewall .id )
229178
@@ -654,6 +603,14 @@ def test_convert_unassigned_reserved_ip_to_ephemeral(
654603 assert len (reserved_ips_list ) == 0
655604
656605
606+ def verify_nat_gateway_ifaces (gateway_ifaces , linode , reserved_ip ):
607+ assert len (gateway_ifaces ) == 1
608+ assert gateway_ifaces [0 ].id == linode .linode_interfaces [0 ].id
609+ assert gateway_ifaces [0 ].linode .id == linode .id
610+ assert gateway_ifaces [0 ].addresses [0 ] == reserved_ip .address
611+ assert gateway_ifaces [0 ].portsets [0 ].address == reserved_ip .address
612+
613+
657614@pytest .mark .smoke
658615def test_create_nat_gateway (test_linode_client , create_nat_gateway ):
659616 client = test_linode_client
@@ -682,7 +639,7 @@ def test_update_nat_gateway_with_ip_address(
682639 test_linode_client , create_nat_gateway , create_reserved_ip
683640):
684641 client = test_linode_client
685- gateway = client . load ( NATGateway , create_nat_gateway . id )
642+ gateway = create_nat_gateway
686643 reserved_ip = create_reserved_ip
687644
688645 gateway .address_assignment_create (reserved_ip .address )
@@ -701,7 +658,7 @@ def test_get_nat_gateway_linode_ifaces(
701658 create_reserved_ip ,
702659):
703660 client = test_linode_client
704- gateway = client . load ( NATGateway , create_nat_gateway . id )
661+ gateway = create_nat_gateway
705662 vpc , subnet , linode = create_nat_vpc_with_subnet_and_linode
706663 reserved_ip = create_reserved_ip
707664
@@ -732,16 +689,13 @@ def test_get_nat_gateway_linode_ifaces(
732689 ),
733690 ),
734691 )
692+ linode = client .load (Instance , linode .id )
735693
736694 gateway_ifaces = gateway .interfaces ()
737- linode = client . load ( Instance , linode . id )
695+ verify_nat_gateway_ifaces ( gateway_ifaces , linode , reserved_ip )
738696
739- assert len (gateway_ifaces ) == 1
740- assert gateway .vpc_subnet .id == subnet .id
741- assert gateway_ifaces [0 ].id == linode .linode_interfaces [0 ].id
742- assert gateway_ifaces [0 ].linode .id == linode .id
743- assert gateway_ifaces [0 ].addresses [0 ] == reserved_ip .address
744- assert gateway_ifaces [0 ].portsets [0 ].address == reserved_ip .address
697+ gateway_ifaces = gateway .address_interfaces (reserved_ip .address )
698+ verify_nat_gateway_ifaces (gateway_ifaces , linode , reserved_ip )
745699
746700
747701def test_get_nat_gateway_types (test_linode_client ):
0 commit comments