-
-
Notifications
You must be signed in to change notification settings - Fork 77
Labels
Description
Describe the bug
Merging a working custom OpenWrt template with another custom OpenWrt template which is using a wrong format can trigger an uncaught exception during validation.
The issue here is that custom templates don't have a strict schema to allow maximum flexibility by design, but this is backfiring when users write the configuration without verifying the template produces the expected results and then add the template to working devices.
Steps To Reproduce
Failing test:
diff --git a/tests/openwrt/test_default.py b/tests/openwrt/test_default.py
index 82880b1..c7c3a92 100644
--- a/tests/openwrt/test_default.py
+++ b/tests/openwrt/test_default.py
@@ -251,3 +251,28 @@ config olsrv2 'internet_hna'
"""
)
self.assertEqual(o.render(), expected)
+
+ def test_merge_invalid_format(self):
+ invalid = {
+ "dhcp": {
+ "lan": {
+ "interface": "lan",
+ "start": 100,
+ "limit": 150,
+ "leasetime": "12h",
+ }
+ }
+ }
+ valid = {
+ "dhcp": [
+ {
+ "dhcpv6": "disabled",
+ "ignore": True,
+ "ra": "disabled",
+ "config_value": "lan",
+ "config_name": "dhcp",
+ }
+ ]
+ }
+ o = OpenWrt({}, templates=[valid, invalid])
+ o.validate()
Expected behavior
Ideally we can raise a validation error instead of failing.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog
Status
To do (general)