diff --git a/.bandit.yml b/.bandit.yml
index 90c05db..6f5460f 100644
--- a/.bandit.yml
+++ b/.bandit.yml
@@ -3,4 +3,5 @@ skips: []
# No need to check for security issues in the test scripts!
exclude_dirs:
- "./tests/"
+ - "./test/"
- "./docs/"
diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py
index e09a3f7..9076f85 100644
--- a/napalm_panos/panos.py
+++ b/napalm_panos/panos.py
@@ -437,6 +437,10 @@ def _extract_interface_list(self):
interface_set = set()
+ # Interfaces on an empty VM may have a empty list if no interfaces are defined.
+ if interfaces is None:
+ return []
+
for entry in interfaces.values():
for entry_contents in entry.values():
if isinstance(entry_contents, dict):
diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml
new file mode 100644
index 0000000..71b83df
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml
@@ -0,0 +1,304 @@
+
+
+
+
+ fnRL/G5lXVMug
+
+
+ yes
+
+
+
+
+
+
+ yes
+
+
+ $1$vbxmfoed$3DpWw/eU1C7S5PUOqZnJ2.
+
+
+
+
+
+
+
+
+
+
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 10
+
+
+ yes
+ 5
+
+
+
+ yes
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+
+
+ 100
+ yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+ 5
+ wait-recover
+
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+
+ 8
+
+
+
+
+ aes-128-cbc
+
+
+ sha256
+
+
+ group19
+
+
+ 8
+
+
+
+
+ aes-256-cbc
+
+
+ sha384
+
+
+ group20
+
+
+ 8
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+ 1
+
+
+
+
+
+ aes-128-gcm
+
+
+ none
+
+
+ group19
+
+ 1
+
+
+
+
+
+ aes-256-gcm
+
+
+ none
+
+
+ group20
+
+ 1
+
+
+
+
+
+
+ aes-128-cbc
+
+
+ sha1
+
+
+
+
+
+
+
+
+
+
+ real-time
+
+
+ high
+
+
+ high
+
+
+ medium
+
+
+ medium
+
+
+ low
+
+
+ low
+
+
+ low
+
+
+
+
+
+
+
+
+
+ no
+
+
+ 1.25
+ 0.5
+ 900
+ 300
+ 900
+ yes
+
+
+
+
+
+
+
+
+
+ 10.0.0.90
+ 255.255.255.0
+ updates.paloaltonetworks.com
+
+
+
+
+ wednesday
+ 01:02
+ download-only
+
+
+
+
+ US/Pacific
+
+ yes
+ yes
+
+ test
+ 10.0.0.2
+
+
+ 8.8.8.8
+
+
+
+
+
+ yes
+
+
+ FQDN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__interface_all__interface___show_.xml b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__interface_all__interface___show_.xml
new file mode 100644
index 0000000..dad222c
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__interface_all__interface___show_.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/expected_result.json b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/expected_result.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/expected_result.json
@@ -0,0 +1 @@
+{}
diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml
new file mode 100644
index 0000000..57b9491
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml
@@ -0,0 +1,302 @@
+
+
+
+
+ fnRL/G5lXVMug
+
+
+ yes
+
+
+
+
+
+
+ yes
+
+
+ $1$vbxmfoed$3DpWw/eU1C7S5PUOqZnJ2.
+
+
+
+
+
+
+
+
+
+
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 10
+
+
+ yes
+ 5
+
+
+
+ yes
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+
+
+ 100
+ yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+ 5
+ wait-recover
+
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+
+ 8
+
+
+
+
+ aes-128-cbc
+
+
+ sha256
+
+
+ group19
+
+
+ 8
+
+
+
+
+ aes-256-cbc
+
+
+ sha384
+
+
+ group20
+
+
+ 8
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+ 1
+
+
+
+
+
+ aes-128-gcm
+
+
+ none
+
+
+ group19
+
+ 1
+
+
+
+
+
+ aes-256-gcm
+
+
+ none
+
+
+ group20
+
+ 1
+
+
+
+
+
+
+ aes-128-cbc
+
+
+ sha1
+
+
+
+
+
+
+
+
+
+
+ real-time
+
+
+ high
+
+
+ high
+
+
+ medium
+
+
+ medium
+
+
+ low
+
+
+ low
+
+
+ low
+
+
+
+
+
+
+
+
+
+ no
+
+
+ 1.25
+ 0.5
+ 900
+ 300
+ 900
+ yes
+
+
+
+
+
+
+
+
+
+ 10.0.0.90
+ 255.255.255.0
+ updates.paloaltonetworks.com
+
+
+
+
+ wednesday
+ 01:02
+ download-only
+
+
+
+
+ US/Pacific
+
+ yes
+ yes
+
+ PA-VM
+ 10.0.0.2
+
+
+ 8.8.8.8
+
+
+
+
+
+ yes
+
+
+ FQDN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py
index 4e4cb4e..2e6858c 100644
--- a/test/unit/test_getters.py
+++ b/test/unit/test_getters.py
@@ -1,7 +1,9 @@
"""Tests for getters."""
+from napalm.base.test import helpers
+from napalm.base.test import models
from napalm.base.test.getters import BaseTestGetters
-
+from napalm.base.test.getters import wrap_test_cases
import pytest
@@ -9,3 +11,21 @@
@pytest.mark.usefixtures("set_device_parameters")
class TestGetter(BaseTestGetters):
"""Test get_* methods."""
+
+ @wrap_test_cases
+ def test_get_interfaces(self, test_case):
+ """Test get_interfaces."""
+ get_interfaces = self.device.get_interfaces()
+ if test_case in {
+ "empty_interfaces",
+ }:
+ assert len(get_interfaces) == 0
+ else:
+ assert len(get_interfaces) > 0
+
+ # for interface, interface_data in get_interfaces.items():
+ # assert helpers.test_model(InterfaceDict, interface_data)
+ for interface, interface_data in get_interfaces.items():
+ assert helpers.test_model(models.interface, interface_data)
+
+ return get_interfaces