summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_snmp.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_snmp.t')
-rw-r--r--plugins/t/check_snmp.t11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index 6de5f29..c35d782 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11BEGIN { 11BEGIN {
12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; 12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
13 plan tests => 60; 13 plan tests => 61;
14} 14}
15 15
16my $res; 16my $res;
@@ -26,6 +26,7 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES
26 26
27my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", 27my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
28 "An invalid (not known to DNS) hostname" ); 28 "An invalid (not known to DNS) hostname" );
29my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user");
29 30
30$res = NPTest->testCmd( "./check_snmp -t 1" ); 31$res = NPTest->testCmd( "./check_snmp -t 1" );
31is( $res->return_code, 3, "No host name" ); 32is( $res->return_code, 3, "No host name" );
@@ -35,7 +36,7 @@ $res = NPTest->testCmd( "./check_snmp -H fakehostname" );
35is( $res->return_code, 3, "No OIDs specified" ); 36is( $res->return_code, 3, "No OIDs specified" );
36is( $res->output, "No OIDs specified" ); 37is( $res->output, "No OIDs specified" );
37 38
38$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 --seclevel=rubbish" ); 39$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" );
39is( $res->return_code, 3, "Invalid seclevel" ); 40is( $res->return_code, 3, "Invalid seclevel" );
40like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); 41like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
41 42
@@ -154,6 +155,12 @@ SKIP: {
154 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); 155 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
155} 156}
156 157
158SKIP: {
159 skip "no SNMP user defined", 1 if ( ! $user_snmp );
160 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
161 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
162}
163
157# These checks need a complete command line. An invalid community is used so 164# These checks need a complete command line. An invalid community is used so
158# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway 165# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
159SKIP: { 166SKIP: {