diff --git a/netbox_diode_plugin/api/views.py b/netbox_diode_plugin/api/views.py index 173a97d..1768e5a 100644 --- a/netbox_diode_plugin/api/views.py +++ b/netbox_diode_plugin/api/views.py @@ -145,7 +145,7 @@ def _additional_attributes_query_filter(self): """Get the additional attributes query filter.""" additional_attributes = {} for attr in self.request.query_params: - if attr not in ["object_type", "id", "q"]: + if attr not in ["object_type", "id", "q", "_branch"]: additional_attributes[attr] = self.request.query_params.get(attr) return dict(additional_attributes.items()) diff --git a/netbox_diode_plugin/tests/test_api_object_state.py b/netbox_diode_plugin/tests/test_api_object_state.py index 4aa16b8..7031549 100644 --- a/netbox_diode_plugin/tests/test_api_object_state.py +++ b/netbox_diode_plugin/tests/test_api_object_state.py @@ -379,3 +379,17 @@ def test_common_user_with_permissions_get_ip_state_using_q_objects(self): .get("name"), self.interfaces[0].name, ) + + def test_common_user_get_object_state_with_branch_parameter_specified(self): + """Test searching accepts _branch parameter with additional attributes specified.""" + query_parameters = { + "q": self.ip_addresses[0].address.__str__(), + "object_type": "ipam.ipaddress", + "interface": self.interfaces[0].id, + "_branch": "" + } + + response = self.client.get(self.url, query_parameters, **self.user_header) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.json().get("object_type"), "ipam.ipaddress")