diff --git a/openwisp_controller/config/base/device.py b/openwisp_controller/config/base/device.py index e3892a08b..e36e34d34 100644 --- a/openwisp_controller/config/base/device.py +++ b/openwisp_controller/config/base/device.py @@ -262,6 +262,7 @@ def _validate_unique_name(self): def clean(self, *args, **kwargs): super().clean(*args, **kwargs) + self.mac_address = self.mac_address.upper() self._validate_unique_name() self._validate_org_relation('group', field_error='group') self._validate_org_device_limit() diff --git a/openwisp_controller/config/tests/test_device.py b/openwisp_controller/config/tests/test_device.py index 462e59106..7768242a2 100644 --- a/openwisp_controller/config/tests/test_device.py +++ b/openwisp_controller/config/tests/test_device.py @@ -69,6 +69,14 @@ def test_mac_address_validator(self): else: self.fail('ValidationError not raised for "{0}"'.format(mac_address)) + def test_device_mac_address_uppercase(self): + device = self._create_device(mac_address='00:1a:2b:3c:4d:5e') + device.full_clean() + self.assertEqual(device.mac_address, '00:1A:2B:3C:4D:5E') + device.save() + device.refresh_from_db() + self.assertEqual(device.mac_address, '00:1A:2B:3C:4D:5E') + def test_config_status_modified(self): c = self._create_config(device=self._create_device(), status='applied') self.assertEqual(c.status, 'applied') diff --git a/openwisp_controller/geo/tests/test_api.py b/openwisp_controller/geo/tests/test_api.py index ffc334ec2..9a9ba6c67 100644 --- a/openwisp_controller/geo/tests/test_api.py +++ b/openwisp_controller/geo/tests/test_api.py @@ -94,7 +94,7 @@ def test_put_create_location(self): device = self._create_object() self.assertEqual(self.location_model.objects.count(), 0) url = reverse(self.url_name, args=[device.pk]) - r = self.client.put(f'{url}?key={device.key }') + r = self.client.put(f'{url}?key={device.key}') self.assertEqual(r.status_code, 200) self.assertDictEqual( r.json(),