Skip to content

Commit e83e0d9

Browse files
authored
Merge branch 'master' into dependabot/github_actions/pypa/gh-action-pypi-publish-1.12.2
2 parents 4e7895c + 55ad214 commit e83e0d9

File tree

11 files changed

+70
-20
lines changed

11 files changed

+70
-20
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Replicate Commits to Version Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
version-branch:
10+
uses: openwisp/openwisp-utils/.github/workflows/reusable-version-branch.yml@master
11+
with:
12+
module_name: openwisp_controller

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
Version 1.2.0 [Unreleased]
5+
--------------------------
6+
7+
Work in progress.
8+
49
Version 1.1.0 [2024-11-22]
510
--------------------------
611

README.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Other popular building blocks that are part of the OpenWISP ecosystem are:
5353
provides device status monitoring, collection of metrics, charts,
5454
alerts, possibility to define custom checks
5555
- `openwisp-firmware-upgrader
56-
<https://openwisp.io/docs/stable/firmware-upgrader/>`_: automated firmware
57-
upgrades (single devices or mass network upgrades)
56+
<https://openwisp.io/docs/stable/firmware-upgrader/>`_: automated
57+
firmware upgrades (single devices or mass network upgrades)
5858
- `openwisp-radius <https://openwisp.io/docs/stable/user/radius.html>`_:
5959
based on FreeRADIUS, allows to implement network access authentication
6060
systems like 802.1x WPA2 Enterprise, captive portal authentication,
@@ -65,10 +65,11 @@ Other popular building blocks that are part of the OpenWISP ecosystem are:
6565
daemons or other network software (e.g.: OpenVPN); it can be used in
6666
conjunction with openwisp-monitoring to get a better idea of the state
6767
of the network
68-
- `openwisp-ipam <https://openwisp.io/docs/stable/ipam/>`_: allows to manage
69-
the assignment of IP addresses used in the network
70-
- `openwisp-notifications <https://openwisp.io/docs/stable/notifications/>`_:
71-
allows users to be aware of important events happening in the network.
68+
- `openwisp-ipam <https://openwisp.io/docs/stable/ipam/>`_: allows to
69+
manage the assignment of IP addresses used in the network
70+
- `openwisp-notifications
71+
<https://openwisp.io/docs/stable/notifications/>`_: allows users to be
72+
aware of important events happening in the network.
7273

7374
**For a more complete overview of the OpenWISP modules and architecture**,
7475
see the `OpenWISP Architecture Overview

openwisp_controller/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (1, 1, 0, 'final')
1+
VERSION = (1, 2, 0, 'alpha')
22
__version__ = VERSION # alias
33

44

openwisp_controller/config/base/device.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def _validate_unique_name(self):
262262

263263
def clean(self, *args, **kwargs):
264264
super().clean(*args, **kwargs)
265+
self.mac_address = self.mac_address.upper()
265266
self._validate_unique_name()
266267
self._validate_org_relation('group', field_error='group')
267268
self._validate_org_device_limit()

openwisp_controller/config/base/template.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.db import models, transaction
77
from django.utils.translation import gettext_lazy as _
88
from jsonfield import JSONField
9+
from netjsonconfig.exceptions import ValidationError as NetjsonconfigValidationError
910
from swapper import get_model_name
1011
from taggit.managers import TaggableManager
1112

@@ -115,7 +116,14 @@ def save(self, *args, **kwargs):
115116
if hasattr(self, 'backend_instance'):
116117
del self.backend_instance
117118
current = self.__class__.objects.get(pk=self.pk)
118-
update_related_config_status = self.checksum != current.checksum
119+
try:
120+
current_checksum = current.checksum
121+
except NetjsonconfigValidationError:
122+
# If the Netjsonconfig library upgrade changes the schema,
123+
# the old configuration may become invalid, raising an exception.
124+
# Setting the checksum to None forces related configurations to update.
125+
current_checksum = None
126+
update_related_config_status = self.checksum != current_checksum
119127
# save current changes
120128
super().save(*args, **kwargs)
121129
# update relations

openwisp_controller/config/tests/test_device.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def test_mac_address_validator(self):
6969
else:
7070
self.fail('ValidationError not raised for "{0}"'.format(mac_address))
7171

72+
def test_device_mac_address_uppercase(self):
73+
device = self._create_device(mac_address='00:1a:2b:3c:4d:5e')
74+
device.full_clean()
75+
self.assertEqual(device.mac_address, '00:1A:2B:3C:4D:5E')
76+
device.save()
77+
device.refresh_from_db()
78+
self.assertEqual(device.mac_address, '00:1A:2B:3C:4D:5E')
79+
7280
def test_config_status_modified(self):
7381
c = self._create_config(device=self._create_device(), status='applied')
7482
self.assertEqual(c.status, 'applied')

openwisp_controller/config/tests/test_template.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.db import transaction
88
from django.test import TestCase, TransactionTestCase
99
from netjsonconfig import OpenWrt
10+
from netjsonconfig.exceptions import ValidationError as NetjsonconfigValidationError
1011
from swapper import load_model
1112

1213
from openwisp_utils.tests import catch_signal
@@ -500,6 +501,20 @@ def test_required_vpn_template_corner_case(self):
500501
# {'__all__': ['VPN client with this Config and Vpn already exists.']}
501502
self.assertIsNotNone(vpn_client)
502503

504+
def test_regression_preventing_from_fixing_invalid_conf(self):
505+
template = self._create_template()
506+
# create a template with an invalid configuration
507+
Template.objects.update(config={'interfaces': [{'name': 'eth0', 'type': ''}]})
508+
# ensure the configuration raises ValidationError
509+
with self.assertRaises(NetjsonconfigValidationError):
510+
template.refresh_from_db()
511+
del template.backend_instance
512+
template.checksum
513+
del template.backend_instance
514+
template.config = {'interfaces': [{'name': 'eth0', 'type': 'ethernet'}]}
515+
template.full_clean()
516+
template.save()
517+
503518

504519
class TestTemplateTransaction(
505520
TransactionTestMixin,

openwisp_controller/geo/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_put_create_location(self):
9494
device = self._create_object()
9595
self.assertEqual(self.location_model.objects.count(), 0)
9696
url = reverse(self.url_name, args=[device.pk])
97-
r = self.client.put(f'{url}?key={device.key }')
97+
r = self.client.put(f'{url}?key={device.key}')
9898
self.assertEqual(r.status_code, 200)
9999
self.assertDictEqual(
100100
r.json(),

requirements-test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pytest-django~=4.9.0
22
pytest-asyncio~=0.24.0
33
pytest-cov~=5.0.0
4-
openwisp-utils[qa,selenium]~=1.1.1
4+
openwisp-utils[qa,selenium] @ https://github.com/openwisp/openwisp-utils/tarball/1.2
55
channels_redis~=4.2.1
66
django_redis~=5.4.0
77
mock-ssh-server~=0.9.1
88
responses~=0.25.3
9-
psycopg2-binary~=2.9.9
9+
psycopg2-binary~=2.9.10

0 commit comments

Comments
 (0)