diff --git a/panos/objects.py b/panos/objects.py index bd4e9107..8482d879 100644 --- a/panos/objects.py +++ b/panos/objects.py @@ -329,8 +329,8 @@ class ApplicationObject(VersionedPanObject): default_type (str): Default identification type of the application default_port (list): Default ports default_ip_protocol (str): Default IP protocol - default_icmp_type (int): Default ICMP type - default_icmp_code (int): Default ICMP code + default_icmp_type (str): Default ICMP type + default_icmp_code (str): Default ICMP code parent_app (str): Parent Application for which this app falls under timeout (int): Default timeout tcp_timeout (int): TCP timeout @@ -405,7 +405,6 @@ def _setup(self): VersionedParamPath( "default_icmp_type", path="default/{default_type}/type", - vartype="int", condition={ "default_type": ["ident-by-icmp-type", "ident-by-icmp6-type"] }, @@ -415,7 +414,6 @@ def _setup(self): VersionedParamPath( "default_icmp_code", path="default/{default_type}/code", - vartype="int", condition={ "default_type": ["ident-by-icmp-type", "ident-by-icmp6-type"] }, diff --git a/tests/test_objects.py b/tests/test_objects.py new file mode 100644 index 00000000..27dfa884 --- /dev/null +++ b/tests/test_objects.py @@ -0,0 +1,54 @@ +import xml.etree.ElementTree as ET + +import pytest + +from panos.objects import ApplicationObject + + +@pytest.mark.parametrize( + "default_type", + ["ident-by-icmp-type", "ident-by-icmp6-type"], +) +def test_application_object_renders_icmp_type_and_code_ranges(default_type): + obj = ApplicationObject( + "icmp-range", + default_type=default_type, + default_icmp_type="13-14", + default_icmp_code="5-6", + ) + expected = "".join( + [ + '<{0}>'.format(default_type), + "13-14", + "5-6", + "".format(default_type), + ] + ) + + assert obj.element_str().decode("utf-8") == expected + + +@pytest.mark.parametrize( + "default_type", + ["ident-by-icmp-type", "ident-by-icmp6-type"], +) +def test_application_object_parses_icmp_type_and_code_ranges(default_type): + obj = ApplicationObject() + xml = ET.fromstring( + """ + + + <{0}> + 13-14 + 5-6 + + + +""".format(default_type) + ) + + obj.parse_xml(xml) + + assert obj.default_type == default_type + assert obj.default_icmp_type == "13-14" + assert obj.default_icmp_code == "5-6"