PHPStan fixes (#13038)

* PHPStan fixes
mostly type fixes
semi-risky changes in availability map widget, tested a bit

* fix style

* Style fix

* restore spaces stupid editor removed

* fix the rest

* device model back

* remove ignores

* introduce variable
This commit is contained in:
Tony Murray
2021-07-13 16:35:43 -05:00
committed by GitHub
parent c563efd284
commit 58ca5994a1
61 changed files with 323 additions and 441 deletions

View File

@@ -51,12 +51,14 @@ class OS implements Module
public function poll(\LibreNMS\OS $os)
{
$deviceModel = $os->getDevice();
$deviceModel = $os->getDevice(); /** @var \App\Models\Device $deviceModel */
if ($os instanceof OSPolling) {
$os->pollOS();
} else {
// legacy poller files
global $graphs, $device;
$location = null;
if (is_file(base_path('/includes/polling/os/' . $device['os'] . '.inc.php'))) {
// OS Specific
include base_path('/includes/polling/os/' . $device['os'] . '.inc.php');
@@ -74,7 +76,6 @@ class OS implements Module
$deviceModel->serial = ($serial ?? $deviceModel->serial) ?: null;
if (! empty($location)) { // legacy support, remove when no longer needed
/** @phpstan-ignore-next-line */
$deviceModel->setLocation($location);
optional($deviceModel->location)->save();
}

View File

@@ -39,6 +39,7 @@ use App\Models\Sensor;
use App\Models\Service;
use App\Models\Vrf;
use Cache;
use Illuminate\Support\Collection;
class ObjectCache
{
@@ -47,10 +48,13 @@ class ObjectCache
public static function applications()
{
return Cache::remember('ObjectCache:applications_list:' . auth()->id(), self::$cache_time, function () {
return Application::hasAccess(auth()->user())
->select('app_type', 'app_state', 'app_instance')
$user = auth()->user(); /** @var \App\Models\User $user */
$applications = Application::hasAccess($user)
->select(['app_type', 'app_state', 'app_instance'])
->groupBy('app_type', 'app_state', 'app_instance')
->get()
->get(); /** @var Collection $applications */
return $applications
->sortBy('show_name', SORT_NATURAL | SORT_FLAG_CASE)
->groupBy('app_type');
});
@@ -59,7 +63,7 @@ class ObjectCache
public static function routing()
{
return Cache::remember('ObjectCache:routing_counts:' . auth()->id(), self::$cache_time, function () {
$user = auth()->user();
$user = auth()->user(); /** @var \App\Models\User $user */
return [
'vrf' => Vrf::hasAccess($user)->count(),
@@ -76,7 +80,8 @@ class ObjectCache
public static function sensors()
{
return Cache::remember('ObjectCache:sensor_list:' . auth()->id(), self::$cache_time, function () {
$sensor_classes = Sensor::hasAccess(auth()->user())->select('sensor_class')->groupBy('sensor_class')->orderBy('sensor_class')->get();
$user = auth()->user(); /** @var \App\Models\User $user */
$sensor_classes = Sensor::hasAccess($user)->select('sensor_class')->groupBy('sensor_class')->orderBy('sensor_class')->get();
$sensor_menu = [];
foreach ($sensor_classes as $sensor_model) {
@@ -100,7 +105,7 @@ class ObjectCache
];
}
if (PrinterSupply::hasAccess(auth()->user())->exists()) {
if (PrinterSupply::hasAccess($user)->exists()) {
$sensor_menu[3] = [
[
'class' => 'toner',

View File

@@ -70,7 +70,7 @@ class UserController extends Controller
$this->authorize('create', User::class);
$tmp_user = new User;
$tmp_user->can_modify_passwd = LegacyAuth::get()->canUpdatePasswords(); // default to true for new users
$tmp_user->can_modify_passwd = (int) LegacyAuth::get()->canUpdatePasswords(); // default to true for new users
return view('user.create', [
'user' => $tmp_user,

View File

@@ -99,43 +99,47 @@ class AvailabilityMapController extends WidgetController
$device_query->isNotDisabled();
}
$device_query->orderBy($settings['order_by']);
$devices = $device_query->select('devices.device_id', 'hostname', 'sysName', 'status', 'uptime', 'last_polled', 'disabled', 'disable_notify', 'location_id')->get();
$devices = $device_query->select(['devices.device_id', 'hostname', 'sysName', 'status', 'uptime', 'last_polled', 'disabled', 'disable_notify', 'location_id'])->get();
// process status
$uptime_warn = Config::get('uptime_warning', 84600);
$totals = ['warn' => 0, 'up' => 0, 'down' => 0, 'maintenance' => 0, 'ignored' => 0, 'disabled' => 0];
$data = [];
foreach ($devices as $device) {
$row = ['device' => $device];
if ($device->disabled) {
$totals['disabled']++;
$device->stateName = 'disabled';
$device->labelClass = 'blackbg';
$row['stateName'] = 'disabled';
$row['labelClass'] = 'blackbg';
} elseif ($device->disable_notify) {
$totals['ignored']++;
$device->stateName = 'alert-dis';
$device->labelClass = 'label-default';
$row['stateName'] = 'alert-dis';
$row['labelClass'] = 'label-default';
} elseif ($device->status == 1) {
if (($device->uptime < $uptime_warn) && ($device->uptime != 0)) {
$totals['warn']++;
$device->stateName = 'warn';
$device->labelClass = 'label-warning';
$row['stateName'] = 'warn';
$row['labelClass'] = 'label-warning';
} else {
$totals['up']++;
$device->stateName = 'up';
$device->labelClass = 'label-success';
$row['stateName'] = 'up';
$row['labelClass'] = 'label-success';
}
} else {
$totals['down']++;
$device->stateName = 'down';
$device->labelClass = 'label-danger';
$row['stateName'] = 'down';
$row['labelClass'] = 'label-danger';
}
if ($device->isUnderMaintenance()) {
$device->labelClass = 'label-default';
$row['labelClass'] = 'label-default';
$totals['maintenance']++;
}
$data[] = $row;
}
return [$devices, $totals];
return [$data, ['warn' => 0, 'up' => 0, 'down' => 0, 'maintenance' => 0, 'ignored' => 0, 'disabled' => 0]];
}
private function getServices($request)
@@ -155,25 +159,28 @@ class AvailabilityMapController extends WidgetController
$services_query->leftJoin('devices', 'services.device_id', 'devices.device_id')->orderBy('hostname')->orderBy('service_type');
}
$services = $services_query->with(['device' => function ($query) {
$query->select('devices.device_id', 'hostname', 'sysName');
}])->select('service_id', 'services.device_id', 'service_type', 'service_desc', 'service_status')->get();
$query->select(['devices.device_id', 'hostname', 'sysName']);
}])->select(['service_id', 'services.device_id', 'service_type', 'service_desc', 'service_status'])->get();
// process status
$totals = ['warn' => 0, 'up' => 0, 'down' => 0];
$data = [];
foreach ($services as $service) {
$row = ['service' => $service];
if ($service->service_status == 0) {
$service->labelClass = 'label-success';
$service->stateName = 'up';
$row['labelClass'] = 'label-success';
$row['stateName'] = 'up';
$totals['up']++;
} elseif ($service->service_status == 1) {
$service->labelClass = 'label-warning';
$service->stateName = 'warn';
$row['labelClass'] = 'label-warning';
$row['stateName'] = 'warn';
$totals['warn']++;
} else {
$service->labelClass = 'label-danger';
$service->stateName = 'down';
$row['labelClass'] = 'label-danger';
$row['stateName'] = 'down';
$totals['down']++;
}
$data[] = $row;
}
return [$services, $totals];

View File

@@ -129,7 +129,7 @@ class TopDevicesController extends WidgetController
/** @var Builder $query */
return $query->with(['device' => function ($query) {
$query->select('device_id', 'hostname', 'sysName', 'status', 'os');
return $query->select('device_id', 'hostname', 'sysName', 'status', 'os');
}])
->select("$left_table.device_id")
->leftJoin('devices', "$left_table.device_id", 'devices.device_id')
@@ -137,7 +137,9 @@ class TopDevicesController extends WidgetController
->where('devices.last_polled', '>', Carbon::now()->subMinutes($settings['time_interval']))
->when($settings['device_group'], function ($query) use ($settings) {
/** @var Builder<\App\Models\DeviceRelatedModel> $query */
return $query->inDeviceGroup($settings['device_group']);
$inDeviceGroup = $query->inDeviceGroup($settings['device_group']); /** @var Builder $inDeviceGroup */
return $inDeviceGroup;
});
}
@@ -151,7 +153,7 @@ class TopDevicesController extends WidgetController
return Device::hasAccess(Auth::user())->select('device_id', 'hostname', 'sysName', 'status', 'os')
->where('devices.last_polled', '>', Carbon::now()->subMinutes($settings['time_interval']))
->when($settings['device_group'], function ($query) use ($settings) {
$query->inDeviceGroup($settings['device_group']);
return $query->inDeviceGroup($settings['device_group']);
})
->limit($settings['device_count']);
}
@@ -189,9 +191,9 @@ class TopDevicesController extends WidgetController
->groupBy('device_id')
->where('poll_time', '>', Carbon::now()->subMinutes($settings['time_interval'])->timestamp)
->when($settings['device_group'], function ($query) use ($settings) {
$query->inDeviceGroup($settings['device_group']);
return $query->inDeviceGroup($settings['device_group']);
}, function ($query) {
$query->has('device');
return $query->has('device');
})
->orderByRaw('SUM(ifInOctets_rate + ifOutOctets_rate) ' . $sort)
->limit($settings['device_count']);

View File

@@ -54,7 +54,7 @@ class TopErrorsController extends WidgetController
$query->select('device_id', 'hostname', 'sysName', 'status', 'os');
}])
->isValid()
->select('port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias')
->select(['port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias'])
->groupBy('port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias')
->where('poll_time', '>', Carbon::now()->subMinutes($data['time_interval'])->timestamp)
->where(function ($query) {
@@ -64,12 +64,12 @@ class TopErrorsController extends WidgetController
})
->isUp()
->when($data['device_group'], function ($query) use ($data) {
$query->inDeviceGroup($data['device_group']);
return $query->inDeviceGroup($data['device_group']);
}, function ($query) {
$query->has('device');
return $query->has('device');
})
->when($data['port_group'], function ($query) use ($data) {
$query->inPortGroup($data['port_group']);
return $query->inPortGroup($data['port_group']);
})
->orderByRaw('SUM(LEAST(ifInErrors_rate, 9223372036854775807) + LEAST(ifOutErrors_rate, 9223372036854775807)) DESC')
->limit($data['interface_count']);

View File

@@ -52,17 +52,17 @@ class TopInterfacesController extends WidgetController
$query->select('device_id', 'hostname', 'sysName', 'status', 'os');
}])
->isValid()
->select('port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias')
->select(['port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias'])
->groupBy('port_id', 'device_id', 'ifName', 'ifDescr', 'ifAlias')
->where('poll_time', '>', Carbon::now()->subMinutes($data['time_interval'])->timestamp)
->isUp()
->when($data['device_group'], function ($query) use ($data) {
$query->inDeviceGroup($data['device_group']);
return $query->inDeviceGroup($data['device_group']);
}, function ($query) {
$query->has('device');
return $query->has('device');
})
->when($data['port_group'], function ($query) use ($data) {
$query->inPortGroup($data['port_group']);
return $query->inPortGroup($data['port_group']);
})
->orderByRaw('SUM(LEAST(ifInOctets_rate, 9223372036854775807) + LEAST(ifOutOctets_rate, 9223372036854775807)) DESC')
->limit($data['interface_count']);

View File

@@ -27,12 +27,12 @@ class BgpPeerFactory extends Factory
'bgpPeerRemoteAddr' => $this->faker->ipv4,
'bgpPeerRemoteAs' => $this->faker->numberBetween(1, 65535),
'bgpPeerState' => $this->faker->randomElement(['established', 'idle']),
'astext' => $this->faker->sentence(),
'astext' => $this->faker->sentence,
'bgpPeerAdminStatus' => $this->faker->randomElement(['start', 'stop']),
'bgpPeerInUpdates' => $this->faker->randomDigit,
'bgpPeerOutUpdates' => $this->faker->randomDigit,
'bgpPeerInTotalMessages' => $this->faker->randomDigit,
'bgpPeerOutTotalMessages' => $this->faker->randomDigit,
'bgpPeerInUpdates' => $this->faker->randomDigit(),
'bgpPeerOutUpdates' => $this->faker->randomDigit(),
'bgpPeerInTotalMessages' => $this->faker->randomDigit(),
'bgpPeerOutTotalMessages' => $this->faker->randomDigit(),
'bgpPeerFsmEstablishedTime' => $this->faker->unixTime,
'bgpPeerInUpdateElapsedTime' => $this->faker->unixTime,
];

View File

@@ -22,7 +22,7 @@ class ComponentFactory extends Factory
public function definition()
{
return [
'device_id' => $this->faker->randomDigit,
'device_id' => $this->faker->randomDigit(),
'type' => $this->faker->regexify('[A-Za-z0-9]{4,20}'),
];
}

View File

@@ -3,6 +3,8 @@
namespace Database\Factories;
use App\Models\Ipv4Address;
use App\Models\Ipv4Network;
use App\Models\Port;
use Illuminate\Database\Eloquent\Factories\Factory;
use LibreNMS\Util\IPv4;
@@ -29,10 +31,14 @@ class Ipv4AddressFactory extends Factory
'ipv4_address' => $ip->uncompressed(),
'ipv4_prefixlen' => $prefix,
'port_id' => function () {
return \App\Models\Port::factory()->create()->port_id;
$port = Port::factory()->create(); /** @var Port $port */
return $port->port_id;
},
'ipv4_network_id' => function () use ($ip) {
return \App\Models\Ipv4Network::factory()->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr])->ipv4_network_id;
$ipv4 = Ipv4Network::factory()->create(['ipv4_network' => $ip->getNetworkAddress() . '/' . $ip->cidr]); /** @var Ipv4Address $ipv4 */
return $ipv4->ipv4_network_id;
},
];
}

