diff options
author | gpotter2 <gabriel@potter.fr> | 2018-01-21 21:02:35 +0100 |
---|---|---|
committer | gpotter2 <gabriel@potter.fr> | 2018-01-21 21:02:35 +0100 |
commit | 75358aa9aa96089a1c18d1bad7a061a4163a2d80 (patch) | |
tree | ca83c894e1d40d1dd7c11b25ba75c60039ca203a | |
parent | ead1310c01a5bbcec0e0317ace76c27346fcbd81 (diff) | |
download | scapy-75358aa9aa96089a1c18d1bad7a061a4163a2d80.tar.gz |
Add test
-rw-r--r-- | test/mock_windows.uts | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/mock_windows.uts b/test/mock_windows.uts index 81abb6b7..1cb1b560 100644 --- a/test/mock_windows.uts +++ b/test/mock_windows.uts @@ -193,6 +193,81 @@ InterfaceMetric : test_missing_ifacemetric() += Test _get_metrics with weird netsh length + +from scapy.arch.windows import _get_metrics + +@mock.patch("scapy.arch.windows.POWERSHELL_PROCESS.query") +def test_get_metrics(mock_exec_query): + exc_query_output = """Interface Loopback Pseudo-Interface 1 Parameters +------------------------------- +IfLuid : loopback_0 +IfIndex : 1 +State : connected +Metric : 75 +Link MTU : 4294967295 byt +Reachable Time : 40500 ms +Base Reachable Time : 30000 ms +Retransmission Interval : 1000 ms +DAD Transmits : 0 +Site Prefix Length : 64 +Site Id : 1 +Forwarding : disabled +Advertising : disabled +Neighbor Discovery : disabled +Neighbor Unreachability Detection : disabled +Router Discovery : dhcp +Managed Address Configuration : enabled +Other Stateful Configuration : enabled +Weak Host Sends : disabled +Weak Host Receives : disabled +Use Automatic Metric : enabled +Ignore Default Routes : disabled +Advertised Router Lifetime : 1800 seconds +Advertise Default Route : disabled +Current Hop Limit : 0 +Force ARPND Wake up patterns : disabled +Directed MAC Wake up patterns : disabled +ECN capability : application + +Interface Wi-Fi Parameters +------------------------------- +IfLuid : wireless_32768 +IfIndex : 7 +State : connected +Metric : 55 +Link MTU : 1500 bytes +Reachable Time : 43500 ms +Base Reachable Time : 30000 ms +Retransmission Interval : 1000 ms +DAD Transmits : 3 +Site Prefix Length : 64 +Site Id : 1 +Forwarding : disabled +Advertising : disabled +Neighbor Discovery : enabled +Neighbor Unreachability Detection : enabled +Router Discovery : dhcp +Managed Address Configuration : enabled +Other Stateful Configuration : enabled +Weak Host Sends : disabled +Weak Host Receives : disabled +Use Automatic Metric : enabled +Ignore Default Routes : disabled +Advertised Router Lifetime : 1800 seconds +Advertise Default Route : disabled +Current Hop Limit : 0 +Force ARPND Wake up patterns : disabled +Directed MAC Wake up patterns : disabled +ECN capability : application +""" + mock_exec_query.side_effect = lambda *args, **kargs: exc_query_output.split("\n") + metrics = _get_metrics() + print(metrics) + assert metrics == {'1': 75, '7': 55} + +test_get_metrics() + ############ ############ + Windows arch unit tests |