@@ -190,15 +190,17 @@ def test_valid_acl_choices(self):
190190 )
191191
192192 for default_action , acl_type in valid_acl_choices :
193- valid_acl_choice = AccessList (
193+ invalid_acl_choice = AccessList (
194194 name = f"TestACL_Valid_Choice_{ default_action } _{ acl_type } " ,
195195 comments = f"VALID ACL CHOICES USED: { default_action = } { acl_type = } " ,
196196 type = acl_type ,
197197 default_action = default_action ,
198198 assigned_object_type = ContentType .objects .get_for_model (Device ),
199199 assigned_object_id = 1 , # TODO - replace with Device.objects.first()
200200 )
201- valid_acl_choice .full_clean ()
201+
202+ with self .assertRaises (ValidationError ):
203+ invalid_acl_choice .full_clean ()
202204
203205 def test_invalid_acl_choices (self ):
204206 """
@@ -284,6 +286,27 @@ def test_acl_interface_assignment_success(self):
284286 )
285287 acl_device_interface .full_clean ()
286288
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+
287310 def test_acl_vminterface_assignment_success (self ):
288311 """
289312 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