View File

@@ -22,13 +22,13 @@ class OspfNbrFactory extends Factory
public function definition()
{
return [
'id' => $this->faker->randomDigit,
'id' => $this->faker->randomDigit(),
'ospfNbrIpAddr' => $this->faker->ipv4,
'ospfNbrAddressLessIndex' => $this->faker->randomDigit,
'ospfNbrAddressLessIndex' => $this->faker->randomDigit(),
'ospfNbrRtrId' => $this->faker->ipv4,
'ospfNbrOptions' => 0,
'ospfNbrPriority' => 1,
'ospfNbrEvents' => $this->faker->randomDigit,
'ospfNbrEvents' => $this->faker->randomDigit(),
'ospfNbrLsRetransQLen' => 0,
'ospfNbmaNbrStatus' => 'active',
'ospfNbmaNbrPermanence' => 'dynamic',

View File

@@ -22,10 +22,10 @@ class OspfPortFactory extends Factory
public function definition()
{
return [
'id' => $this->faker->randomDigit,
'ospf_port_id' => $this->faker->randomDigit,
'id' => $this->faker->randomDigit(),
'ospf_port_id' => $this->faker->randomDigit(),
'ospfIfIpAddress' => $this->faker->ipv4,
'ospfAddressLessIf' => $this->faker->randomDigit,
'ospfAddressLessIf' => $this->faker->randomDigit(),
'ospfIfAreaId' => '0.0.0.0',
];
}

View File

@@ -25,9 +25,9 @@ class SensorFactory extends Factory
$sensor_oid = '.1.3.6.1.4.1.4115.1.4.3.3.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10) . '.' . $this->faker->numberBetween(0, 10);
return [
'sensor_index' => $this->faker->randomDigit,
'sensor_index' => $this->faker->randomDigit(),
'sensor_class' => $this->faker->randomElement($sensor_class),
'sensor_current' => $this->faker->randomDigit,
'sensor_current' => $this->faker->randomDigit(),
'sensor_oid' => $sensor_oid,
];
}

View File

@@ -24,11 +24,11 @@ class VminfoFactory extends Factory
{
return [
'vm_type' => $this->faker->text(16),
'vmwVmVMID' => $this->faker->randomDigit,
'vmwVmVMID' => $this->faker->randomDigit(),
'vmwVmDisplayName' => $this->faker->domainWord . '.' . $this->faker->domainName,
'vmwVmGuestOS' => $this->faker->text(128),
'vmwVmMemSize' => $this->faker->randomDigit,
'vmwVmCpus' => $this->faker->randomDigit,
'vmwVmMemSize' => $this->faker->randomDigit(),
'vmwVmCpus' => $this->faker->randomDigit(),
'vmwVmState' => $this->faker->randomElement([PowerState::OFF, PowerState::ON, PowerState::SUSPENDED, PowerState::UNKNOWN]),
];
}

View File

@@ -25,38 +25,38 @@
<br style="clear:both;">
@foreach($devices as $device)
<a href="@deviceUrl($device)" title="{{$device->displayName() }}@if($device->stateName == 'up' or $device->stateName == 'warn')@if($device->formatDownUptime(true)) - @endif{{ $device->formatDownUptime(true) }}@elseif($device->stateName == 'down')@if($device->formatDownUptime(true)) - downtime @endif{{$device->formatDownUptime(true)}}@endif">
@foreach($devices as $row)
<a href="@deviceUrl($row['device'])" title="{{$row['device']->displayName() }}@if($row['stateName'] == 'up' or $row['stateName'] == 'warn')@if($row['device']->formatDownUptime(true)) - @endif{{ $row['device']->formatDownUptime(true) }}@elseif($row['stateName'] == 'down')@if($row['device']->formatDownUptime(true)) - downtime @endif{{$row['device']->formatDownUptime(true)}}@endif">
@if($type == 0)
@if($color_only_select == 1)
<span class="label {{ $device->labelClass }} widget-availability-fixed widget-availability label-font-border"> </span>
<span class="label {{ $row['labelClass'] }} widget-availability-fixed widget-availability label-font-border"> </span>
@else
@if($color_only_select == 2)
<span class="label {{ $device->labelClass }} widget-availability label-font-border">@lang($device->hostname)</span>
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">@lang($row['device']->hostname)</span>
@else
@if($color_only_select == 3)
<span class="label {{ $device->labelClass }} widget-availability label-font-border">@lang($device->sysName)</span>
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">@lang($row['device']->sysName)</span>
@else
<span class="label {{ $device->labelClass }} widget-availability label-font-border">@lang($device->stateName)</span>
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">@lang($row['stateName'])</span>
@endif
@endif
@endif
@else
<div class="availability-map-oldview-box-{{ $device->stateName }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
<div class="availability-map-oldview-box-{{ $row['stateName'] }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
@endif
</a>
@endforeach
@foreach($services as $service)
<a href="@deviceUrl($service->device, ['tab' => 'services'])" title="{{ $service->device->displayName() }} - {{ $service->service_type }} - {{ $service->service_desc }}">
@foreach($services as $row)
<a href="@deviceUrl($row['service']->device, ['tab' => 'services'])" title="{{ $row['service']->device->displayName() }} - {{ $row['service']->service_type }} - {{ $row['service']->service_desc }}">
@if($type == 0)
@if($color_only_select)
<span class="label {{ $service->labelClass }} widget-availability-fixed widget-availability label-font-border"> </span>
<span class="label {{ $row['labelClass'] }} widget-availability-fixed widget-availability label-font-border"> </span>
@else
<span class="label {{ $service->labelClass }} widget-availability label-font-border">{{ $service->service_type }} - {{ $service->stateName }}</span>
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['service']->service_type }} - {{ $row['stateName'] }}</span>
@endif
@else
<div class="availability-map-oldview-box-{{ $service->stateName }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
<div class="availability-map-oldview-box-{{ $row['stateName'] }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
@endif
</a>
@endforeach

