Skip to content

Commit 36e375c

Browse files
committed
Merge branch 'release/0.5.3'
2 parents 0f83a7e + 3098ca0 commit 36e375c

File tree

8 files changed

+1143
-24
lines changed

8 files changed

+1143
-24
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ ENV/
7474

7575
# Configtree diagram generated by sphinx
7676
docs/_diagrams
77+
78+
# vim swap files
79+
*.swp

HISTORY.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
History
44
=======
55

6+
0.5.3
7+
-----
8+
9+
Released: 2018-01-30
10+
11+
Status: Alpha
12+
13+
- Added: `network.IkeGateway`
14+
- Added: `network.IpsecTunnel`
15+
- Added: `network.IpsecTunnelIpv4ProxyId`
16+
- Added: `network.IpsecTunnelIpv6ProxyId`
17+
- Added: `network.IpsecCryptoProfile`
18+
- Added: `network.IkeCryptoProfile`
19+
- Fix: `enable_ipv6` XPath for various network interface has been corrected
20+
21+
622
0.5.2
723
-----
824

pandevice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
__author__ = 'Palo Alto Networks'
2525
__email__ = '[email protected]'
26-
__version__ = '0.5.2'
26+
__version__ = '0.5.3'
2727

2828

2929
import logging

pandevice/firewall.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class Firewall(PanDevice):
8484
"network.VirtualRouter",
8585
"network.ManagementProfile",
8686
"network.VirtualWire",
87+
"network.IkeGateway",
88+
"network.IpsecTunnel",
89+
"network.IpsecCryptoProfile",
90+
"network.IkeCryptoProfile",
8791
)
8892

