diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-09-25 16:48:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-25 16:48:24 +0100 |
| commit | 7b4c77e8ee650314c8913e0565ffb93194007284 (patch) | |
| tree | 2a4b8bf59c8d852e263d74a328e2f84a6dad379f /tests/unit/modules | |
| parent | ea972536abda5b2acb4b4ec843511c768361bbf5 (diff) | |
| parent | 9fe93349225eb9b014e7a3e397da88fece40a0b2 (diff) | |
| download | rest.vyos-7b4c77e8ee650314c8913e0565ffb93194007284.tar.gz rest.vyos-7b4c77e8ee650314c8913e0565ffb93194007284.zip | |
Merge branch 'main' into T8989_vyos_hostname_SIT_fixT8989_vyos_hostname_SIT_fix
Diffstat (limited to 'tests/unit/modules')
| -rw-r--r-- | tests/unit/modules/test_vyos_static_routes.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/modules/test_vyos_static_routes.py b/tests/unit/modules/test_vyos_static_routes.py index 1a50da9..0ec74a5 100644 --- a/tests/unit/modules/test_vyos_static_routes.py +++ b/tests/unit/modules/test_vyos_static_routes.py @@ -259,6 +259,56 @@ class TestBuildCommands(VyOSModuleTestCase): expected = ("delete", _BASE + ["route", "192.0.2.0/24", "next-hop", "10.0.0.1", "distance"]) self.assertIn(expected, cmds) + def test_merged_explicit_enabled_true_clears_stale_disable(self): + """Confirmed real gap from review: dict_op(op="set") only ever + walks want's own keys, so it can never reach a "disable" leaf + that's simply absent from want -- under "merged" (which never + runs a purge pass at all) there was no way to clear a + previously disabled next-hop. Fixed via an explicit check + against the original argspec-shape config for enabled: true, + scoped to merged specifically since replaced/overridden + already handle this correctly through their existing purge + pass.""" + raw_have = {"route": {"192.0.2.0/24": {"next-hop": {"10.0.0.1": {"disable": {}}}}}} + config = [ + { + "afi": "ipv4", + "routes": [ + { + "dest": "192.0.2.0/24", + "next_hops": [ + {"forward_router_address": "10.0.0.1", "enabled": True}, + ], + }, + ], + }, + ] + cmds = build_commands(config, raw_have, "merged") + expected = ("delete", _BASE + ["route", "192.0.2.0/24", "next-hop", "10.0.0.1", "disable"]) + self.assertIn(expected, cmds) + + def test_merged_omitted_enabled_leaves_existing_disable_alone(self): + """enabled deliberately has no default (fixed alongside the + above): omitting it entirely means "no opinion", so an + unrelated merged update must not silently re-enable an + existing disabled next-hop.""" + raw_have = {"route": {"192.0.2.0/24": {"next-hop": {"10.0.0.1": {"disable": {}}}}}} + config = [ + { + "afi": "ipv4", + "routes": [ + { + "dest": "192.0.2.0/24", + "next_hops": [ + {"forward_router_address": "10.0.0.1", "admin_distance": 5}, + ], + }, + ], + }, + ] + cmds = build_commands(config, raw_have, "merged") + self.assertFalse(any("disable" in str(c) for c in cmds)) + def test_replaced_scoped_to_named_route_only(self): raw_have = { "route": { |
