From dd2a83b2092b612745fdf9ce2bafbc5605238588 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Fri, 16 Feb 2024 15:45:55 +0530 Subject: [PATCH] [fix] Handle called_station_id uses "-" instead of ":" Also made device mac address lookup case insensitive --- openwisp_radius/integrations/monitoring/tasks.py | 5 ++++- .../integrations/monitoring/tests/test_metrics.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openwisp_radius/integrations/monitoring/tasks.py b/openwisp_radius/integrations/monitoring/tasks.py index 34f54896..f44dd679 100644 --- a/openwisp_radius/integrations/monitoring/tasks.py +++ b/openwisp_radius/integrations/monitoring/tasks.py @@ -105,7 +105,10 @@ def post_save_radiusaccounting( device = ( Device.objects.select_related('devicelocation') .only('id', 'devicelocation__location_id') - .get(mac_address=called_station_id, organization_id=organization_id) + .get( + mac_address__iexact=called_station_id.replace('-', ':'), + organization_id=organization_id, + ) ) except Device.DoesNotExist: logger.warning( diff --git a/openwisp_radius/integrations/monitoring/tests/test_metrics.py b/openwisp_radius/integrations/monitoring/tests/test_metrics.py index b377386f..6ff89726 100644 --- a/openwisp_radius/integrations/monitoring/tests/test_metrics.py +++ b/openwisp_radius/integrations/monitoring/tests/test_metrics.py @@ -139,7 +139,7 @@ def test_post_save_radiusaccounting(self, *args): { 'unique_id': '117', 'username': user.username, - 'called_station_id': device.mac_address, + 'called_station_id': device.mac_address.replace('-', ':').upper(), 'calling_station_id': '00:00:00:00:00:00', 'input_octets': '8000000000', 'output_octets': '9000000000',