1 | <?php |
||
2 | /** |
||
3 | * FgTrapVpnTunTest.php |
||
4 | * |
||
5 | * -Description- |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation, either version 3 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
19 | * |
||
20 | * @link https://www.librenms.org |
||
21 | * |
||
22 | * @copyright 2019 Tony Murray |
||
23 | * @author Tony Murray <[email protected]> |
||
24 | */ |
||
25 | |||
26 | namespace LibreNMS\Tests\Feature\SnmpTraps; |
||
27 | |||
28 | use App\Models\Device; |
||
29 | use App\Models\Ipv4Address; |
||
30 | use LibreNMS\Snmptrap\Dispatcher; |
||
31 | use LibreNMS\Snmptrap\Trap; |
||
32 | |||
33 | class FgTrapVpnTunTest extends SnmpTrapTestCase |
||
34 | { |
||
35 | public function testVpnTunDown() |
||
36 | { |
||
37 | $device = Device::factory()->create(); /** @var Device $device */ |
||
38 | $ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */ |
||
39 | $trapText = "$device->hostname |
||
40 | UDP: [$device->ip]:57602->[192.168.5.5]:162 |
||
41 | DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81 |
||
42 | SNMPv2-MIB::snmpTrapOID.0 FORTINET-FORTIGATE-MIB::fgTrapVpnTunDown |
||
43 | FORTINET-CORE-MIB::fnSysSerial.0 $device->serial |
||
44 | SNMPv2-MIB::sysName.0 $device->hostname |
||
45 | FORTINET-FORTIGATE-MIB::fgVpnTrapLocalGateway.0 $device->ip |
||
46 | FORTINET-FORTIGATE-MIB::fgVpnTrapRemoteGateway.0 $ipv4->ipv4_address |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
47 | FORTINET-FORTIGATE-MIB::fgVpnTrapPhase1Name.0 test_tunnel_down"; |
||
48 | |||
49 | $message = "VPN tunnel test_tunnel_down to $ipv4->ipv4_address is down"; |
||
50 | \Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 3); |
||
51 | |||
52 | $trap = new Trap($trapText); |
||
53 | $this->assertTrue(Dispatcher::handle($trap), 'Could not handle fgTrapVpnTunDown'); |
||
54 | } |
||
55 | |||
56 | public function testVpnTunUp() |
||
57 | { |
||
58 | $device = Device::factory()->create(); /** @var Device $device */ |
||
59 | $ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */ |
||
60 | $trapText = "$device->hostname |
||
61 | UDP: [$device->ip]:57602->[192.168.5.5]:162 |
||
62 | DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81 |
||
63 | SNMPv2-MIB::snmpTrapOID.0 FORTINET-FORTIGATE-MIB::fgTrapVpnTunUp |
||
64 | SNMPv2-MIB::sysName.0 $device->hostname |
||
65 | FORTINET-FORTIGATE-MIB::fgVpnTrapLocalGateway.0 $device->ip |
||
66 | FORTINET-FORTIGATE-MIB::fgVpnTrapRemoteGateway.0 $ipv4->ipv4_address |
||
0 ignored issues
–
show
The property
ipv4_address does not exist on App\Models\Ipv4Address . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||
67 | FORTINET-FORTIGATE-MIB::fgVpnTrapPhase1Name.0 test_tunnel_up"; |
||
68 | |||
69 | $message = "VPN tunnel test_tunnel_up to $ipv4->ipv4_address is up"; |
||
70 | \Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1); |
||
71 | |||
72 | $trap = new Trap($trapText); |
||
73 | $this->assertTrue(Dispatcher::handle($trap), 'Could not handle fgTrapVpnTunUp'); |
||
74 | } |
||
75 | } |
||
76 |