Przeglądaj źródła

Fixes #19687: Treat cellular interface type as not connectable (#19691)

* Add cellular interface types to WIRELESS_IFACE_TYPES const
Add cable termination test for cellular interface

* Add regression tag to cellular test
Omripresent 8 miesięcy temu
rodzic
commit
afeddee10d
2 zmienionych plików z 18 dodań i 0 usunięć
  1. 5 0
      netbox/dcim/constants.py
  2. 13 0
      netbox/dcim/tests/test_models.py

+ 5 - 0
netbox/dcim/constants.py

@@ -53,6 +53,11 @@ WIRELESS_IFACE_TYPES = [
     InterfaceTypeChoices.TYPE_802151,
     InterfaceTypeChoices.TYPE_802154,
     InterfaceTypeChoices.TYPE_OTHER_WIRELESS,
+    InterfaceTypeChoices.TYPE_GSM,
+    InterfaceTypeChoices.TYPE_CDMA,
+    InterfaceTypeChoices.TYPE_LTE,
+    InterfaceTypeChoices.TYPE_4G,
+    InterfaceTypeChoices.TYPE_5G,
 ]
 
 NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES

+ 13 - 0
netbox/dcim/tests/test_models.py

@@ -954,6 +954,19 @@ class CableTestCase(TestCase):
         with self.assertRaises(ValidationError):
             cable.clean()
 
+    @tag('regression')
+    def test_cable_cannot_terminate_to_a_cellular_interface(self):
+        """
+        A cable cannot terminate to a cellular interface
+        """
+        device1 = Device.objects.get(name='TestDevice1')
+        interface2 = Interface.objects.get(device__name='TestDevice2', name='eth0')
+
+        cellular_interface = Interface(device=device1, name="W1", type=InterfaceTypeChoices.TYPE_LTE)
+        cable = Cable(a_terminations=[interface2], b_terminations=[cellular_interface])
+        with self.assertRaises(ValidationError):
+            cable.clean()
+
 
 class VirtualDeviceContextTestCase(TestCase):