diff --git a/changelogs/fragments/T9756_firewall_global_zone_vrf.yml b/changelogs/fragments/T9756_firewall_global_zone_vrf.yml index 5d6b0a13..dd10051d 100644 --- a/changelogs/fragments/T9756_firewall_global_zone_vrf.yml +++ b/changelogs/fragments/T9756_firewall_global_zone_vrf.yml @@ -1,5 +1,6 @@ --- bugfixes: - vyos_firewall_global - fix the module failing on every run with C(Unsupported parameters for (basic.py) module - config.zone.member) when a firewall zone has a VRF member (C(member vrf)) (https://vyos.dev/T9756). + - vyos_firewall_global - device configuration the module does not declare in its argument spec (for example zone options from newer VyOS releases) is now left out of the facts with a warning, instead of failing argspec validation on every run (https://vyos.dev/T9756). minor_changes: - vyos_firewall_global - add the C(vrfs) zone option to manage VRF zone members (C(member vrf), VyOS 1.5+) (https://vyos.dev/T9756). diff --git a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py index 46598f84..f579ef9b 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py @@ -1,531 +1,570 @@ # # -*- coding: utf-8 -*- # Copyright 2019 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ The vyos firewall_global fact class It is in this file the configuration is collected from the device for a given resource, parsed, and the facts tree is populated based on the configuration. """ from __future__ import absolute_import, division, print_function __metaclass__ = type from copy import deepcopy from re import M, findall, search from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_global.firewall_global import ( Firewall_globalArgs, ) class Firewall_globalFacts(object): """The vyos firewall_global fact class""" def __init__(self, module, subspec="config", options="options"): self._module = module self.argument_spec = Firewall_globalArgs.argument_spec spec = deepcopy(self.argument_spec) if subspec: if options: facts_argument_spec = spec[subspec][options] else: facts_argument_spec = spec[subspec] else: facts_argument_spec = spec self.generated_spec = utils.generate_dict(facts_argument_spec) def get_device_data(self, connection): return connection.get_config() def populate_facts(self, connection, ansible_facts, data=None): """Populate the facts for firewall_global :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ if not data: # typically data is populated from the current device configuration # data = connection.get('show running-config | section ^interface') # using mock data instead data = self.get_device_data(connection) objs = {} firewalls = findall(r"^set firewall .*$", data, M) if firewalls: objs = self.render_config(firewalls) facts = {} + dropped = [] + self._drop_undeclared(objs, self.argument_spec["config"]["options"], "config", dropped) + if dropped: + self._module.warn( + "vyos_firewall_global: ignoring device configuration the module does " + "not support: %s" % ", ".join(sorted(set(dropped))), + ) params = utils.validate_config(self.argument_spec, {"config": objs}) facts["firewall_global"] = utils.remove_empties(params["config"]) ansible_facts["ansible_network_resources"].update(facts) return ansible_facts + def _drop_undeclared(self, data, options, path, dropped): + """ + Remove keys the argspec does not declare, so device configuration + the module does not support (e.g. a newer VyOS schema) is ignored + instead of failing argspec validation on every run (T9756). + :param data: parsed facts (dict), pruned in place + :param options: argspec 'options' for this level + :param path: dotted path of this level, for the warning + :param dropped: list collecting the dropped paths + """ + for key in list(data): + spec = options.get(key) + if spec is None: + del data[key] + dropped.append("%s.%s" % (path, key)) + continue + sub_options = spec.get("options") + if not sub_options: + continue + value = data[key] + if isinstance(value, dict): + self._drop_undeclared(value, sub_options, "%s.%s" % (path, key), dropped) + elif isinstance(value, list): + for item in value: + if isinstance(item, dict): + self._drop_undeclared( + item, + sub_options, + "%s.%s" % (path, key), + dropped, + ) + def render_config(self, conf): """ Render config as dictionary structure and delete keys from spec for null values :param spec: The facts tree, generated from the argspec :param conf: The configuration :rtype: dictionary :returns: The generated config """ conf = "\n".join( filter( lambda x: not ( x.startswith("set firewall name") or x.startswith("set firewall ipv6-name") or x.startswith("set firewall ipv6 name") ), conf, ), ) a_lst = [ "config_trap", "validation", "log_martians", "syn_cookies", "twa_hazards_protection", ] firewall = self.parse_attr(conf, a_lst) f_sub = { "ping": self.parse_ping(conf), "group": self.parse_group(conf), "route_redirects": self.route_redirects(conf), "state_policy": self.parse_state_policy(conf), "zone": self.parse_zone(conf), } firewall.update(f_sub) return firewall def route_redirects(self, conf): """ This function forms the regex to fetch the afi and invoke functions to fetch route redirects and source routes :param conf: configuration data. :return: generated rule list configuration. """ rr_lst = [] v6_attr = findall( r"^set firewall (?:global-options )?(?:ipv6-src-route|ipv6-receive-redirects) (\S+)", conf, M, ) if v6_attr: obj = self.parse_rr_attrib(conf, "ipv6") if obj: rr_lst.append(obj) v4_attr = findall( r"^set firewall (?:global-options )?(?:ip-src-route|receive-redirects|send-redirects) (\S+)", conf, M, ) if v4_attr: obj = self.parse_rr_attrib(conf, "ipv4") if obj: rr_lst.append(obj) return rr_lst def parse_rr_attrib(self, conf, attrib=None): """ This function fetches the 'ip_src_route' invoke function to parse icmp redirects. :param conf: configuration to be parsed. :param attrib: 'ipv4/ipv6'. :return: generated config dictionary. """ cfg_dict = self.parse_attr(conf, ["ip_src_route"], type=attrib) cfg_dict["icmp_redirects"] = self.parse_icmp_redirects(conf, attrib) cfg_dict["afi"] = attrib return cfg_dict def parse_icmp_redirects(self, conf, attrib=None): """ This function triggers the parsing of 'icmp_redirects' attributes. :param conf: configuration to be parsed. :param attrib: 'ipv4/ipv6'. :return: generated config dictionary. """ a_lst = ["send", "receive"] cfg_dict = self.parse_attr(conf, a_lst, type=attrib) return cfg_dict def parse_ping(self, conf): """ This function triggers the parsing of 'ping' attributes. :param conf: configuration to be parsed. :return: generated config dictionary. """ a_lst = ["all", "broadcast"] cfg_dict = self.parse_attr(conf, a_lst) return cfg_dict def parse_state_policy(self, conf): """ This function fetched the connecton type and invoke function to parse other state-policy attributes. :param conf: configuration data. :return: generated rule list configuration. """ sp_lst = [] policies = findall(r"^set firewall (?:global-options )?state-policy (\S+)", conf, M) policies = list(set(policies)) # remove redundancies if policies: rules_lst = [] for sp in set(policies): sp_regex = r"^set firewall (?:global-options )?state-policy %s .+$" % sp cfg = "\n".join(findall(sp_regex, conf, M)) obj = self.parse_policies(cfg, sp) obj["connection_type"] = sp if obj: rules_lst.append(obj) sp_lst = sorted(rules_lst, key=lambda i: i["connection_type"]) return sp_lst def parse_policies(self, conf, attrib=None): """ This function triggers the parsing of policy attributes action and log. :param conf: configuration :param attrib: connection type. :return: generated rule configuration dictionary. """ a_lst = ["action", "log", "log_level"] cfg_dict = self.parse_attr(conf, a_lst, match=attrib) return cfg_dict def parse_group(self, conf): """ This function triggers the parsing of 'group' attributes. :param conf: configuration. :return: generated config dictionary. """ cfg_dict = {} cfg_dict["port_group"] = self.parse_group_lst(conf, "port-group", False) cfg_dict["address_group"] = self.parse_group_lst( conf, "address-group", ) + self.parse_group_lst(conf, "ipv6-address-group") cfg_dict["network_group"] = self.parse_group_lst( conf, "network-group", ) + self.parse_group_lst(conf, "ipv6-network-group") return cfg_dict def parse_group_lst(self, conf, type, include_afi=True): """ This function fetches the name of group and invoke function to parse group attributes'. :param conf: configuration data. :param type: type of group. :param include_afi: if the afi should be included in the parsed object :return: generated group list configuration. """ g_lst = [] groups = findall(r"^set firewall group " + type + " (\\S+)", conf, M) if groups: rules_lst = [] for gr in set(groups): gr_regex = r"^set firewall group " + type + " %s .+$" % gr cfg = "\n".join(findall(gr_regex, conf, M)) if "ipv6" in type: # fmt: off obj = self.parse_groups(cfg, type[len("ipv6-"):], gr) # fmt: on if include_afi: obj["afi"] = "ipv6" else: obj = self.parse_groups(cfg, type, gr) if include_afi: obj["afi"] = "ipv4" obj["name"] = gr.strip("'") if obj: rules_lst.append(obj) g_lst = sorted(rules_lst, key=lambda i: i["name"]) return g_lst def parse_groups(self, conf, type, name): """ This function fetches the description and invoke the parsing of group members. :param conf: configuration. :param type: type of group. :param name: name of group. :return: generated configuration dictionary. """ a_lst = ["name", "description"] group = self.parse_attr(conf, a_lst) key = self.get_key(type) r_sub = {key[0]: self.parse_address_port_lst(conf, name, key[1])} group.update(r_sub) return group def parse_address_port_lst(self, conf, name, key): """ This function forms the regex to fetch the group members attributes. :param conf: configuration data. :param name: name of group. :param key: key value. :return: generated member list configuration. """ l_lst = [] attribs = findall(r"^.*" + name + " " + key + " (\\S+)", conf, M) if attribs: for attr in attribs: if key == "port": l_lst.append({"port": attr.strip("'")}) else: l_lst.append({"address": attr.strip("'")}) return l_lst def parse_attr(self, conf, attr_list, match=None, type=None): """ This function peforms the following: - Form the regex to fetch the required attribute config. - Type cast the output in desired format. :param conf: configuration. :param attr_list: list of attributes. :param match: parent node/attribute name. :return: generated config dictionary. """ config = {} for attrib in attr_list: regex = self.map_regex(attrib, type) if match: regex = match + " " + regex if conf: if self.is_bool(attrib): # fancy regex to make sure we don't get a substring out = search(r"^.*" + regex + r"( 'disable')?(?=\s|$)", conf, M) if out: if out.group(1): config[attrib] = False else: config[attrib] = True else: out = search(r"^.*" + regex + r" (.+)", conf, M) if out: val = out.group(1).strip("'") if self.is_num(attrib): val = int(val) config[attrib] = val return config def get_key(self, type): """ This function map the group type to member type :param type: :return: """ key = () if type == "port-group": key = ("members", "port") elif type == "address-group": key = ("members", "address") elif type == "network-group": key = ("members", "network") return key def map_regex(self, attrib, type=None): """ - This function construct the regex string. - replace the underscore with hyphen. :param attrib: attribute :return: regex string """ regex = attrib.replace("_", "-") if attrib == "all": regex = "all-ping" elif attrib == "disabled": regex = "disable" elif attrib == "broadcast": regex = "broadcast-ping" elif attrib == "send": if type == "ipv6": regex = "ipv6-send-redirects" else: regex = "send-redirects" elif attrib == "ip_src_route": if type == "ipv6": regex = "ipv6-src-route" elif attrib == "receive": if type == "ipv6": regex = "ipv6-receive-redirects" else: regex = "receive-redirects" return regex def is_num(self, attrib): """ This function looks for the attribute in predefined integer type set. :param attrib: attribute. :return: True/false. """ num_set = ("time", "code", "type", "count", "burst", "number") return True if attrib in num_set else False def get_src_route(self, attrib): """ This function looks for the attribute in predefined integer type set. :param attrib: attribute. :return: True/false. """ return "ipv6_src_route" if attrib == "ipv6" else "ip_src_route" def is_bool(self, attrib): """ This function looks for the attribute in predefined bool type set. :param attrib: attribute. :return: True/False """ bool_set = ( "all", "log", "send", "receive", "broadcast", "config_trap", "log_martians", "syn_cookies", "ip_src_route", "twa_hazards_protection", ) return True if attrib in bool_set else False def parse_zone(self, conf): """ This function triggers the parsing of 'zone' attributes. :param conf: configuration. :return: generated config dictionary. """ cfg_dict = {} KEY_MAP = { "interface": "interfaces", "vrf": "vrfs", "intra-zone-filtering": "intra-zone-filtering", "from": "sources", } LIST_ATTRS = { "interfaces", "vrfs", "intra_zone_filtering", "sources", } for line in conf.splitlines(): m = search( r"^set firewall zone (?P\S+)\s+(?P[a-z-]+)(?:\s+(?P'[^']+'|[^\n]+))?$", line, ) if not m: continue zone_name = m.group("zone") raw_attr = m.group("attr").replace("-", "_") value = m.group("value") if value is None: value = True else: value = value.strip("'") # VyOS 1.5.0 GA wraps zone members under a 'member' node: # "set firewall zone member interface " and # "set firewall zone member vrf " (T9756). Unwrap # them here so they land in the 'interfaces' and 'vrfs' lists. # 'interfaces' also takes the pre-1.5.0 bare # "interface " form. No version check needed -- # 1.4.x/1.5-rolling configs never emit 'member'. if raw_attr == "member" and isinstance(value, str): kind, _sep, member = value.partition(" ") if kind in ("interface", "vrf"): raw_attr = kind value = member.strip("'") zone = cfg_dict.setdefault(zone_name, {"name": zone_name}) attr = KEY_MAP.get(raw_attr, raw_attr) if attr in LIST_ATTRS: if attr == "intra_zone_filtering": izf = zone.setdefault(attr, {}) izf_attr = self._parse_izf(value) for k, v in izf_attr.items(): if isinstance(v, dict): izf.setdefault(k, {}).update(v) else: izf[k] = v elif attr == "sources": self._parse_sources(zone, value) else: zone.setdefault(attr, []).append(value) else: zone[attr] = value return list(cfg_dict.values()) def _parse_izf(self, value): tokens = value.replace("'", "").split() result = {} key = tokens[0].replace("-", "_") if len(tokens) == 2: result[key] = tokens[1] elif len(tokens) >= 3: subkey = tokens[1].replace("-", "_") result[key] = {subkey: tokens[2]} return result def _parse_sources(self, zone, value): tokens = value.split() if len(tokens) < 1: return src_zone = tokens[0] sources = zone.setdefault("sources", []) entry = None for s in sources: if s.get("zone") == src_zone: entry = s break if entry is None: entry = {"zone": src_zone} sources.append(entry) if len(tokens) == 1: return if tokens[1] == "firewall" and len(tokens) >= 4: key = tokens[2].replace("-", "_") val = tokens[3].strip("'") firewall = entry.setdefault("firewall", {}) firewall[key] = val diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_global15.py b/tests/unit/modules/network/vyos/test_vyos_firewall_global15.py index c4069685..b9bfe44b 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_global15.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_global15.py @@ -1,229 +1,272 @@ # (c) 2016 Red Hat Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . # Make coding more python3-ish from __future__ import absolute_import, division, print_function __metaclass__ = type from unittest.mock import patch from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_global from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args +from ansible.module_utils.basic import AnsibleModule + from .vyos_module import TestVyosModule, load_fixture class TestVyosFirewallRulesModule15(TestVyosModule): module = vyos_firewall_global def setUp(self): super(TestVyosFirewallRulesModule15, self).setUp() self.mock_get_config = patch( "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data", ) self.mock_get_os_version = patch( "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_global.firewall_global.get_os_version", ) self.get_os_version = self.mock_get_os_version.start() self.get_os_version.return_value = "1.5" self.execute_show_command = self.mock_execute_show_command.start() + self.extra_config = "" self.maxDiff = None def tearDown(self): super(TestVyosFirewallRulesModule15, self).tearDown() self.mock_get_resource_connection_config.stop() self.mock_get_resource_connection_facts.stop() self.mock_get_config.stop() self.mock_load_config.stop() self.mock_execute_show_command.stop() self.mock_get_os_version.stop() def load_fixtures(self, commands=None, filename=None): def load_from_file(*args, **kwargs): - return load_fixture("vyos_firewall_global_config_v15.cfg") + return load_fixture("vyos_firewall_global_config_v15.cfg") + self.extra_config self.execute_show_command.side_effect = load_from_file def test_vyos_firewall_global_set_01_merged_interface_uses_member_keyword(self): # On a 1.5.0 device (empty fixture, no existing zone), merging a # zone with an interface should render "member interface", not the # bare "interface" used on 1.4.x / 1.5-rolling. This is the sole # thing this class exists to prove right now -- the version-gate # added to _render_interfaces. set_module_args( dict( config=dict( zone=[ dict( name="ZONE-15", interfaces=["eth1"], ), ], ), state="merged", ), ) commands = [ "set firewall zone ZONE-15 default-action 'drop'", "set firewall zone ZONE-15 member interface eth1", ] self.execute_module(changed=True, commands=commands) def test_vyos_firewall_global_set_02_gathered_member_interface_parsed(self): # ZONE-15-EXISTING in the fixture uses 1.5.0's "member interface" # syntax. Before the parse_zone fix, this misparsed into a bogus # zone['member'] = "interface eth2" string field, and 'interfaces' # was missing entirely. After the fix, it should land in # 'interfaces' exactly like the pre-1.5.0 bare "interface" form. set_module_args(dict(config=dict(), state="gathered")) result = self.execute_module(changed=False) zones = result["gathered"]["zone"] zone = next(z for z in zones if z["name"] == "ZONE-15-EXISTING") self.assertEqual(zone["interfaces"], ["eth2"]) self.assertEqual(zone["description"], "existing 1.5.0 zone for facts parsing test") self.assertNotIn("member", zone) def test_vyos_firewall_global_ruleset_lines_filtered_from_facts(self): # Same coverage as the 1.4 version, confirmed independently on the # 1.5.0 fixture/version path. set_module_args(dict(config=dict(), state="gathered")) result = self.execute_module(changed=False) facts = result["gathered"] self.assertNotIn("TESTRULESET-V4", str(facts)) self.assertNotIn("TESTRULESET-V6-LEGACY", str(facts)) self.assertNotIn("TESTRULESET-V6-1_4PLUS", str(facts)) def test_vyos_firewall_global_set_03_gathered_member_vrf_parsed(self): # T9756: a zone with a VRF member ("member vrf ") must parse # into 'vrfs' instead of leaking a bogus 'member' key that fails # argspec validation on every run. set_module_args(dict(state="gathered")) result = self.execute_module(changed=False) zone = next(z for z in result["gathered"]["zone"] if z["name"] == "ZONE-15-EXISTING") self.assertEqual(zone["interfaces"], ["eth2"]) self.assertEqual(zone["vrfs"], ["vrf_evpn1"]) self.assertNotIn("member", zone) def test_vyos_firewall_global_set_04_merged_untouched_vrf_zone(self): # T9756: a merged run that doesn't touch zones must not fail on a # device that has a VRF-member zone. set_module_args(dict(config=dict(log_martians=True), state="merged")) commands = ["set firewall global-options log-martians 'enable'"] self.execute_module(changed=True, commands=commands) def test_vyos_firewall_global_set_05_merged_vrf_member(self): set_module_args( dict( config=dict( zone=[ dict(name="ZONE-15-EXISTING", vrfs=["vrf_evpn1", "vrf_evpn2"]), ], ), state="merged", ), ) commands = ["set firewall zone ZONE-15-EXISTING member vrf vrf_evpn2"] self.execute_module(changed=True, commands=commands) def test_vyos_firewall_global_set_06_merged_vrf_member_idempotent(self): set_module_args( dict( config=dict(zone=[dict(name="ZONE-15-EXISTING", vrfs=["vrf_evpn1"])]), state="merged", ), ) self.execute_module(changed=False, commands=[]) def test_vyos_firewall_global_set_07_replaced_vrf_member(self): set_module_args( dict( config=dict( zone=[ dict( name="ZONE-15-EXISTING", description="existing 1.5.0 zone for facts parsing test", interfaces=["eth2"], vrfs=["vrf_evpn2"], ), ], ), state="replaced", ), ) commands = [ "delete firewall zone ZONE-15-EXISTING member vrf vrf_evpn1", "set firewall zone ZONE-15-EXISTING member vrf vrf_evpn2", ] self.execute_module(changed=True, commands=commands, sort=True) def test_vyos_firewall_global_set_08_replaced_vrf_member_removed(self): set_module_args( dict( config=dict( zone=[ dict( name="ZONE-15-EXISTING", description="existing 1.5.0 zone for facts parsing test", interfaces=["eth2"], ), ], ), state="replaced", ), ) commands = [ "delete firewall zone ZONE-15-EXISTING member vrf vrf_evpn1", ] self.execute_module(changed=True, commands=commands, sort=True) def test_vyos_firewall_global_set_09_rendered_vrf_member(self): set_module_args( dict( config=dict(zone=[dict(name="ZONE-R", vrfs=["vrf_evpn1"])]), state="rendered", ), ) commands = [ "set firewall zone ZONE-R default-action 'drop'", "set firewall zone ZONE-R member vrf vrf_evpn1", ] result = self.execute_module(changed=False) self.assertEqual(sorted(result["rendered"]), sorted(commands)) + + def test_vyos_firewall_global_set_10_gathered_unknown_zone_attr(self): + # T9756: zone attributes the argspec does not declare (here + # 'default-firewall' from VyOS rolling) are dropped with a warning + # instead of failing validation. + self.extra_config = ( + "\nset firewall zone ZONE-15-EXISTING default-firewall name 'TESTRULESET-V4'\n" + ) + set_module_args(dict(state="gathered")) + with patch.object(AnsibleModule, "warn") as warn: + result = self.execute_module(changed=False) + zone = next(z for z in result["gathered"]["zone"] if z["name"] == "ZONE-15-EXISTING") + self.assertNotIn("default_firewall", zone) + self.assertEqual(zone["vrfs"], ["vrf_evpn1"]) + warn.assert_called_once() + self.assertIn("config.zone.default_firewall", warn.call_args[0][0]) + + def test_vyos_firewall_global_set_11_merged_unknown_zone_attr(self): + self.extra_config = ( + "\nset firewall zone ZONE-15-EXISTING default-firewall name 'TESTRULESET-V4'\n" + ) + set_module_args(dict(config=dict(log_martians=True), state="merged")) + commands = ["set firewall global-options log-martians 'enable'"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_global_set_12_parsed_unknown_zone_attr(self): + set_module_args( + dict( + running_config=( + "set firewall zone Z1 member interface eth1\n" + "set firewall zone Z1 default-firewall name 'FW1'\n" + ), + state="parsed", + ), + ) + result = self.execute_module(changed=False) + self.assertEqual( + result["parsed"]["zone"], + [{"name": "Z1", "interfaces": ["eth1"], "default_action": "drop"}], + )