Merge pull request #87 from dbarrosop/base_new_methods

Major enhancements to tests
This commit is contained in:
David Barroso committed 2015-11-30 13:13:22 +01:00
commit fcd9aebfe8
8 files changed
+345 -2

No files matched your search

+37 -2
View File
@@ -15,10 +15,11 @@
import unittest
from napalm.fortios import FortiOSDriver
from base import TestNetworkDriver
from base import TestConfigNetworkDriver, TestGettersNetworkDriver
from pyFG.fortios import FortiConfig
class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver):
class TestConfigFortiOSDriver(unittest.TestCase, TestConfigNetworkDriver):
@classmethod
def setUpClass(cls):
@@ -29,3 +30,37 @@ class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver):
cls.device = FortiOSDriver(hostname, username, password, timeout=60)
cls.device.open()
class TestGetterFortiOSDriver(unittest.TestCase, TestGettersNetworkDriver):
@classmethod
def setUpClass(cls):
cls.mock = True
hostname = '192.168.56.201'
username = 'vagrant'
password = 'vagrant'
cls.vendor = 'eos'
cls.device = FortiOSDriver(hostname, username, password, timeout=60)
if cls.mock:
cls.device.device = FakeFortiOSDevice()
else:
cls.device.open()
class FakeFortiOSDevice:
@staticmethod
def read_txt_file(filename):
with open(filename) as data_file:
return data_file.read().splitlines()
def execute_command(self, command):
return self.read_txt_file('fortios/mock_data/{}.txt'.format(command.replace(' ', '_')))
def load_config(self, config_block):
self.running_config = FortiConfig('running')
self.running_config.parse_config_output(self.read_txt_file('fortios/mock_data/{}.txt'.format(
config_block.replace(' ', '_'))))
@@ -0,0 +1,42 @@
Description Broadcom 570x Tigon3 Ethernet Adapter
Part_Number BCM95718
PHY_Device_ID 5718C
Driver_Name tg3
Driver_Version 3.85l
PCI_Vendor 0x14e4
PCI_Device_ID 0x1656
PCI_Subsystem_Vendor 0x14e4
PCI_Subsystem_ID 0x1656
PCI_Revision_ID 0x5717100
PCI_Address 5:0.1
Memory 0xefe30000
IRQ 17
System_Device_Name mgmt2
Current_HWaddr 00:09:0f:09:00:01
Permanent_HWaddr 08:5b:0e:7a:66:83
Link down
Speed N/A
FlowControl N/A
Rx_Packets 0
Rx_Packets_Dropped 0
Tx_Packets 0
Rx_Bytes 0
Tx_Bytes 0
Rx_Errors 0
Tx_errors 0
Multicast 0
Collisions 0
Rx_Length_Errors 0
Rx_Over_Errors 0
Rx_Frame_Errors 0
Tx_aborted_Errors 0
Tx_carrier_errors 0
Rx_CRC_Errors 0
rx_pending 200
tx_pending 511
tg3_flags a648e425
tg3_flags2 180c9600
tg3_flags3 00603003
rx_rcb_ptr 00000000
rx_producer 00000000
num_reset 0
@@ -0,0 +1,93 @@
Description :FortiASIC NP4 Adapter
Driver Name :FortiASIC Unified NPU Driver
Version :1.0
PCI Slot :01:00.0
PCI_Revision_ID :1
Board :fgt800c
SN :FG800C3914800949
Major ID :19
Minor ID :0
LIF ID :1
NPU OID :1
NPU OID_VID :3
netdev flags :0x00001303
Current_HWaddr 00:09:0f:09:00:02
Permanent_HWaddr 08:5b:0e:7a:66:69
Queue :On
rx_buffer_len :2048
max_frame_size :1522
min_frame_size :278
MTU :1500
Hidden :No
dyn_lif :0
npu_cap :0000601f
ses_mask :40027dcb
cmd_in_queue :0
half_id :1
phy_addr :0x01
phy_flags :0x4002
medium_type :Copper
sw_port :3
sw_np_port :29
sw_stats_port :0
phy_oid :0x01
slot_id :0x00
vid_phy[6] :[0003][0000][0000][0000][0000][0000]
vid_fwd[6] :[0000][0000][0000][0000][0000][0000]
oid_fwd[6] :[0000][0000][0000][0000][0000][0000]
========== Link Status ==========
Admin :up
PHY Status :up
PHY Speed :1000
Duplex :Full
link_status :1
rx_link_status :1
remote_fault :0
local_fault :0
local_warning :0
int_phy_link :0
int_phy_reinit_cnt:0
link_andone :0
serdes_mode :SerDes
============ Counters ===========
clst_tx_orig :0
clst_tx_o_free :0
clst_tx_redir :0
clst_tx_rd_free :0
clst_tx_reply :0
clst_tx_rp_free :0
dd_wo_eop :0
tcp_udp_csum_err:0
rx_error :0
rx_crc_error :0
rx_len_error :0
rx_carrier :0
rx_oversize :0
rx_undersize :0
tx_collision :0
ip_sum_offload :0
ipsec_dec :0
ipsec_dec_drop :0
ipsec_antireplay_f:0
ipsec_antireplay_p:0
aps_log :0
Rx Pkts :188895694
Rx Bytes :82538535564
Tx Pkts :297621641
Tx Bytes :236894931491
Host Rx Pkts :188895680
Host Rx Bytes :79138411812
Host Tx Pkts :297622192
Host Tx Bytes :238680266080
sw_rx_pkts :188895695
sw_rx_bytes :934157048
sw_tx_pkts :297621645
sw_tx_bytes :671734297
sw_rx_mc_pkts :166
sw_rx_bc_pkts :110805703
sw_np_rx_pkts :416031055
sw_np_rx_bytes :251347608749
sw_np_tx_pkts :299701544
sw_np_tx_bytes :95704383998
sw_np_rx_mc_pkts:78
sw_np_rx_bc_pkts:236817338
@@ -0,0 +1 @@
domain : spotify.net
@@ -0,0 +1,15 @@
== [ mgmt1 ]
== [ mgmt2 ]
== [ wan1 ]
== [ wan2 ]
== [ port1 ]
== [ port2 ]
== [ modem ]
== [ ssl.root ]
== [ npu0-vlink0 ]
== [ npu0-vlink1 ]
== [ pub0 ]
== [ svc0 ]
== [ forticlient ]
== [ native ]
== [ MY_VPN ]
@@ -0,0 +1,12 @@
CPU states: 0% user 18% system 0% nice 82% idle
CPU0 states: 0% user 22% system 0% nice 78% idle
CPU1 states: 0% user 15% system 0% nice 85% idle
CPU2 states: 0% user 17% system 0% nice 83% idle
CPU3 states: 0% user 19% system 0% nice 81% idle
Memory states: 49% used
Average network usage: 141989 kbps in 1 minute, 125760 kbps in 10 minutes, 146591 kbps in 30 minutes
Average sessions: 14482 sessions in 1 minute, 14837 sessions in 10 minutes, 14965 sessions in 30 minutes
Average session setup rate: 259 sessions per second in last 1 minute, 154 sessions per second in last 10 minutes, 193 sessions per second in last 30 minutes
Virus caught: 0 total in 1 minute
IPS attacks blocked: 0 total in 1 minute
Uptime: 274 days, 1 hours, 41 minutes
@@ -0,0 +1,24 @@
vpn-sto3-z8r307-2 # get system status
Version: FortiGate-800C v5.2.2,build0642,141118 (GA)
Virus-DB: 16.00560(2012-10-19 08:31)
Extended DB: 1.00000(2012-10-17 15:46)
Extreme DB: 1.00000(2012-10-17 15:47)
IPS-DB: 5.00555(2014-10-07 01:21)
IPS-ETDB: 0.00000(2001-01-01 00:00)
Serial-Number: FG800C3914800949
Botnet DB: 1.00000(2012-05-28 22:51)
BIOS version: 04000038
System Part-Number: P11496-05
Log hard disk: Available
Hostname: vpn-sto3-z8r307-2
Operation Mode: NAT
Current virtual domain: root
Max number of virtual domains: 10
Virtual domains status: 1 in NAT mode, 0 in TP mode
Virtual domain configuration: disable
FIPS-CC mode: disable
Current HA mode: a-p, master
Branch point: 642
Release Version Information: GA
FortiOS x86-64: Yes
System time: Thu Nov 26 06:46:57 2015
@@ -0,0 +1,121 @@
config system interface
edit "mgmt1"
set ip 10.209.32.126 255.255.240.0
set allowaccess ping https ssh snmp
set vlanforward enable
set type physical
set dedicated-to management
set snmp-index 2
set defaultgw disable
next
edit "mgmt2"
set vdom "root"
set vlanforward enable
set type physical
set snmp-index 4
next
edit "wan1"
set vdom "root"
set vlanforward enable
set type physical
set snmp-index 5
next
edit "wan2"
set vdom "root"
set vlanforward enable
set type physical
set snmp-index 6
next
edit "port1"
set vdom "root"
set allowaccess ping https
set vlanforward enable
set type physical
set snmp-index 1
next
edit "port2"
set vdom "root"
set vlanforward enable
set type physical
set snmp-index 7
next
edit "modem"
set vdom "root"
set mode pppoe
set vlanforward enable
set type physical
set snmp-index 3
next
edit "ssl.root"
set vdom "root"
set vlanforward enable
set status down
set type tunnel
set alias "sslvpn tunnel interface"
set snmp-index 30
next
edit "npu0-vlink0"
set vdom "root"
set vlanforward enable
set status down
set type physical
set snmp-index 32
next
edit "npu0-vlink1"
set vdom "root"
set vlanforward enable
set status down
set type physical
set snmp-index 33
next
edit "pub0"
set vdom "root"
set ip 192.168.181.235 255.255.255.248
set allowaccess ping
set vlanforward enable
set snmp-index 31
set interface "port1"
set vlanid 22
next
edit "svc0"
set vdom "root"
set ip 192.168.169.235 255.255.255.248
set allowaccess ping
set vlanforward enable
set snmp-index 34
set interface "port11"
set vlanid 32
next
edit "forticlient"
set vdom "root"
set ip 10.210.0.1 255.255.255.255
set allowaccess ping ssh
set vlanforward enable
set type tunnel
set remote-ip 10.210.0.1
set listen-forticlient-connection enable
set snmp-index 39
set interface "pub0"
next
edit "native"
set vdom "root"
set ip 10.210.1.1 255.255.255.255
set allowaccess ping ssh
set vlanforward enable
set type tunnel
set remote-ip 10.210.1.1
set snmp-index 40
set interface "pub0"
next
edit "MY_VPN"
set vdom "root"
set ip 10.15.2.160 255.255.255.255
set allowaccess ping ssh
set vlanforward enable
set type tunnel
set remote-ip 10.15.2.161
set snmp-index 41
set interface "pub0"
next
end