Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions panos/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
},
Expand All @@ -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"]
},
Expand Down
54 changes: 54 additions & 0 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
@@ -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(
[
'<entry name="icmp-range"><default><{0}>'.format(default_type),
"<type>13-14</type>",
"<code>5-6</code>",
"</{0}></default></entry>".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(
"""
<entry name="icmp-range">
<default>
<{0}>
<type>13-14</type>
<code>5-6</code>
</{0}>
</default>
</entry>
""".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"