diff --git a/netbox/core/tests/test_api.py b/netbox/core/tests/test_api.py index 0c852636b..bf3d03c30 100644 --- a/netbox/core/tests/test_api.py +++ b/netbox/core/tests/test_api.py @@ -35,6 +35,9 @@ class DataSourceTestCase(APIViewTestCases.APIViewTestCase): 'enabled': False, 'description': 'foo bar baz', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): diff --git a/netbox/tenancy/tests/test_api.py b/netbox/tenancy/tests/test_api.py index dcba0025b..f53b19810 100644 --- a/netbox/tenancy/tests/test_api.py +++ b/netbox/tenancy/tests/test_api.py @@ -28,6 +28,9 @@ class TenantGroupTestCase(APIViewTestCases.APIViewTestCase): 'description': 'New description', 'comments': 'New Comment', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -119,6 +122,9 @@ class TenantTestCase(APIViewTestCases.APIViewTestCase): 'group': None, 'description': 'New description', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -160,6 +166,9 @@ class ContactGroupTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -219,6 +228,9 @@ class ContactRoleTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -238,6 +250,9 @@ class ContactTestCase(APIViewTestCases.APIViewTestCase): 'groups': [], 'comments': 'New comments', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -277,6 +292,9 @@ class ContactAssignmentTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'priority': ContactPriorityChoices.PRIORITY_INACTIVE, } + bulk_update_invalid_data = { + 'priority': 'not-a-valid-priority', + } user_permissions = ('tenancy.view_contact', ) @classmethod diff --git a/netbox/users/tests/test_api.py b/netbox/users/tests/test_api.py index 1e5fd5ccf..22d6adf8b 100644 --- a/netbox/users/tests/test_api.py +++ b/netbox/users/tests/test_api.py @@ -24,6 +24,9 @@ class UserTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'email': 'test@example.com', } + bulk_update_invalid_data = { + 'email': 'not-an-email', + } @classmethod def setUpTestData(cls): @@ -202,6 +205,9 @@ class TokenTestCase( bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'expires': 'not-a-date', + } def setUp(self): super().setUp() @@ -588,6 +594,9 @@ class ObjectPermissionTestCase( cls.bulk_update_data = { 'description': 'New description', } + cls.bulk_update_invalid_data = { + 'users': [99999], + } class UserConfigTestCase(APITestCase): @@ -649,6 +658,11 @@ class OwnerGroupTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + # OwnerGroupSerializer exposes only name, description, and a read-only member_count, so an + # over-length description is the only value available to trigger a validation error. + bulk_update_invalid_data = { + 'description': 'a' * 201, + } @classmethod def setUpTestData(cls): @@ -750,3 +764,7 @@ class OwnerTestCase(APIViewTestCases.APIViewTestCase): 'users': [users[3].pk], 'description': 'New description', } + + cls.bulk_update_invalid_data = { + 'group': 99999, + } diff --git a/netbox/virtualization/tests/test_api.py b/netbox/virtualization/tests/test_api.py index f20c58653..9f00d79aa 100644 --- a/netbox/virtualization/tests/test_api.py +++ b/netbox/virtualization/tests/test_api.py @@ -56,6 +56,9 @@ class ClusterTypeTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -88,6 +91,9 @@ class ClusterGroupTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -107,6 +113,9 @@ class ClusterTestCase(APIViewTestCases.APIViewTestCase): 'status': 'offline', 'comments': 'New comment', } + bulk_update_invalid_data = { + 'status': 'not-a-valid-status', + } @classmethod def setUpTestData(cls): @@ -235,6 +244,9 @@ class VirtualMachineTypeTestCase(APIViewTestCases.APIViewTestCase): 'default_memory': 8192, 'description': 'New description', } + cls.bulk_update_invalid_data = { + 'owner': 99999, + } class VirtualMachineTestCase(APIViewTestCases.APIViewTestCase): @@ -243,6 +255,9 @@ class VirtualMachineTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'status': 'staged', } + bulk_update_invalid_data = { + 'status': 'not-a-valid-status', + } user_permissions = ('dcim.view_platform', 'virtualization.view_virtualmachinetype') @classmethod @@ -624,6 +639,9 @@ class VMInterfaceTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'description': 'New description', } + bulk_update_invalid_data = { + 'mode': 'not-a-valid-mode', + } graphql_base_name = 'vm_interface' user_permissions = ('virtualization.view_virtualmachine', ) @@ -915,6 +933,9 @@ class VirtualDiskTestCase(APIViewTestCases.APIViewTestCase): bulk_update_data = { 'size': 888, } + bulk_update_invalid_data = { + 'virtual_machine': 99999, + } graphql_base_name = 'virtual_disk' user_permissions = ('virtualization.view_virtualmachine', ) diff --git a/netbox/wireless/tests/test_api.py b/netbox/wireless/tests/test_api.py index b5671db32..bbfed9327 100644 --- a/netbox/wireless/tests/test_api.py +++ b/netbox/wireless/tests/test_api.py @@ -40,6 +40,9 @@ class WirelessLANGroupTestCase(APIViewTestCases.APIViewTestCase): 'description': 'New description', 'comments': 'New comment', } + bulk_update_invalid_data = { + 'owner': 99999, + } @classmethod def setUpTestData(cls): @@ -118,6 +121,10 @@ class WirelessLANTestCase(APIViewTestCases.APIViewTestCase): 'auth_psk': 'abc123def456', } + cls.bulk_update_invalid_data = { + 'auth_type': 'not-a-valid-auth-type', + } + class WirelessLinkTestCase(APIViewTestCases.APIViewTestCase): model = WirelessLink @@ -127,6 +134,9 @@ class WirelessLinkTestCase(APIViewTestCases.APIViewTestCase): 'distance': 100, 'distance_unit': 'm', } + bulk_update_invalid_data = { + 'status': 'not-a-valid-status', + } user_permissions = ('dcim.view_interface', ) @classmethod