8993
def __init__(self,

pandevice/network.py

Lines changed: 900 additions & 21 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
setup(
2525
name='pandevice',
26-
version='0.5.2',
26+
version='0.5.3',
2727
description='Framework for interacting with Palo Alto Networks devices via API',
2828
long_description='The Palo Alto Networks Device Framework is a way to interact with Palo Alto Networks devices (including Next-generation Firewalls and Panorama) using the device API that is object oriented and conceptually similar to interaction with the device via the GUI or CLI.',
2929
author='Palo Alto Networks',

tests/live/test_network.py

Lines changed: 210 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def cleanup_dependencies(self, fw, state):
4848
except Exception:
4949
pass
5050

51+
5152
class TestStaticMac(testlib.FwFlow):
5253
def create_dependencies(self, fw, state):
5354
state.parent = None
@@ -416,6 +417,7 @@ def cleanup_dependencies(self, fw, state):
416417
except IndexError:
417418
pass
418419

420+
419421
class TestL2EthernetInterface(testlib.FwFlow):
420422
def create_dependencies(self, fw, state):
421423
state.management_profiles = []
@@ -867,7 +869,7 @@ class TestOspfExportRules(MakeVirtualRouter):
867869

868870
def setup_state_obj(self, fw, state):
869871
state.obj = network.OspfExportRules(
870-
testlib.random_ip('/24'),
872+
testlib.random_netmask(),
871873
'ext-2', testlib.random_ip(), 2048)
872874
state.ospf.add(state.obj)
873875

@@ -899,3 +901,210 @@ def update_state_obj(self, fw, state):
899901
state.obj.permitted_ip = ['9.8.7.6', ]
900902
state.obj.https = True
901903
state.obj.http_ocsp = False
904+
905+
906+
class TestIkeCryptoProfile(testlib.FwFlow):
907+
def setup_state_obj(self, fw, state):
908+
state.obj = network.IkeCryptoProfile(
909+
testlib.random_name(),
910+
authentication=['sha256', ],
911+
dh_group=['group1', ],
912+
lifetime_minutes=42,
913+
)
914+
fw.add(state.obj)
915+
state.obj.set_encryption('3des')
916+
917+
def update_state_obj(self, fw, state):
918+
state.obj.dh_group = ['group5', 'group2']
919+
state.obj.lifetime_minutes = None
920+
state.obj.lifetime_hours = 4
921+
state.obj.authentication_multiple = 3
922+
state.obj.set_encryption(['3des', 'aes128'])
923+
924+
925+
class TestIpsecCryptoProfile(testlib.FwFlow):
926+
def setup_state_obj(self, fw, state):
927+
state.obj = network.IpsecCryptoProfile(
928+
testlib.random_name(),
929+
ah_authentication=['md5', 'sha256'],
930+
dh_group='group1',
931+
lifetime_hours=4,
932+
lifesize_gb=2,
933+
)
934+
fw.add(state.obj)
935+
936+
def update_state_obj(self, fw, state):
937+
state.obj.ah_authentication = None
938+
state.obj.esp_authentication = ['md5', 'sha512']
939+
state.obj.lifetime_hours = None
940+
state.obj.lifetime_days = 2
941+
state.obj.lifesize_gb = None
942+
state.obj.lifesize_tb = 1
943+
state.obj.set_esp_encryption(['aes128', 'aes192', 'aes256'])
944+
945+
946+
class TestIkeGateway(testlib.FwFlow):
947+
def create_dependencies(self, fw, state):
948+
state.lbi = network.LoopbackInterface(
949+
'loopback.{0}'.format(random.randint(5, 20)),
950+
ip=[testlib.random_ip(), testlib.random_ip()],
951+
)
952+
fw.add(state.lbi)
953+
state.lbi.create()
954+
955+
def setup_state_obj(self, fw, state):
956+
state.obj = network.IkeGateway(
957+
testlib.random_name(),
958+
auth_type='pre-shared-key',
959+
enable_dead_peer_detection=True,
960+
enable_liveness_check=True,
961+
enable_passive_mode=True,
962+
ikev2_crypto_profile='default',
963+
interface=state.lbi.name,
964+
liveness_check_interval=5,
965+
local_id_type='ipaddr',
966+
local_id_value=testlib.random_ip(),
967+
local_ip_address_type='ip',
968+
local_ip_address=state.lbi.ip[0],
969+
peer_ip_type='ip',
970+
peer_ip_value=testlib.random_ip(),
971+
pre_shared_key='secret',
972+
version='ikev2-preferred',
973+
)
974+
fw.add(state.obj)
975+
976+
def update_state_obj(self, fw, state):
977+
state.obj.disabled = True
978+
state.obj.local_ip_address = state.lbi.ip[1]
979+
state.obj.local_id_type = 'fqdn'
980+
state.obj.local_id_value = 'example.com'
981+
state.obj.peer_id_type = 'keyid'
982+
state.obj.peer_id_value = '{0:04x}'.format(random.randint(1, 65535))
983+
984+
def cleanup_dependencies(self, fw, state):
985+
try:
986+
state.lbi.delete()
987+
except Exception:
988+
pass
989+
990+
991+
class TestIkeIpv6Gateway(testlib.FwFlow):
992+
def create_dependencies(self, fw, state):
993+
if fw._version_info < (7, 0, 0):
994+
raise ValueError('IkeGateway not supported for version < 7.0')
995+
996+
state.lbi = network.LoopbackInterface(
997+
'loopback.{0}'.format(random.randint(5, 20)),
998+
ipv6_enabled=True,
999+
)
1000+
state.lbi.add(network.IPv6Address(testlib.random_ipv6()))
1001+
state.lbi.add(network.IPv6Address(testlib.random_ipv6()))
1002+
fw.add(state.lbi)
1003+
state.lbi.create()
1004+
1005+
def setup_state_obj(self, fw, state):
1006+
state.obj = network.IkeGateway(
1007+
testlib.random_name(),
1008+
auth_type='pre-shared-key',
1009+
enable_ipv6=True,
1010+
enable_liveness_check=True,
1011+
ikev2_crypto_profile='default',
1012+
interface=state.lbi.name,
1013+
liveness_check_interval=5,
1014+
local_id_type='ufqdn',
1015+
local_id_value='[email protected]',
1016+
local_ip_address_type='ip',
1017+
local_ip_address=state.lbi.children[0].address,
1018+
peer_id_type='keyid',
1019+
peer_id_value='{0:04x}'.format(random.randint(1, 65535)),
1020+
peer_ip_type='dynamic',
1021+
pre_shared_key='secret',
1022+
version='ikev2',
1023+
)
1024+
fw.add(state.obj)
1025+
1026+
def update_state_obj(self, fw, state):
1027+
state.obj.disabled = True
1028+
state.obj.local_ip_address = state.lbi.children[1].address
1029+
state.obj.enable_liveness_check = False
1030+
1031+
def cleanup_dependencies(self, fw, state):
1032+
try:
1033+
state.lbi.delete()
1034+
except Exception:
1035+
pass
1036+
1037+
1038+
class TestIpv4IpsecTunnel(testlib.FwFlow):
1039+
def create_dependencies(self, fw, state):
1040+
state.ti = network.TunnelInterface(
1041+
'tunnel.{0}'.format(random.randint(5, 50)),
1042+
ip=[testlib.random_ip(), testlib.random_ip()],
1043+
)
1044+
fw.add(state.ti)
1045+
1046+
state.lbi = network.LoopbackInterface(
1047+
'loopback.{0}'.format(random.randint(5, 20)),
1048+
ip=[testlib.random_ip(), testlib.random_ip()],
1049+
)
1050+
fw.add(state.lbi)
1051+
1052+
state.ike_gw = network.IkeGateway(
1053+
testlib.random_name(),
1054+
auth_type='pre-shared-key',
1055+
enable_dead_peer_detection=True,
1056+
enable_liveness_check=True,
1057+
enable_passive_mode=True,
1058+
ikev2_crypto_profile='default',
1059+
interface=state.lbi.name,
1060+
liveness_check_interval=5,
1061+
local_id_type='ipaddr',
1062+
local_id_value=testlib.random_ip(),
1063+
local_ip_address_type='ip',
1064+
local_ip_address=state.lbi.ip[0],
1065+
peer_ip_type='ip',
1066+
peer_ip_value=testlib.random_ip(),
1067+
pre_shared_key='secret',
1068+
version='ikev2-preferred',
1069+
)
1070+
fw.add(state.ike_gw)
1071+
1072+
state.ti.create()
1073+
state.lbi.create()
1074+
state.ike_gw.create()
1075+
1076+
def setup_state_obj(self, fw, state):
1077+
state.obj = network.IpsecTunnel(
1078+
testlib.random_name(),
1079+
tunnel_interface=state.ti.name,
1080+
type='auto-key',
1081+
ak_ike_gateway=state.ike_gw.name,
1082+
ak_ipsec_crypto_profile='default',
1083+
)
1084+
fw.add(state.obj)
1085+
1086+
def update_state_obj(self, fw, state):
1087+
state.obj.anti_replay = True
1088+
state.obj.copy_tos = True
1089+
state.obj.enable_tunnel_monitor = True
1090+
state.obj.tunnel_monitor_dest_ip = testlib.random_ip()
1091+
1092+
def test_05_add_ipv4_proxy_id(self, fw, state_map):
1093+
state = self.sanity(fw, state_map)
1094+
1095+
state.proxy_id = network.IpsecTunnelIpv4ProxyId(
1096+
testlib.random_name(),
1097+
local=testlib.random_netmask(),
1098+
remote=testlib.random_netmask(),
1099+
any_protocol=True,
1100+
)
1101+
state.obj.add(state.proxy_id)
1102+
1103+
state.proxy_id.create()
1104+
1105+
def cleanup_dependencies(self, fw, state):
1106+
for o in (state.ike_gw, state.lbi, state.ti):
1107+
try:
1108+
o.delete()
1109+
except Exception:
1110+
pass

tests/live/testlib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ def random_ip(netmask=None):
2222
)
2323

2424

25+
def random_netmask():
26+
return '{0}.{1}.{2}.0/24'.format(
27+
random.randint(11, 150),
28+
random.randint(1, 200),
29+
random.randint(1, 200),
30+
)
31+
32+
2533
def random_ipv6(ending=None):
2634
if ending is None:
2735
return ':'.join(

0 commit comments

Comments
 (0)