View File

@@ -28,8 +28,7 @@ class LoginTest extends DuskTestCase
$password = 'some_password';
$user = User::factory()->create([
'password' => password_hash($password, PASSWORD_DEFAULT),
]);
]); /** @var User $user */
$browser->visit(new LoginPage())
->type('username', $user->username)
->type('password', 'wrong_password')
@@ -54,7 +53,7 @@ class LoginTest extends DuskTestCase
$password = 'another_password';
$user = User::factory()->create([
'password' => password_hash($password, PASSWORD_DEFAULT),
]);
]); /** @var User $user */
Config::persist('twofactor', true); // set to db
UserPref::setPref($user, 'twofactor', [
'key' => '5P3FLXBX7NU3ZBFOTWZL2GL5MKFEWBOA', // known key: 634456, 613687, 064292

View File

@@ -32,8 +32,7 @@ class AdvaAccThresholdCrossingAlertTest extends SnmpTrapTestCase
{
public function testAccThresholdTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaAttributeChangeTest extends SnmpTrapTestCase
{
public function testSyslogIPVersionModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -53,8 +52,7 @@ ADVA-MIB::neEventLogTimeStamp.150 2018-12-10,9:11:40.5,-6:0";
public function testSyslogIP6AddrModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -74,8 +72,7 @@ ADVA-MIB::neEventLogTimeStamp.150 2018-12-10,9:11:40.5,-6:0";
public function testSyslogIPAddrModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -95,8 +92,7 @@ ADVA-MIB::neEventLogTimeStamp.150 2018-12-10,9:11:40.5,-6:0";
public function testSyslogPortModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -116,8 +112,7 @@ ADVA-MIB::neEventLogTimeStamp.150 2018-12-10,9:11:40.5,-6:0";
public function testAclModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -137,8 +132,7 @@ ADVA-MIB::neEventLogTimeStamp.155 2018-12-10,9:17:22.5,-6:0";
public function testBannerModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -158,8 +152,7 @@ ADVA-MIB::neEventLogTimeStamp.157 2018-12-10,9:18:43.6,-6:0";
public function testTimeSourceModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -197,8 +190,7 @@ ADVA-MIB::neEventLogTimeStamp.169 2018-12-10,9:28:57.1,-6:0";
public function testTimeZoneModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -250,8 +242,7 @@ ADVA-MIB::neEventLogTimeStamp.160 2018-12-10,10:21:30.3,-5:0";
public function testNtpModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -289,8 +280,7 @@ ADVA-MIB::neEventLogTimeStamp.170 2018-12-10,9:30:17.0,-6:0";
public function testAuthServerModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -336,8 +326,7 @@ ADVA-MIB::neEventLogTimeStamp.173 2018-12-10,9:32:18.1,-6:0";
public function testNeModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -361,8 +350,7 @@ ADVA-MIB::neEventLogTimeStamp.175 2018-12-10,9:34:23.0,-6:0";
public function testSnmpDyingGaspStateModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -398,8 +386,7 @@ ADVA-MIB::neEventLogTimeStamp.177 2018-12-10,9:36:14.5,-6:0";
public function testNetPortModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -456,8 +443,7 @@ ADVA-MIB::neEventLogTimeStamp.188 2018-12-10,9:41:49.0,-6:0";
public function testAccPortModied()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -515,8 +501,7 @@ ADVA-MIB::neEventLogTimeStamp.214 2018-12-10,9:43:22.3,-6:0";
public function testAccFlowModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -539,8 +524,7 @@ ADVA-MIB::neEventLogTimeStamp.147 2018-12-10,9:7:28.1,-6:0";
public function testLagModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -560,8 +544,7 @@ ADVA-MIB::neEventLogTimeStamp.113 2018-12-10,8:58:43.7,-6:0";
public function testQosFlowPolicerModfied()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -584,8 +567,7 @@ ADVA-MIB::neEventLogTimeStamp.217 2018-12-10,9:47:51.0,-6:0";
public function testQosShaperModified()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -606,8 +588,7 @@ ADVA-MIB::neEventLogTimeStamp.218 2018-12-10,9:47:51.0,-6:0";
public function testAccShaper()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaDyingGaspTrapTest extends SnmpTrapTestCase
{
public function testDyingGasp()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaNetThresholdCrossingAlertTest extends SnmpTrapTestCase
{
public function testNetThresholdTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaNetworkElementAlmTrapTest extends SnmpTrapTestCase
{
public function testElementAlarmCleared()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -64,8 +63,7 @@ ADVA-MIB::neEventLogTimeStamp.231 2018-12-10,11:1:43.3,-6:0";
public function testElementAlarmMinor()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -96,8 +94,7 @@ ADVA-MIB::neEventLogTimeStamp.231 2018-12-10,11:1:43.3,-6:0";
public function testElementAlarmMajor()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -128,8 +125,7 @@ ADVA-MIB::neEventLogTimeStamp.231 2018-12-10,11:1:43.3,-6:0";
public function testElementAlarmCritical()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaObjectCreationTest extends SnmpTrapTestCase
{
public function testUserCreation()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -56,8 +55,7 @@ ADVA-MIB::neEventLogTimeStamp.91 2018-12-10,8:55:41.1,-6:0";
public function testLagCreation()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaObjectDeletionTest extends SnmpTrapTestCase
{
public function testUserDeletion()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -53,8 +52,7 @@ ADVA-MIB::neEventLogTimeStamp.92 2018-12-10,8:56:27.5,-6:0";
public function testFLowDeletion()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -74,8 +72,7 @@ ADVA-MIB::neEventLogTimeStamp.148 2018-12-10,9:7:28.1,-6:0";
public function testLagPortDeletion()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -95,8 +92,7 @@ ADVA-MIB::neEventLogTimeStamp.136 2018-12-10,9:3:51.3,-6:0";
public function testLagDeletion()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -32,8 +32,7 @@ class AdvaStateChangeTrapTest extends SnmpTrapTestCase
{
public function testAccessPortChg()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68
@@ -56,8 +55,7 @@ ADVA-MIB::neEventLogTimeStamp.48 2018-12-10,11:20:40.7,-6:0";
public function testNetworkPortChg()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68
@@ -80,8 +78,7 @@ ADVA-MIB::neEventLogTimeStamp.19 2018-12-10,11:17:7.9,-6:0";
public function testFlowStateChg()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68

View File

@@ -32,8 +32,7 @@ class AdvaSysAlmTrapTest extends SnmpTrapTestCase
{
public function testCriticalAlarm()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68
@@ -57,8 +56,7 @@ CM-ALARM-MIB::cmSysAlmDescr.5 \"Critical alarm test\"";
public function testMajorAlarm()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68
@@ -82,8 +80,7 @@ CM-ALARM-MIB::cmSysAlmDescr.5 \"Major alarm test\"";
public function testMinorAlarm()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68
@@ -107,8 +104,7 @@ CM-ALARM-MIB::cmSysAlmDescr.5 \"Minor alarm test\"";
public function testClearedAlarm()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:15:22.68

View File

@@ -30,8 +30,7 @@ class ApcPduOutletTest extends SnmpTrapTestCase
{
public function testOutletOff()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 84:21:45:07.07
@@ -49,8 +48,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 PowerNet-MIB::apc";
public function testOutletOn()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 84:21:45:07.07
@@ -68,8 +66,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 PowerNet-MIB::apc";
public function testOutletReboot()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 84:21:45:07.07

View File

@@ -36,8 +36,8 @@ class BgpTrapTest extends SnmpTrapTestCase
{
// Cache it to avoid DNS Lookup
Config::set('astext.1', 'PHPUnit ASTEXT');
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'idle', 'bgpPeerRemoteAs' => 1]);
$device = Device::factory()->create(); /** @var Device $device */
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'idle', 'bgpPeerRemoteAs' => 1]); /** @var BgpPeer $bgppeer */
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname
@@ -61,8 +61,8 @@ BGP4-MIB::bgpPeerState.$bgppeer->bgpPeerIdentifier established\n";
{
// Cache it to avoid DNS Lookup
Config::set('astext.1', 'PHPUnit ASTEXT');
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'established', 'bgpPeerRemoteAs' => 1]);
$device = Device::factory()->create(); /** @var Device $device */
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'established', 'bgpPeerRemoteAs' => 1]); /** @var BgpPeer $bgppeer */
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname

View File

@@ -43,10 +43,11 @@ class CommonTrapTest extends SnmpTrapTestCase
public function testFindByIp()
{
$device = Device::factory()->create();
$port = Port::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(); /** @var Port $port */
$device->ports()->save($port);
$ipv4 = Ipv4Address::factory()->make(); // test ipv4 lookup of device
// test ipv4 lookup of device
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$port->ipv4()->save($ipv4);
$trapText = "something
@@ -69,8 +70,7 @@ DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91\n";
public function testGenericTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -89,8 +89,7 @@ SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::someOid\n";
public function testAuthorization()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -107,8 +106,7 @@ SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::authenticationFailure\n";
public function testBridgeNewRoot()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 3:4:17:32.35
@@ -125,8 +123,7 @@ SNMPv2-MIB::snmpTrapOID.0 BRIDGE-MIB::newRoot";
public function testBridgeTopologyChanged()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 3:4:17:32.35
@@ -143,8 +140,7 @@ SNMPv2-MIB::snmpTrapOID.0 BRIDGE-MIB::topologyChange";
public function testColdStart()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:1:12.7
@@ -161,8 +157,7 @@ SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::coldStart";
public function testWarmStart()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:2:12.7
@@ -179,8 +174,7 @@ SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::warmStart";
public function testEntityDatabaseChanged()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 3:4:17:32.35

View File

@@ -26,7 +26,6 @@
namespace LibreNMS\Tests\Feature\SnmpTraps;
use App\Models\Device;
use App\Models\Ipv4Address;
use LibreNMS\Snmptrap\Dispatcher;
use LibreNMS\Snmptrap\Trap;
@@ -34,9 +33,7 @@ class CyberPowerTrapsTest extends SnmpTrapTestCase
{
public function testCpUpsOverload()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -55,9 +52,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsDiagFailed()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -76,9 +71,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsDischarged()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -97,9 +90,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsOnBattery()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -118,9 +109,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpLowBattery()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -139,9 +128,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpPowerRestored()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -160,9 +147,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsDiagPassed()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -181,9 +166,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpRtnLowBattery()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -202,9 +185,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsTurnedOff()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -223,9 +204,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsSleeping()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -244,9 +223,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsWokeUp()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -265,9 +242,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsRebootStarted()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -286,9 +261,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsOverTemp()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -307,9 +280,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpRtnOverTemp()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -328,9 +299,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpRtOverLoad()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -349,9 +318,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpRtnDischarged()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -370,9 +337,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsChargerFailure()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -391,9 +356,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpRtnChargerFailure()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
@@ -412,9 +375,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
public function testCpUpsBatteryNotPresent()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:161->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00

View File

@@ -33,8 +33,7 @@ class FgTrapAvOversizeTest extends SnmpTrapTestCase
{
public function testAvOversize()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81

View File

@@ -34,9 +34,8 @@ class FgTrapIpsTest extends SnmpTrapTestCase
{
public function testIpsAnomaly()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81
@@ -56,8 +55,7 @@ FORTINET-FORTIGATE-MIB::fgIpsTrapSigMsg.0 tcp_src_session";
public function testIpsPkgUdate()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81
@@ -74,9 +72,8 @@ SNMPv2-MIB::sysName.0 $device->hostname";
public function testIpsSignature()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81

View File

@@ -33,9 +33,8 @@ class FgTrapVpnTunTest extends SnmpTrapTestCase
{
public function testVpnTunDown()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81
@@ -55,9 +54,8 @@ FORTINET-FORTIGATE-MIB::fgVpnTrapPhase1Name.0 test_tunnel_down";
public function testVpnTunUp()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81

View File

@@ -33,8 +33,7 @@ class FmTrapLogRateThresholdTest extends SnmpTrapTestCase
{
public function testAvOversize()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 302:12:56:24.81

View File

@@ -35,8 +35,7 @@ class JnxBgpM2Test extends SnmpTrapTestCase
{
public function testBgpPeerUnknown()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -62,8 +61,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
public function testBgpBackwardTrasition()
{
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerIdentifier' => '2001:d88:1::2', 'bgpPeerState' => 'established']);
$device = Device::factory()->create(); /** @var Device $device */
$bgppeer = BgpPeer::factory()->make(['bgpPeerIdentifier' => '2001:d88:1::2', 'bgpPeerState' => 'established']); /** @var BgpPeer $bgppeer */
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname
@@ -91,8 +90,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
public function testBgpEstablished()
{
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerIdentifier' => '2001:d88:1::2', 'bgpPeerState' => 'idle']);
$device = Device::factory()->create(); /** @var Device $device */
$bgppeer = BgpPeer::factory()->make(['bgpPeerIdentifier' => '2001:d88:1::2', 'bgpPeerState' => 'idle']); /** @var BgpPeer $bgppeer */
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname

View File

@@ -34,8 +34,7 @@ class JnxCmCfgChangeTest extends SnmpTrapTestCase
{
public function testConfigChangeTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -55,8 +54,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameEX22
public function testConfigRollbackTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91

View File

@@ -35,9 +35,8 @@ class JnxDomAlarmTest extends SnmpTrapTestCase
{
public function testJnxDomAlarmSetTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(); /** @var Port $port */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -57,9 +56,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX48
public function testJnxDomAlarmClearTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(); /** @var Port $port */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91

View File

@@ -35,8 +35,8 @@ class JnxDomLaneAlarmTest extends SnmpTrapTestCase
{
public function testJnxDomLaneAlarmSetTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname
@@ -61,8 +61,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX96
public function testJnxDomLaneAlarmClearedTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname

View File

@@ -35,9 +35,8 @@ class JnxLdpLspTest extends SnmpTrapTestCase
{
public function testLdpLspDownTrap()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
@@ -58,9 +57,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX48
public function testLdpLspUpTrap()
{
$device = Device::factory()->create();
$ipv4 = Ipv4Address::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$trapText = "$device->hostname
UDP: [$device->ip]:64610->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91

View File

@@ -35,8 +35,8 @@ class JnxLdpSesTest extends SnmpTrapTestCase
{
public function testJnxLdpSesDownTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname
@@ -59,8 +59,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX48
public function testJnxLdpSesUpTrap()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname

View File

@@ -34,8 +34,7 @@ class JnxPowerSupplyTest extends SnmpTrapTestCase
{
public function testJnxPowerSupplyFailureTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:49716->[10.0.0.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 470:23:25:41.21
@@ -57,8 +56,7 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX96
public function testJnxPowerSupplyOkTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:49716->[10.0.0.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 470:23:25:41.21

View File

@@ -36,8 +36,8 @@ class JnxVpnIfTest extends SnmpTrapTestCase
{
public function testVpnIfDown()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname
@@ -58,8 +58,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX96
public function testVpnIfUp()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname

View File

@@ -36,8 +36,8 @@ class JnxVpnPwTest extends SnmpTrapTestCase
{
public function testVpnPwDown()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname
@@ -58,8 +58,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX48
public function testVpnPwUp()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "$device->hostname

View File

@@ -37,7 +37,7 @@ class MgmtTrapNmsAlarmTest extends SnmpTrapTestCase
{
public function testAlarmClear()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
@@ -74,7 +74,7 @@ EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogChassisId $device->ip";
//Test alarm with addtional text supplied.
public function testAlarmAddText()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
@@ -112,7 +112,7 @@ EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogChassisId $device->ip";
//Alarm is on a specific port
public function testAlarmPort()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];

View File

@@ -37,7 +37,7 @@ class MgmtTrapNmsEventTest extends SnmpTrapTestCase
{
public function testEvent()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
@@ -73,7 +73,7 @@ EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogChassisId $device->ip";
//Test alarm with addtional text supplied.
public function testEventAddText()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
@@ -110,7 +110,7 @@ EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogChassisId $device->ip";
//Event trap on a specific port
public function testEventPort()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];

View File

@@ -30,8 +30,7 @@ class NetgearFailedUserLoginTest extends SnmpTrapTestCase
{
public function testManagedSeries()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:44298->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:6:11:31.55
@@ -46,8 +45,7 @@ SNMPv2-MIB::snmpTrapOID.0 NETGEAR-SWITCHING-MIB::failedUserLoginTrap";
public function testSmartSeries()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:1026->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 30:22:57:58.00

View File

@@ -39,12 +39,11 @@ class OspfIfStateChangeTest extends SnmpTrapTestCase
//Test OSPF interface state down
public function testOspfIfDown()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -72,12 +71,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state DesignatedRouter
public function testOspfIfDr()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -105,12 +103,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state backupDesignatedRouter
public function testOspfIfBdr()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -138,12 +135,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state otherDesignatedRouter
public function testOspfIfOdr()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -171,12 +167,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state pointToPoint
public function testOspfIfPtp()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'down']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -204,12 +199,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state waiting
public function testOspfIfWait()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname
@@ -237,12 +231,11 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF interface state loopback
public function testOspfIfLoop()
{
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']);
$ospfIf = OspfPort::factory()->make(['port_id' => $port->port_id, 'ospfIfState' => 'designatedRouter']); /** @var OspfPort $ospfIf */
$device->ospfPorts()->save($ospfIf);
$trapText = "$device->hostname

View File

@@ -38,9 +38,8 @@ class OspfNbrStateChangeTest extends SnmpTrapTestCase
//Test OSPF neighbor state down trap
public function testOspfNbrDown()
{
$device = Device::factory()->create();
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'full']);
$device = Device::factory()->create(); /** @var Device $device */
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'full']); /** @var OspfNbr $ospfNbr */
$ospfNbr->ospf_nbr_id = "$ospfNbr->ospfNbrIpAddr.$ospfNbr->ospfNbrAddressLessIndex";
$device->ospfNbrs()->save($ospfNbr);
@@ -70,9 +69,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF neighbor state full trap
public function testOspfNbrFull()
{
$device = Device::factory()->create();
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'down']);
$device = Device::factory()->create(); /** @var Device $device */
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'down']); /** @var OspfNbr $ospfNbr */
$ospfNbr->ospf_nbr_id = "$ospfNbr->ospfNbrIpAddr.$ospfNbr->ospfNbrAddressLessIndex";
$device->ospfNbrs()->save($ospfNbr);
@@ -102,9 +100,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX2
//Test OSPF neighbor state trap any other state
public function testOspfNbrOther()
{
$device = Device::factory()->create();
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'full']);
$device = Device::factory()->create(); /** @var Device $device */
$ospfNbr = OspfNbr::factory()->make(['device_id' => $device->device_id, 'ospfNbrState' => 'full']); /** @var OspfNbr $ospfNbr */
$ospfNbr->ospf_nbr_id = "$ospfNbr->ospfNbrIpAddr.$ospfNbr->ospfNbrAddressLessIndex";
$device->ospfNbrs()->save($ospfNbr);

View File

@@ -35,8 +35,8 @@ class PortsTrapTest extends SnmpTrapTestCase
public function testLinkDown()
{
// make a device and associate a port with it
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "<UNKNOWN>
@@ -65,8 +65,8 @@ OLD-CISCO-INTERFACES-MIB::locIfReason.$port->ifIndex \"down\"\n";
public function testLinkUp()
{
// make a device and associate a port with it
$device = Device::factory()->create();
$port = Port::factory()->make(['ifAdminStatus' => 'down', 'ifOperStatus' => 'down']);
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(['ifAdminStatus' => 'down', 'ifOperStatus' => 'down']); /** @var Port $port */
$device->ports()->save($port);
$trapText = "<UNKNOWN>

View File

@@ -34,8 +34,7 @@ class RuckusEventTest extends SnmpTrapTestCase
{
public function testRuckusAssocTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -52,8 +51,7 @@ RUCKUS-EVENT-MIB::ruckusEventClientMacAddr \"de:ad:be:ef:11:221.0.5.1.1.1.2.2\""
public function testRuckusDiassocTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -70,8 +68,7 @@ RUCKUS-EVENT-MIB::ruckusEventClientMacAddr \"de:ad:be:ef:33:441.0.5.1.1.1.2.2\""
public function testRuckusSetErrorTrap()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -34,8 +34,7 @@ class RuckusSzClusterStateTest extends SnmpTrapTestCase
{
public function testClusterInMaintenance()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -55,8 +54,7 @@ RUCKUS-SZ-EVENT-MIB::ruckusSZClusterName.0 \"$device->hostname\"";
public function testClusterInService()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -34,8 +34,7 @@ class RuckusSzEventTest extends SnmpTrapTestCase
{
public function testSzApConf()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -60,8 +59,7 @@ RUCKUS-SZ-EVENT-MIB::ruckusSZAPConfigID.0 \"2f860f70-6b88-11e9-a3c5-000000937916
public function testSzApConnect()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -86,8 +84,7 @@ RUCKUS-SZ-EVENT-MIB::ruckusSZEventReason.0 \"AP connected after rebooting\"";
public function testSzApMiscEvent()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24
@@ -112,8 +109,7 @@ RUCKUS-SZ-EVENT-MIB::ruckusSZEventDescription.0 \"Test AP event has occured\"";
public function testSzApRebooted()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:57602->[192.168.5.5]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 26:19:43:37.24

View File

@@ -33,8 +33,7 @@ class TrippliteTrapTest extends SnmpTrapTestCase
{
public function testTlpNotificationsAlarmEntryAdded()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:46024->[1.1.1.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:1:55:34.92
@@ -62,8 +61,7 @@ TRIPPLITE-PRODUCTS::tlpAgentUuid.0 c94e376a-8080-44fb-96ad-0fe6583d1c4a";
public function testTlpNotificationsAlarmEntryRemoved()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$trapText = "$device->hostname
UDP: [$device->ip]:46024->[1.1.1.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 0:1:56:40.26

View File

@@ -32,10 +32,10 @@ class UpsTrapsOnBatteryTest extends SnmpTrapTestCase
{
public function testOnBattery()
{
$device = Device::factory()->create();
$state = Sensor::factory()->make(['sensor_class' => 'state', 'sensor_type' => 'upsOutputSourceState', 'sensor_current' => '2']);
$time = Sensor::factory()->make(['sensor_class' => 'runtime', 'sensor_index' => '100', 'sensor_type' => 'rfc1628', 'sensor_current' => '0']);
$remaining = Sensor::factory()->make(['sensor_class' => 'runtime', 'sensor_index' => '200', 'sensor_type' => 'rfc1628', 'sensor_current' => '371']);
$device = Device::factory()->create(); /** @var Device $device */
$state = Sensor::factory()->make(['sensor_class' => 'state', 'sensor_type' => 'upsOutputSourceState', 'sensor_current' => '2']); /** @var Sensor $state */
$time = Sensor::factory()->make(['sensor_class' => 'runtime', 'sensor_index' => '100', 'sensor_type' => 'rfc1628', 'sensor_current' => '0']); /** @var Sensor $time */
$remaining = Sensor::factory()->make(['sensor_class' => 'runtime', 'sensor_index' => '200', 'sensor_type' => 'rfc1628', 'sensor_current' => '371']); /** @var Sensor $remaining */
$device->sensors()->save($state);
$device->sensors()->save($time);
$device->sensors()->save($remaining);

View File

@@ -34,9 +34,8 @@ class VmwHBTest extends SnmpTrapTestCase
{
public function testVmwVmHBLostTrap()
{
$device = Device::factory()->create();
$guest = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$guest = Device::factory()->create(); /** @var Device $guest */
$trapText = "$device->hostname
UDP: [$device->ip]:28386->[10.10.10.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 5:18:30:26.00
@@ -56,9 +55,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 VMWARE-PRODUCTS-MIB::vmwESX";
public function testVmwVmHBDetectedTrap()
{
$device = Device::factory()->create();
$guest = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$guest = Device::factory()->create(); /** @var Device $guest */
$trapText = "$device->hostname
UDP: [$device->ip]:28386->[10.10.10.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 5:18:30:26.00

View File

@@ -35,9 +35,8 @@ class VmwPowerStateTest extends SnmpTrapTestCase
{
public function testVmwVmPoweredOffTrap()
{
$device = Device::factory()->create();
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]);
$device = Device::factory()->create(); /** @var Device $device */
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]); /** @var Vminfo $guest */
$trapText = "$device->hostname
UDP: [$device->ip]:28386->[10.10.10.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 5:18:30:26.00
@@ -57,9 +56,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 VMWARE-PRODUCTS-MIB::vmwESX";
public function testVmwVmPoweredONTrap()
{
$device = Device::factory()->create();
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]);
$device = Device::factory()->create(); /** @var Device $device */
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]); /** @var Vminfo $guest */
$trapText = "$device->hostname
UDP: [$device->ip]:28386->[10.10.10.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 5:18:30:26.00
@@ -79,9 +77,8 @@ SNMPv2-MIB::snmpTrapEnterprise.0 VMWARE-PRODUCTS-MIB::vmwESX";
public function testVmwVmSuspendedTrap()
{
$device = Device::factory()->create();
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]);
$device = Device::factory()->create(); /** @var Device $device */
$guest = Vminfo::factory()->create(['device_id' => $device->device_id]); /** @var Vminfo $guest */
$trapText = "$device->hostname
UDP: [$device->ip]:28386->[10.10.10.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 5:18:30:26.00

View File

@@ -16,7 +16,7 @@ class TestScheduledMaintenance extends DBTestCase
{
$now = CarbonImmutable::now();
$schedule = AlertSchedule::factory()->make();
$schedule = AlertSchedule::factory()->make(); /** @var AlertSchedule $schedule */
$schedule->start = $now->subHour();
$schedule->end = $now->addHour();
$schedule->save();

View File

@@ -332,7 +332,7 @@ class SmokepingCliTest extends DBTestCase
// Generate a ridiculous number of random devices for testing
foreach (range(1, 1000) as $i) {
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$data[$device->type][] = $device->hostname;
}

View File

@@ -37,8 +37,7 @@ class ComponentTest extends DBTestCase
public function testDeleteComponent()
{
$target = \App\Models\Component::factory()->create();
$target = \App\Models\Component::factory()->create(); /** @var \App\Models\Component $target */
$this->assertTrue(\App\Models\Component::where('id', $target->id)->exists(), 'Failed to create component, this shouldn\'t happen');
$component = new Component();
@@ -54,7 +53,7 @@ class ComponentTest extends DBTestCase
public function testGetComponentsOptionsType()
{
$target = \App\Models\Component::factory()->create();
$target = \App\Models\Component::factory()->create(); /** @var \App\Models\Component $target */
$component = new Component();
$actual = $component->getComponents($target->device_id, ['type' => $target->type]);
@@ -67,7 +66,7 @@ class ComponentTest extends DBTestCase
public function testGetComponentsOptionsFilterNotIgnore()
{
\App\Models\Component::factory()->create(['device_id' => 1, 'ignore' => 1]);
$target = \App\Models\Component::factory()->times(2)->create(['device_id' => 1, 'ignore' => 0]);
$target = \App\Models\Component::factory()->times(2)->create(['device_id' => 1, 'ignore' => 0]); /** @var \Illuminate\Support\Collection $target */
$component = new Component();
$actual = $component->getComponents(1, ['filter' => ['ignore' => ['=', 0]]]);
@@ -79,7 +78,7 @@ class ComponentTest extends DBTestCase
{
\App\Models\Component::factory()->create(['label' => 'Search Phrase']);
\App\Models\Component::factory()->times(2)->create(['label' => 'Something Else']);
$target = \App\Models\Component::factory()->times(2)->create(['label' => 'Search Phrase']);
$target = \App\Models\Component::factory()->times(2)->create(['label' => 'Search Phrase']); /** @var \Illuminate\Support\Collection $target */
\App\Models\Component::factory()->create(['label' => 'Search Phrase']);
$component = new Component();
@@ -119,7 +118,7 @@ class ComponentTest extends DBTestCase
public function testSetComponentPrefs()
{
// Nightmare function, no where near exhaustive
$base = \App\Models\Component::factory()->create();
$base = \App\Models\Component::factory()->create(); /** @var \App\Models\Component $base */
$component = new Component();
\Log::shouldReceive('event')->withArgs(["Component: $base->type($base->id). Attribute: null_val, was added with value: ", $base->device_id, 'component', 3, $base->id]);
@@ -182,7 +181,7 @@ class ComponentTest extends DBTestCase
$this->assertEquals(0, $component->createStatusLogEntry(434242, 0, 'failed'), 'incorrectly added log');
$message = Str::random(8);
$model = \App\Models\Component::factory()->create();
$model = \App\Models\Component::factory()->create(); /** @var \App\Models\Component $model */
$log_id = $component->createStatusLogEntry($model->id, 1, $message);
$this->assertNotEquals(0, $log_id, ' failed to create log');

View File

@@ -36,8 +36,7 @@ class DeviceTest extends DBTestCase
public function testFindByHostname()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$found = Device::findByHostname($device->hostname);
$this->assertNotNull($found);
$this->assertEquals($device->device_id, $found->device_id, 'Did not find the correct device');
@@ -63,7 +62,7 @@ class DeviceTest extends DBTestCase
public function testFindIpButNoPort()
{
$ipv4 = Ipv4Address::factory()->create();
$ipv4 = Ipv4Address::factory()->create(); /** @var Ipv4Address $ipv4 */
Port::destroy($ipv4->port_id);
$found = Device::findByIp($ipv4->ipv4_address);
@@ -72,8 +71,7 @@ class DeviceTest extends DBTestCase
public function testFindByIp()
{
$device = Device::factory()->create();
$device = Device::factory()->create(); /** @var Device $device */
$found = Device::findByIp($device->ip);
$this->assertNotNull($found);
$this->assertEquals($device->device_id, $found->device_id, 'Did not find the correct device');
@@ -82,8 +80,7 @@ class DeviceTest extends DBTestCase
public function testFindByIpHostname()
{
$ip = '192.168.234.32';
$device = Device::factory()->create(['hostname' => $ip]);
$device = Device::factory()->create(['hostname' => $ip]); /** @var Device $device */
$found = Device::findByIp($ip);
$this->assertNotNull($found);
$this->assertEquals($device->device_id, $found->device_id, 'Did not find the correct device');
@@ -91,10 +88,11 @@ class DeviceTest extends DBTestCase
public function testFindByIpThroughPort()
{
$device = Device::factory()->create();
$port = Port::factory()->make();
$device = Device::factory()->create(); /** @var Device $device */
$port = Port::factory()->make(); /** @var Port $port */
$device->ports()->save($port);
$ipv4 = Ipv4Address::factory()->make(); // test ipv4 lookup of device
// test ipv4 lookup of device
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
$port->ipv4()->save($ipv4);
$found = Device::findByIp($ipv4->ipv4_address);

View File

@@ -51,8 +51,7 @@ class LocationTest extends TestCase
public function testCanNotSetLocation()
{
$device = Device::factory()->make(); /** @var Device $device */
$location = Location::factory()->make();
$location = Location::factory()->make(); /** @var Location $location */
$device->override_sysLocation = true;
$device->setLocation($location->location);
$this->assertNull($device->location);
@@ -64,7 +63,7 @@ class LocationTest extends TestCase
$device = Device::factory()->make(); /** @var Device $device */
// valid coords
$location = Location::factory()->withCoordinates()->make();
$location = Location::factory()->withCoordinates()->make(); /** @var Location $location */
$device->setLocation("$location->location [$location->lat,$location->lng]", true);
$this->assertEquals("$location->location [$location->lat,$location->lng]", $device->location->location);
$this->assertEquals($location->location, $device->location->display());
@@ -72,7 +71,7 @@ class LocationTest extends TestCase
$this->assertEquals($location->lng, $device->location->lng);
// with space
$location = Location::factory()->withCoordinates()->make();
$location = Location::factory()->withCoordinates()->make(); /** @var Location $location */
$device->setLocation("$location->location [$location->lat, $location->lng]", true);
$this->assertEquals("$location->location [$location->lat, $location->lng]", $device->location->location);
$this->assertEquals($location->location, $device->location->display());
@@ -81,7 +80,7 @@ class LocationTest extends TestCase
$this->assertEquals($location->lng, $device->location->lng);
// invalid coords
$location = Location::factory()->withCoordinates()->make(['lat' => 251.5007138]);
$location = Location::factory()->withCoordinates()->make(['lat' => 251.5007138]); /** @var Location $location */
$name = "$location->location [$location->lat,$location->lng]";
$device->setLocation($name, true);
$this->assertEquals($name, $device->location->location);
@@ -95,8 +94,7 @@ class LocationTest extends TestCase
{
Config::set('geoloc.dns', false);
$device = Device::factory()->make(); /** @var Device $device */
$location = Location::factory()->withCoordinates()->make();
$location = Location::factory()->withCoordinates()->make(); /** @var Location $location */
$device->setLocation($location);
$this->assertEquals($location->location, $device->location->location);
$this->assertEquals($location->location, $device->location->display());
@@ -108,9 +106,8 @@ class LocationTest extends TestCase
public function testCanNotSetFixedCoordinates()
{
$device = Device::factory()->make(); /** @var Device $device */
$locationOne = Location::factory()->withCoordinates()->make();
$locationTwo = Location::factory(['location' => $locationOne->location])->withCoordinates()->make();
$locationOne = Location::factory()->withCoordinates()->make(); /** @var Location $locationOne */
$locationTwo = Location::factory(['location' => $locationOne->location])->withCoordinates()->make(); /** @var Location $locationTwo */
$device->setLocation($locationOne);
$this->assertEquals($locationOne->lat, $device->location->lat);
$this->assertEquals($locationOne->lng, $device->location->lng);
@@ -140,8 +137,7 @@ class LocationTest extends TestCase
{
Config::set('geoloc.dns', true);
$device = Device::factory()->make(); /** @var Device $device */
$location = Location::factory()->withCoordinates()->make();
$location = Location::factory()->withCoordinates()->make(); /** @var Location $location */
$this->mock(Dns::class, function (MockInterface $mock) use ($location) {
$mock->shouldReceive('getCoordinates')->once()->andReturn($location->only(['lat', 'lng']));
});
@@ -161,8 +157,7 @@ class LocationTest extends TestCase
public function testCanSetByApi()
{
$device = Device::factory()->make(); /** @var Device $device */
$location = Location::factory()->withCoordinates()->make();
$location = Location::factory()->withCoordinates()->make(); /** @var Location $location */
$this->mock(Geocoder::class, function (MockInterface $mock) use ($location) {
$mock->shouldReceive('getCoordinates')->once()->andReturn($location->only(['lat', 'lng']));
});
@@ -188,11 +183,10 @@ class LocationTest extends TestCase
public function testCorrectPrecedence()
{
$device = Device::factory()->make(); /** @var Device $device */
$location_encoded = Location::factory()->withCoordinates()->make();
$location_fixed = Location::factory()->withCoordinates()->make();
$location_api = Location::factory()->withCoordinates()->make();
$location_dns = Location::factory()->withCoordinates()->make();
$location_encoded = Location::factory()->withCoordinates()->make(); /** @var Location $location_encoded */
$location_fixed = Location::factory()->withCoordinates()->make(); /** @var Location $location_fixed */
$location_api = Location::factory()->withCoordinates()->make(); /** @var Location $location_api */
$location_dns = Location::factory()->withCoordinates()->make(); /** @var Location $location_dns */
Config::set('geoloc.dns', true);
$this->mock(Dns::class, function (MockInterface $mock) use ($location_dns) {
$mock->shouldReceive('getCoordinates')->times(3)->andReturn(

View File

@@ -63,8 +63,8 @@ class PermissionsTest extends TestCase
return self::devicePermissionData($user);
});
$device = Device::factory()->make(['device_id' => 54]);
$user = User::factory()->make(['user_id' => 43]);
$device = Device::factory()->make(['device_id' => 54]); /** @var Device $device */
$user = User::factory()->make(['user_id' => 43]); /** @var User $user */
$this->assertTrue($perms->canAccessDevice($device, 43));
$this->assertTrue($perms->canAccessDevice($device, $user));
$this->assertTrue($perms->canAccessDevice(54, $user));
@@ -88,7 +88,7 @@ class PermissionsTest extends TestCase
});
$this->assertEquals(collect([54, 32]), $perms->devicesForUser(43));
$user = User::factory()->make(['user_id' => 43]);
$user = User::factory()->make(['user_id' => 43]); /** @var User $user */
$this->assertEquals(collect([54, 32]), $perms->devicesForUser($user));
$this->assertEmpty($perms->devicesForUser(9));
$this->assertEquals(collect(), $perms->devicesForUser());
@@ -122,8 +122,8 @@ class PermissionsTest extends TestCase
(object) ['user_id' => 14, 'port_id' => 54],
]));
$port = Port::factory()->make(['port_id' => 54]);
$user = User::factory()->make(['user_id' => 43]);
$port = Port::factory()->make(['port_id' => 54]); /** @var Port $port */
$user = User::factory()->make(['user_id' => 43]); /** @var User $user */
$this->assertTrue($perms->canAccessPort($port, 43));
$this->assertTrue($perms->canAccessPort($port, $user));
$this->assertTrue($perms->canAccessPort(54, $user));
@@ -149,7 +149,7 @@ class PermissionsTest extends TestCase
]));
$this->assertEquals(collect([7, 2]), $perms->portsForUser(3));
$user = User::factory()->make(['user_id' => 3]);
$user = User::factory()->make(['user_id' => 3]); /** @var User $user */
$this->assertEquals(collect([7, 2]), $perms->portsForUser($user));
$this->assertEmpty($perms->portsForUser(9));
$this->assertEquals(collect(), $perms->portsForUser());
@@ -167,8 +167,9 @@ class PermissionsTest extends TestCase
(object) ['user_id' => 6, 'port_id' => 5],
]));
$port = Port::factory()->make(['port_id' => 7]); /** @var Port $port */
$this->assertEquals(collect([4, 6]), $perms->usersForPort(5));
$this->assertEquals(collect([3]), $perms->usersForPort(Port::factory()->make(['port_id' => 7])));
$this->assertEquals(collect([3]), $perms->usersForPort($port));
$this->assertEquals(collect(), $perms->usersForPort(6));
$this->assertEmpty($perms->usersForPort(9));
}
@@ -182,8 +183,8 @@ class PermissionsTest extends TestCase
(object) ['user_id' => 14, 'bill_id' => 54],
]));
$bill = Bill::factory()->make(['bill_id' => 54]);
$user = User::factory()->make(['user_id' => 43]);
$bill = Bill::factory()->make(['bill_id' => 54]); /** @var Bill $bill */
$user = User::factory()->make(['user_id' => 43]); /** @var User $user */
$this->assertTrue($perms->canAccessBill($bill, 43));
$this->assertTrue($perms->canAccessBill($bill, $user));
$this->assertTrue($perms->canAccessBill(54, $user));
@@ -209,7 +210,7 @@ class PermissionsTest extends TestCase
]));
$this->assertEquals(collect([7, 2]), $perms->billsForUser(3));
$user = User::factory()->make(['user_id' => 3]);
$user = User::factory()->make(['user_id' => 3]); /** @var User $user */
$this->assertEquals(collect([7, 2]), $perms->billsForUser($user));
$this->assertEmpty($perms->billsForUser(9));
$this->assertEquals(collect(), $perms->billsForUser());
@@ -228,7 +229,8 @@ class PermissionsTest extends TestCase
]));
$this->assertEquals(collect([4, 6]), $perms->usersForBill(5));
$this->assertEquals(collect([3]), $perms->usersForBill(Bill::factory()->make(['bill_id' => 7])));
$bill = Bill::factory()->make(['bill_id' => 7]); /** @var Bill $bill */
$this->assertEquals(collect([3]), $perms->usersForBill($bill));
$this->assertEquals(collect(), $perms->usersForBill(6));
$this->assertEmpty($perms->usersForBill(9));
}