@@ -190,15 +190,17 @@ def test_valid_acl_choices(self):
190
190
)
191
191
192
192
for default_action , acl_type in valid_acl_choices :
193
- valid_acl_choice = AccessList (
193
+ invalid_acl_choice = AccessList (
194
194
name = f"TestACL_Valid_Choice_{ default_action } _{ acl_type } " ,
195
195
comments = f"VALID ACL CHOICES USED: { default_action = } { acl_type = } " ,
196
196
type = acl_type ,
197
197
default_action = default_action ,
198
198
assigned_object_type = ContentType .objects .get_for_model (Device ),
199
199
assigned_object_id = 1 , # TODO - replace with Device.objects.first()
200
200
)
201
- valid_acl_choice .full_clean ()
201
+
202
+ with self .assertRaises (ValidationError ):
203
+ invalid_acl_choice .full_clean ()
202
204
203
205
def test_invalid_acl_choices (self ):
204
206
"""
@@ -284,6 +286,27 @@ def test_acl_interface_assignment_success(self):
284
286
)
285
287
acl_device_interface .full_clean ()
286
288
289
+ def test_aclinterface_assignment_fail (self ):
290
+ """
291
+ Test that ACLInterfaceAssignment passes validation if the ACL is assigned to the host and not already assigned to the vminterface and direction.
292
+ """
293
+ device_acl = AccessList (
294
+ name = "STANDARD_ACL" ,
295
+ comments = "STANDARD_ACL" ,
296
+ type = "standard" ,
297
+ default_action = "permit" ,
298
+ assigned_object_id = 1 ,
299
+ assigned_object_type = ContentType .objects .get_for_model (Device ),
300
+ )
301
+ vm_acl .save ()
302
+ acl_vm_interface = ACLInterfaceAssignment (
303
+ access_list = device_acl ,
304
+ direction = "ingress" ,
305
+ assigned_object_id = 1 ,
306
+ assigned_object_type = ContentType .objects .get_for_model (VMInterface ),
307
+ )
308
+ acl_vm_interface .full_clean ()
309
+
287
310
def test_acl_vminterface_assignment_success (self ):
288
311
"""
289
312
Test that ACLInterfaceAssignment passes validation if the ACL is assigned to the host and not already assigned to the vminterface and direction.
0 commit comments