Commit Graph

57 Commits

Author SHA1 Message Date
Jellyfrog
0a351b49fd
Laravel 9.x Shift (#14504)
* Move `resources/lang` folder

* Shift registered middleware

* Remove `fruitcake/laravel-cors` dependency

* Streamline `$commands` property

* Upgrade to Flysystem 3.0

* Shift core files

* Convert `optional()` to nullsafe operator

* Remove unnecessary `$model` property

* Convert route options to fluent methods

Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods.

* Convert deprecated `$dates` property to `$casts`

* Shift config files

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them and merged your true customizations -
where ENV variables may not be used.

* Bump Laravel dependencies

* Use `<env>` tags for configuration

`<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI.

Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/

* Fix error provider

* Match new symfony syntax

* Match upstream syntax

* Fix route syntax

* generate composer.lock

* Sync back configs

* routes

* composer

* Fix more flare

* fix cors

* sync lang

* Apply fixes from StyleCI (#14517)

Co-authored-by: StyleCI Bot <bot@styleci.io>

* bump larastan

* update packages

* wip

* Temporarily lower phpstan level

* Update phpstan.neon

* wip

* wip

* wip

* Apply fixes from StyleCI (#14592)

Co-authored-by: StyleCI Bot <bot@styleci.io>

* test

* Update CiHelper.php

* Update test.yml

* Update CiHelper.php

* Update CiHelper.php

* Apply fixes from StyleCI (#14616)

Co-authored-by: StyleCI Bot <bot@styleci.io>

* test?

* fix phpstan problems

* dont run snmpsim on github ci

* Fix whitespace

* More whitespace

* More whitespace ???

* I think the space broke it

* fix the reset of the whitespace

* hard code auth guard

---------

Co-authored-by: Shift <shift@laravelshift.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Tony Murray <murraytony@gmail.com>
2023-04-17 06:51:35 -05:00
Tony Murray
98da97c816
Test PHP 8.1 (#14109)
* Test PHP 8.1
Would love to remove the PHP7 versions, but we need to update our minimum version first.

* Try mariadb 10.8

* Reduce the number of open connections during testing.
2022-07-20 15:27:57 +02:00
Tony Murray
f94f7f23b8
Fully convert core to a modern module (#13347)
* Core module WIP

* update OS::make()

* core WIP

* try to finish up

* switch all core do os Model

* Mock WIP

* Working tests

* cleanup

* phpstan fixes

* style fixes

* fix agent

* trim space too
and a couple of cleanups

* corrected ios test data

* missed space

* update test data

* put escapes back

* another net-snmp difference

* Fix class description

* revert snmp.inc.php change, that can be a different PR

* revert snmp.inc.php change, that can be a different PR
2021-10-19 15:43:43 -05:00
Jellyfrog
258505ed44
Apply fixes from StyleCI (#13224) 2021-09-10 20:09:53 +02:00
Jellyfrog
edb36fd69d
More cleanups (#12715)
* PHPDoc

* Replace Auth > Illuminate\Support\Facades\Auth

* Return inside when()

* use str_replace correct

* Misc

* dead code

* use int $port

* styleci
2021-04-08 08:14:49 -05:00
Jellyfrog
f06e81b357
Switch to utf8mb4 (#12580)
* Switch to utf8mb4

This allows emojis to function correctly

* Update URLs
2021-03-28 16:23:08 +02:00
Tony Murray
f5a0959181
Revert "Switch to utf8mb4 (#12501)" (#12578)
This reverts commit 8e2e67d0ee.
2021-03-01 14:59:06 -06:00
Jellyfrog
8e2e67d0ee
Switch to utf8mb4 (#12501)
* Switch to utf8mb4

This allows emojis to function correctly

* Update URLs
2021-03-01 08:02:26 -06:00
Jellyfrog
20b4215204
Swich links to https (#12511)
* Switch librenms links to https

* Convert librenms links in comments

* Switch gnu.org url to https

* switch php urls to https
2021-02-09 00:29:04 +01:00
CrazyMax
4126dddf73
GitHub Actions dev:check ci (#12392)
* Refactor test for GitHub Actions

* Checkout pull request HEAD commit instead of merge commit

* Fetch changed files from API instead of git

* HEAD commit

* Origin

* Fix env

* force full unit checks on gh actions change

* Fix DB conn

* Update test.yml

* Also set port in PDO connection

* Exit with correct exit code

* Update CiHelper.php

* Update test.yml

* Update CiHelper.php

* Update Proc.php

* Cleanups

Remove extra unit test run on php 7.4
Add names that will hopefully show in github.
Remove redundant DB env variables.

* Fix

Shorter names
and DB_TEST env is required

* Change command for information purposes

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
Co-authored-by: Jellyfrog <Jellyfrog@users.noreply.github.com>
2021-01-03 00:54:01 -06:00
Jellyfrog
29f45ca352
Apply fixes from StyleCI (#12124) 2020-09-21 15:59:34 +02:00
Jellyfrog
0d56bbd946
Apply fixes from StyleCI (#12123) 2020-09-21 15:51:53 +02:00
Jellyfrog
77c531527c
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI

* Disable style check
2020-09-21 14:54:51 +02:00
Tony Murray
941037e44e
Convert OS discovery to new style (#12099)
* terra

* airos

* port cisco os polling
old wwan polling was broken and deprecated anyway

* enterasys

* Brother, a few changes

* AW Plus

* Fabos

* set expected test data

* 3com

* Adva FSP150

* advantech

* airos-af

* aix

* akcp

* allied

* allworx and missed mibs

* anyos

* fixup some zyxel shared stuffs
zywall graph polling

* aos

* apc

* apex

* apsoluteos

* fix copyrights

* arris

* arris

* aruba-instant

* ArubaOS

* Ascom

* asuswrt-merlin, ats

* audiocodes

* avocent

* avtech

* barracuda

* binox

* boss

* canonprinter

* cdata

* ceraos

* ciena-waveserver

* fix 3com

* fix airos

* fix brother yaml?

* fix aos more

* fix and improve apc

* fix arista test data

* yaml discovery (basic)

* cimc

* mib not used

* remove old discovery file

* ciscosat

* ciscosb fixes + improvements

* comware

* ctm

* cumulus

* cxr-ts

* cyberoam-utm

* cyberpower

* dahua-nvr

* dasan-nos

* datadomain

* dcn-software and fallback oids

* dd-wrt

* dell-laser

* d*

* e* and location

* forti, post processing, oid coalescing

* Freebsd array of sysDescr regex

* finish f*

* g*

* h*

* i* WIP

* i*

* Junos

* j*

* k*

* unix refactor previous to yaml more
inject $device

* fixes

* fixes

* l*

* m*

* n* ability to set other fields in regex
tnmsne polling to eloquent

* o*

* p*

* q* + bonus calix

* r*

* s* WIP

* s*

* t*

* u*

* v*
rework vrp to yaml (hybrid)

* w*

* x*

* z*

* a* easy no-data

* fixes

* style fixes

* missed ApexPlus

* fix signature

* Add missing location data

* rename getDevice functions

* add new cisco ftd data

* update docs

* revert sill snmp format

* fix snmp options

* update for new smartax test data

* rebase dsm

* fix voss
2020-09-18 15:12:07 +02:00
Tony Murray
5f0388f0e3 Remove DB credentials from config.php
Better validation when config.php does not exist

Update docs and quote password

only populate legacy vars in config_to_json
drop .travis.yml config copy
remove credentials from config.php.default

Check for existance of .env instead of config.php in python scripts

legacy credential cleanup

tiny cleanups

consistent env for artisan server and artisan dusk
2020-06-27 07:47:08 -05:00
PipoCanaja
ea2928babd
VRP FDB table correctly parsed on some CE switches (#11766)
* vrp FDB table corrected on CE switches

* sleep 5 in snmpsim to run tests.

* 6 seconds wait when snmpsim.fork is called from bootstrap

* rollback in Snmpsim Class

* Update bootstrap.php
2020-06-07 23:32:15 -05:00
Tony Murray
e7d954d7df
Fix dev:check fail-fast not returning error (#11672)
Fix dantherm definition
2020-05-23 14:43:41 -05:00
Tony Murray
5fc3fcb9e8
Make migrations work in SQLite (#11643)
* WIP Sqlite

Down methods don't work either, avoid them with refresh for now.

WIP persistent support

WIP db_schema

WIP db_schema 2

Update new migrations...

revert dump_db_schema changes for now, too much difference.

fix migrations on mysql

fix up some more items, this should be our target schema
lots of index renames and a two misc changes

index rename WIP

index rename WIP

another round

fix up new schema changes

try case insensitive fix

Trying tests WIP

fix down methods

DBSetupTest working (uses mysql)

Test sqlite migrations work

* Properly validate sqlite output

* revert glue changes, should be separate PR

* remove dusk workaround

* remove unused variables

* import

* sqlite capitalization

* Revert some refresh tests

* testing_mysql back to testing
2020-05-22 16:49:21 -05:00
Tony Murray
d5a52ca4eb
Fix various issues with loading os definitions (#11640)
* Ping only device doesn't display
if os was set to something, ping os wasn't loaded and we try to get overview graphs from it.

* Fix snmp_disable device page load error
When other os is set.

* Revamp os setting loading
the only safe way to access is Config::getOsSetting()

* Remove getOsSetting fallback behavior
Most instances don't use it and it can have unexpected results Config::getOsSetting('blah', 'group') == 'librenms'

* refactor and remove unneeded load_os/loadOs calls now since getOsSetting automatically loads it.

* restore unix overview graphs, they are different
small cleanups

* fix
2020-05-19 14:35:32 -05:00
Tony Murray
63442e8b4a
Refactor tests (#10625)
* Refactor tests
Boot Laravel for all tests.
Config use private static property for storage instead of global

* Backup/restore modules

* disable snmpsim log

* Fixing DBTestCase

* Fix macros loading to the wrong place

* trap and other tests should check if db is available

* don't include snmp.inc.php if mock.snmp.inc.php is already included...

* fix migration

* if we don't reset the db, run migrations at least.

* set vars for migrate too

* Fix style

* ignore issues with undefined indexes in legacy code
2019-10-13 13:40:38 +00:00
Tony Murray
f3ba8947f7
Use Config helper (#10339)
remove usage of global variable
2019-06-23 00:29:12 -05:00
Tony Murray
e18f4522d5
Update to Laravel 5.7 (PHP 7.3 support) (#9800)
* Move assets to 5.7 location

* Add 5.7 SVGs

* add cache data dir

* update QUEUE_DRIVER -> QUEUE_CONNECTION

* Update trusted proxy config

* update composer.json

* 5.5 command loading

* @php and @endphp can't be inline

* Laravel 5.6 logging, Nice!

* Update blade directives

* improved redirects

* remove unneeded service providers

* Improved debugbar loading

* no need to emulate renderable exceptions anymore

* merge updated 5.7 files (WIP)

* Enable CSRF

* database_path() call causes issue in init.php

* fix old testcase name

* generic phpunit 7 fixes

* add missed file_get_contents
Keep migrations table content

* fix duplicate key

* Drop old php versions from travis-ci

* remove hhvm

* fix code climate message

* remove use of deprecated function assertInternalType

* Disable CSRF, we'll enable it separately.
All forms need to be updated to work.

* Update document references
2019-02-12 17:45:04 -06:00
Paul Heinrichs
ebe2ecf524 Laravel migrations (#8868)
* Add migrations and seeds

* Fix spacing validation issues

* Fix linting

* Update tabs to spaces

* Update daily and install process

* Make build-base.php use the new migrations if empty or at dbschema 1000.
Seed 1000 into the database.
Temp fix for the route table index length (this table basically isn't used...)

* Fix typo in seed.
Hard code legacy schema checks to version 1000 (999 would have worked as is)

* Port association table no longer exists

* Make database validate again

* DB schema, remove as many DB::statement as possible

* update migrations
add librenms cli entry point (artisan)
update validate to check laravel migrations

* remove statements from users migration

* Fix up daily.sh and the 1000 migration

* Update migrations to current state
Take advantage of environment variables to set DB credentials.

* Fix style issues

* Update schema

* fix test db collation

* Fix migration table definition

* update db migrations

* Update migrations

* Update stats callback.  Just count the total migrations applied.

* Update 1000.sql.

* update migrations

* remove the graph type seeder, it is no longer needed

* update docs

* fix whitespace

* remove extra schema

* update tests

* fix sort

* add message

* dbSchema should actually be 1000

* add character set to db create

* Fix some artisan issues

* Update schema
2019-01-14 06:44:23 -06:00
Tony Murray
ef8d7adad0
Remove graph_types definitions from DB (#9618)
* Remove graph_types from DB.

This is silly since defining them in definitions.inc.php already does the same thing.
Adds missing ones in definitions.inc.php and rewrites others since I already wrote them before I realized they were duplicates.

* remove dead table

* Remove graph_types inserts from schema files.

* update db_schema.yaml
2019-01-08 13:46:45 -06:00
Tony Murray
32a7c50189
Use Laravel authentication (#8702)
* Use Laravel for authentication
Support legacy auth methods
Always create DB entry for users (segregate by auth method)

Port api auth to Laravel

restrict poller errors to devices the user has access to

Run checks on every page load.  But set a 5 minute (configurable) timer.
Only run some checks if the user is an admin

Move toastr down a few pixels so it isn't as annoying.

Fix menu not loaded on laravel pages when twofactor is enabled for the system, but disabled for the user.
Add two missing menu entries in the laravel menu

Rewrite 2FA code
Simplify some and verify code before applying

Get http-auth working
Handle legacy $_SESSION differently.  Allows Auth::once(), etc to work.

* Fix tests and mysqli extension check

* remove duplicate Toastr messages

* Fix new items

* Rename 266.sql to 267.sql
2018-09-11 07:51:35 -05:00
Neil Lathwood
62190a30d4
Fixed pre-commit (#9035) 2018-08-19 09:29:34 +01:00
Tony Murray
a2e33efba8 Use PDO for MySQL queries (#8935)
Gut dbFacile
mres() now does nothing... could have some vulnerable queries, but most are ok

TODO
- [x] IRC client broke
- [x] Install broke

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
2018-08-17 21:29:20 +01:00
TheGreatDoc
9940c884f5 Fixed snmptraps. (#8898)
* Fixed snmptraps.

* Fixed space

* Added bgp down/up and authentication failure

* Fixed typo

* Fixed some typos, arrays, astext and format_hostname

* Updated documentation

* Moved code to a function

* Some refactor

* Minor fixes

* Minor fixes 2

* More minor fixes

* Changes requested by Tony

* Minor fixes

* Moved include to snmptrap.php

* Refactor traps to use object oriented code.

Should trigger events too/instead, but we'll leave that.
Testing todo

* Add tests and fix things so they actually work
Not checking events yet.

* Fixed typo and severity level

* Update composer deps, I think the lock file wasn't right.
add json and mbstring extension deps while I'm at it.

* Fix several issues with phpunit fixtures
2018-08-11 16:37:44 -05:00
Tony Murray
8afafe7eb0 refactor: pre-commit.php updates (#8679)
Disable the log for unit tests to speed things up hopefully
2018-05-09 12:53:45 +01:00
Tony Murray
d841625f12 refactor: Refactor database and config init (#8527)
* Refactor database and config init
Connect to the database without loading full config
Load config completely so post-processing is always done consistently.
Erase existing $config when loading, fixes issues in case we load the config twice.
If the database is not connected, don't try to load database settings. (Fixes some db errors on install)
Attempt to remove $config access/modification before init.php
Remove usage of db_name, that might not match the connected database.
Centralize db config loading, so we consistently apply db_test database settings.
Many of these changes are influenced by Laravel port.

* Some safety so we don't assign strings to numeric port field
Smooth out phpunit bootstrap

* Fix a couple of scrutinizer warnings.
2018-04-11 16:15:13 +01:00
Tony Murray
cc377353f3 Snmpsim fail when it fails (#8392)
* Update snmpsim to fail better if it can't be started.
The main issue is the isRunning() check was done too soon after forking, the sh process was still running.

* increase default delay to 2s

* Pull this back, all we need is the sleep really.

* Remove removed exception
2018-04-05 22:49:58 +01:00
Tony Murray
fff66d3c00
Feature: Generic discovery and poller tests (#7873)
* Processor Tests!

* Capture data from live devices easily.

* fix up some stuff, remove powerconnect things as they seem to be just broken.

* formatting, fix missing assignment
add netonix processor data

* fix multi-line, always add sysDescr and sysObjectID
ios cpm test file

* revert composer change and fix whitespace issues

* add help text

* missed help text

* tighter debug output

* handle empty strings properly and mibs with numbers

* use keys for sorting as intended

* fix type with empty data

* oops :)

* whitespace fix

* try installing fping

* Fix TestCase collision + cleanup

* mark TestCase as abstract
don't run two instances of snmpsim

* better database dumps, improved capture

* style fixes

* fix quotes add a few more tables

* add --prefer-new, properly merge data

* Support separate discovery and poller data. But don't waste space if they aren't needed.

* refactor to use class
collects all code in one place for reusability

* reorganize

* Print out when not saving.

* Support for running multiple (or all) modules at once.

* tidy

* Change unit test to a generic name and test all modules we have data for.

* Add documentation and a few more tidies

* whitespace fixes

* Fix tests, add a couple more modules, more docs

* More docs updates

* Fix scrutinizer issues

* add bgp-peers
2017-12-20 08:36:49 -06:00
Tony Murray
3dba5cd39d newdevice: Support Avtech RoomAlert 32E/W and RoomAlert 11E (#7614)
* newdevice: support Avtech RoomAlert 32E/W
Move avtech discovery to yaml, took a bit of trickery

* More flexibility when checking pre-cached data
A little cleanup

* Add support for RoomAlert 32E/W external and wish temp sensors
Add RoomAlert 11E support (just temp sensors)
Updated ROOMALERT32E-MIB
2017-11-04 21:25:13 +00:00
Tony Murray
8a051aa295 fix: Fix a couple of OS cache invalidation issues (#7567)
* fix: fix a couple of OS cache invalidation issues
Fixes issues where we might be using outdated os definitions.

* use Config and fix style issue

* only pull in settings from config.php (otherwise will possibly contain populated os config)
2017-10-27 21:03:58 +01:00
Neil Lathwood
96b010a735 feature: Forced OS Cache rebuild for unit tests (#7163) 2017-08-16 13:58:10 -05:00
Tony Murray
f02b551145 feature: Improved install experience (#6915)
always check that the base sql has been imported.
async db building
After this merge, we could move install.php to the end of the install documentation.  Makes a more natural flow.
2017-07-01 21:28:29 +01:00
Tony Murray
4dbab407bb refactor: OS discovery tests are now dynamic (#6555)
* refactor: OS discovery tests are now dynamic
All that needs to be done now is supply snmprec files with the proper name. os.snmprec or os_description.snmprec
I also tweaked the loading of yaml files to speed up the tests substantially.
Verifies all os have at least one test and all snmprec files are tested.

* fix typo
2017-05-03 15:52:53 +01:00
Tony Murray
1b1907a09f Update database tests to prepare for more (#6500)
* Update database tests to prepare for more
Add test_db_name, test_db_user, test_db_pass to allow developers to have a dedicated testing database.
Extract DBTestCase to include common functionality for database based tests. Use transactions to isolate tests.
Enable STRICT_TRANS_TABLE, test for it's existence (only when we have a user that can set it)
Move the database cleanup to register_shutdown_function, this makes it happen every time at the end of tests.
If the was not empty, only truncate the tables (that aren't prepopulated) instead of drop the database.
Use our schema functions for schema tests.
Fix some missing array indexes so it doesn't clutter test output.

* Fix style
2017-04-26 07:56:00 -05:00
Tony Murray
06add77685 fix: Allow unit tests without a sql server (#6398)
* fix: Allow unit tests without a sql server

* Fix db connection in bootstrap.php
Mark tests as skipped
Make sure the sql queries in bootstrap.php have run
2017-04-13 11:05:14 +01:00
Tony Murray
b1483e3d2e feature: Unit test to validate the db schema (#6367)
* Unit test to validate the db schema
Changes build-schema.php to just write misc/db_schema.yaml

* Only build base if needed
Fix 178.sql

* Database is always created by init.php
add dbSchema test too, should guard against testing against an empty database

* feature: support non-standard unix socket (#5724)

* Add support for custom MySQL unix-socket

* NULL must be lowercase!

* Naive edit of html/install.php

* fixup

* Refactor dbConnect
Use it everywhere

* $config needs to be global
Don't need to set $database_link

* small cleanups

* Connect to the database for every test.

* travis fix for blank line
2017-04-07 15:07:44 +01:00
Tony Murray
b1a414e785 feature: support non-standard unix socket (#5724)
* Add support for custom MySQL unix-socket

* NULL must be lowercase!

* Naive edit of html/install.php

* fixup

* Refactor dbConnect
Use it everywhere

* $config needs to be global
Don't need to set $database_link

* small cleanups
2017-04-06 22:02:37 +01:00
Neil Lathwood
200b762478 feature: Added phpunit db setup tests (#5594) 2017-02-07 15:08:52 +00:00
Tony Murray
e20a242785 refactor: use Composer to manage php dependencies (#5216) 2017-01-01 09:37:15 +00:00
Neil Lathwood
f5a16be0e3 refactor: Move OS definitions into yaml files (#5189) 2016-12-23 17:53:19 +00:00
Tony Murray
db240cb4eb refactor: Collection and output of db and snmp stats (#5049) 2016-11-23 06:57:19 +00:00
Tony Murray
9a33464c52 refactor: Centralize includes and initialization (#4991) 2016-11-21 20:12:59 +00:00
Neil Lathwood
d9f4096821 Start of cleaning up mibs (#4806)
refactor: Start of cleaning up mibs
2016-11-09 18:23:27 -06:00
laf
8a142aa53f feature: Added the option to select alert rules from a collection 2016-10-29 10:56:59 +00:00
Tony Murray
edbb6ae0e3 refactor: Centralize MIB include directory specification (#4603)
* refactor: Centralize MIB include directory specification
The default is now:
```
$config['mib_dir'].'/mibdirname:'.$config['mib_dir']
```
This means we exclude OS mibs and only use ours  (we could prepend `+` if we want to include os mibs.
All snmp calls should only include the name of the subdirectory under the mibs directory.

* Remove d_echo from Proc
Fix snmpsim tests.
2016-09-28 14:19:28 +01:00
Tony Murray
1e67337d8e Restore error settings. 2016-09-23 15:44:17 -05:00