33from utilities .testing import APIViewTestCases
44from virtualization .models import Cluster , ClusterType , VirtualMachine
55
6- from netbox_acls .choices import *
7- from netbox_acls .models import *
6+ from netbox_acls .choices import (
7+ ACLActionChoices ,
8+ ACLProtocolChoices ,
9+ ACLRuleActionChoices ,
10+ ACLTypeChoices ,
11+ )
12+ from netbox_acls .models import AccessList , ACLExtendedRule , ACLStandardRule
813
914
1015class ACLStandardRuleAPIViewTestCase (APIViewTestCases .APIViewTestCase ):
@@ -98,7 +103,7 @@ def setUpTestData(cls):
98103 index = 10 ,
99104 description = "Rule 10" ,
100105 action = ACLRuleActionChoices .ACTION_PERMIT ,
101- source_prefix = prefix1 ,
106+ source = prefix1 ,
102107 ),
103108 ACLStandardRule (
104109 access_list = access_list_device ,
@@ -112,7 +117,7 @@ def setUpTestData(cls):
112117 index = 10 ,
113118 description = "Rule 10" ,
114119 action = ACLRuleActionChoices .ACTION_DENY ,
115- source_prefix = prefix2 ,
120+ source = prefix2 ,
116121 ),
117122 )
118123 ACLStandardRule .objects .bulk_create (acl_standard_rules )
@@ -123,14 +128,16 @@ def setUpTestData(cls):
123128 "index" : 30 ,
124129 "description" : "Rule 30" ,
125130 "action" : ACLRuleActionChoices .ACTION_DENY ,
126- "source_prefix" : prefix2 .id ,
131+ "source_type" : "ipam.prefix" ,
132+ "source_id" : prefix2 .id ,
127133 },
128134 {
129135 "access_list" : access_list_vm .id ,
130136 "index" : 20 ,
131137 "description" : "Rule 30" ,
132138 "action" : ACLRuleActionChoices .ACTION_PERMIT ,
133- "source_prefix" : prefix1 .id ,
139+ "source_type" : "ipam.prefix" ,
140+ "source_id" : prefix1 .id ,
134141 },
135142 {
136143 "access_list" : access_list_vm .id ,
@@ -237,9 +244,9 @@ def setUpTestData(cls):
237244 description = "Rule 10" ,
238245 action = ACLRuleActionChoices .ACTION_PERMIT ,
239246 protocol = ACLProtocolChoices .PROTOCOL_TCP ,
240- source_prefix = prefix1 ,
247+ source = prefix1 ,
241248 source_ports = [22 , 443 ],
242- destination_prefix = prefix1 ,
249+ destination = prefix1 ,
243250 destination_ports = [22 , 443 ],
244251 ),
245252 ACLExtendedRule (
@@ -254,8 +261,8 @@ def setUpTestData(cls):
254261 index = 10 ,
255262 description = "Rule 10" ,
256263 action = ACLRuleActionChoices .ACTION_DENY ,
257- source_prefix = prefix2 ,
258- destination_prefix = prefix1 ,
264+ source = prefix2 ,
265+ destination = prefix1 ,
259266 ),
260267 )
261268 ACLExtendedRule .objects .bulk_create (acl_extended_rules )
@@ -267,9 +274,11 @@ def setUpTestData(cls):
267274 "description" : "Rule 30" ,
268275 "action" : ACLRuleActionChoices .ACTION_DENY ,
269276 "protocol" : ACLProtocolChoices .PROTOCOL_UDP ,
270- "source_prefix" : prefix2 .id ,
277+ "source_type" : "ipam.prefix" ,
278+ "source_id" : prefix2 .id ,
271279 "source_ports" : [53 ],
272- "destination_prefix" : prefix2 .id ,
280+ "destination_type" : "ipam.prefix" ,
281+ "destination_id" : prefix2 .id ,
273282 "destination_ports" : [53 ],
274283 },
275284 {
@@ -278,8 +287,10 @@ def setUpTestData(cls):
278287 "description" : "Rule 30" ,
279288 "action" : ACLRuleActionChoices .ACTION_PERMIT ,
280289 "protocol" : ACLProtocolChoices .PROTOCOL_ICMP ,
281- "source_prefix" : prefix1 .id ,
282- "destination_prefix" : prefix2 .id ,
290+ "source_type" : "ipam.prefix" ,
291+ "source_id" : prefix1 .id ,
292+ "destination_type" : "ipam.prefix" ,
293+ "destination_id" : prefix2 .id ,
283294 },
284295 {
285296 "access_list" : access_list_vm .id ,
0 commit comments