From b78084f1bab9d1b1bb2929145194cd6ea023cee7 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 16 Feb 2020 17:49:06 -0600 Subject: [PATCH] Fix invalid dnos test data (#11158) It encoded non-ascii data in the test string --- LibreNMS/Util/ModuleTestHelper.php | 4 ++-- tests/data/dnos_m.json | 21 +++++++++++++++++++-- tests/snmpsim/dnos_m.snmprec | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index 311c6841d3..ec3b5ae5b3 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -673,7 +673,7 @@ class ModuleTestHelper // only dump data for the given modules foreach ($modules as $module) { - foreach ($module_dump_info[$module] as $table => $info) { + foreach ($module_dump_info[$module] ?: [] as $table => $info) { // check for custom where $where = isset($info['custom_where']) ? $info['custom_where'] : "WHERE `$table`.`device_id`=?"; $params = [$device_id]; @@ -681,7 +681,7 @@ class ModuleTestHelper // build joins $join = ''; $select = ["`$table`.*"]; - foreach ($info['joins'] as $join_info) { + foreach ($info['joins'] ?: [] as $join_info) { if (isset($join_info['custom'])) { $join .= ' ' . $join_info['custom']; diff --git a/tests/data/dnos_m.json b/tests/data/dnos_m.json index 279da264d5..e47cb65683 100644 --- a/tests/data/dnos_m.json +++ b/tests/data/dnos_m.json @@ -23,7 +23,7 @@ { "sysName": "", "sysObjectID": ".1.3.6.1.4.1.6027.1.4.3", - "sysDescr": "Dell Networking OS.Operating System Version: 2.0.Application Software Version: 9.11(2.6).Series: PE-FN-2210S-IOM.Copyright (c) 1999-2017 by Dell Inc. All Rights Reserved..Build Time: Mon Nov 13 02:08:55 2017", + "sysDescr": "Dell Networking OS\nOperating System Version: 2.0\nApplication Software Version: 9.11(2.6)\nSeries: PE-FN-2210S-IOM\nCopyright (c) 1999-2017 by Dell Inc. All Rights Reserved.\nBuild Time: Mon Nov 13 02:08:55 2017", "sysContact": null, "version": null, "hardware": null, @@ -36,6 +36,23 @@ } ] }, - "poller": "matches discovery" + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.6027.1.4.3", + "sysDescr": "Dell Networking OS\nOperating System Version: 2.0\nApplication Software Version: 9.11(2.6)\nSeries: PE-FN-2210S-IOM\nCopyright (c) 1999-2017 by Dell Inc. All Rights Reserved.\nBuild Time: Mon Nov 13 02:08:55 2017", + "sysContact": null, + "version": "9.11(2.6)", + "hardware": "PE-FN-2210S-IOM", + "features": null, + "os": "dnos", + "type": "network", + "serial": null, + "icon": "dell.svg", + "location": null + } + ] + } } } diff --git a/tests/snmpsim/dnos_m.snmprec b/tests/snmpsim/dnos_m.snmprec index 2ca123bc85..edb058a99b 100644 --- a/tests/snmpsim/dnos_m.snmprec +++ b/tests/snmpsim/dnos_m.snmprec @@ -1,3 +1,3 @@ -1.3.6.1.2.1.1.1.0|4x|44656C6C204E6574776F726B696E67204F53DA4F7065726174696E672053797374656D2056657273696F6E3A20322E30DA4170706C69636174696F6E20536F6674776172652056657273696F6E3A20392E313128322E3629DA5365726965733A2050452D464E2D32323130532D494F4DDA436F707972696768742028632920313939392D323031372062792044656C6C20496E632E20416C6C205269676874732052657365727665642EDA4275696C642054696D653A204D6F6E204E6F762031332030323A30383A35352032303137 +1.3.6.1.2.1.1.1.0|4x|44656c6c204e6574776f726b696e67204f530a4f7065726174696e672053797374656d2056657273696f6e3a20322e300a4170706c69636174696f6e20536f6674776172652056657273696f6e3a20392e313128322e36290a5365726965733a2050452d464e2d32323130532d494f4d0a436f707972696768742028632920313939392d323031372062792044656c6c20496e632e20416c6c205269676874732052657365727665642e0a4275696c642054696d653a204d6f6e204e6f762031332030323a30383a35352032303137 1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.6027.1.4.3 1.3.6.1.4.1.6027.3.19.1.2.8.1.2.1|66|42