Selaa lähdekoodia

Merge branch 'maint' of github.com-sreinhardt:nagios-plugins/nagios-plugins into maint

Spenser Reinhardt 12 vuotta sitten
vanhempi
commit
e1605b522e
2 muutettua tiedostoa jossa 75 lisäystä ja 9 poistoa
  1. 45 2
      plugins/t/check_dns.t
  2. 30 7
      plugins/t/check_pop.t

+ 45 - 2
plugins/t/check_dns.t

@@ -10,7 +10,7 @@ use NPTest;
 
 
 plan skip_all => "check_dns not compiled" unless (-x "check_dns");
 plan skip_all => "check_dns not compiled" unless (-x "check_dns");
 
 
-plan tests => 13;
+plan tests => 19;
 
 
 my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
 my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
 
 
@@ -38,11 +38,31 @@ my $hostname_invalid = getTestParameter(
 			"nosuchhost.nagios-plugins.org",
 			"nosuchhost.nagios-plugins.org",
 			);
 			);
 
 
-my $dns_server       = getTestParameter(
+my $dns_server = getTestParameter(
 			"NP_DNS_SERVER",
 			"NP_DNS_SERVER",
 			"A non default (remote) DNS server",
 			"A non default (remote) DNS server",
 			);
 			);
 
 
+my $hostname_valid_aaaa = getTestParameter( 
+			"NP_HOSTNAME_VALID_AAAA", 
+			"A valid hostname for AAAA records"
+			);
+
+my $hostname_valid_mx = getTestParameter( 
+			"NP_HOSTNAME_VALID_MX", 
+			"A valid hostname for MX records",
+			"nagios-plugins.org",
+			);
+
+my $hostname_valid_srv = getTestParameter( 
+			"NP_HOSTNAME_VALID_SRV", 
+			"A valid hostname for SRV records"
+			); 
+
+my $hostname_valid_txt = getTestParameter( 
+			"NP_HOSTNAME_VALID_TXT", 
+			"A valid hostname for TXT records"
+			); 
 my $res;
 my $res;
 
 
 $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
 $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
@@ -76,3 +96,26 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
 cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
 cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
 like  ( $res->output, $successOutput, "Output OK");
 like  ( $res->output, $successOutput, "Output OK");
 
 
+SKIP: {
+        skip "No server specified for checking TXT records", 2 unless $hostname_valid_txt;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_txt -s $dns_server -q TXT");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_txt");
+	like  ( $res->output, $successOutput, "TXT Output OK" );
+}
+
+SKIP: {
+        skip "No server specified for checking SRV records", 2 unless $hostname_valid_srv;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_srv -s $dns_server -q SRV");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_srv");
+	like  ( $res->output, $successOutput, "SRV Output OK" );
+}
+
+SKIP: {
+        skip "No server specified for checking AAAA records", 2 unless $hostname_valid_aaaa;
+
+	$res = NPTest->testCmd("./check_dns -H $hostname_valid_aaaa -s $dns_server -q AAAA");
+	cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid_aaaa");
+	like  ( $res->output, $successOutput, "TXT Output OK" );
+}

+ 30 - 7
plugins/t/check_pop.t

@@ -8,7 +8,7 @@ use strict;
 use Test::More;
 use Test::More;
 use NPTest;
 use NPTest;
 
 
-plan tests => 5;
+plan tests => 11;
 
 
 my $host_tcp_smtp = getTestParameter( 
 my $host_tcp_smtp = getTestParameter( 
 			"NP_HOST_TCP_SMTP",
 			"NP_HOST_TCP_SMTP",
@@ -22,6 +22,12 @@ my $host_tcp_pop = getTestParameter(
 			$host_tcp_smtp
 			$host_tcp_smtp
 			);
 			);
 
 
+my $host_tcp_pop_ssl = getTestParameter(
+			"NP_HOST_TCP_POP_SSL",
+			"Enable SSL for the host providing a POP Service (a mail server)",
+			"disabled"
+			);
+
 my $host_nonresponsive = getTestParameter(
 my $host_nonresponsive = getTestParameter(
 			"NP_HOST_NONRESPONSIVE", 
 			"NP_HOST_NONRESPONSIVE", 
 			"The hostname of system not responsive to network requests",
 			"The hostname of system not responsive to network requests",
@@ -39,14 +45,31 @@ my %exceptions = ( 2 => "No POP Server present?" );
 my $t;
 my $t;
 my $res;
 my $res;
 
 
-$res = NPTest->testCmd( "./check_pop $host_tcp_pop" );
-cmp_ok( $res->return_code, '==', 0, "POP server ok");
+SKIP: {
+        skip "SSL Disabled", 6 unless ($host_tcp_pop_ssl ne "disabled");
+
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -S -p 995" );
+	cmp_ok( $res->return_code, '==', 0, "SSL POP server ok");
+
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 995 -w 9 -c 9 -t 10 -S -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "SSL POP server returned +OK");
+
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 995 -wt 9 -ct 9 -to 10 -S -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "SSL Old syntax");
+}
+
+SKIP: {
+        skip "SSL Enabled", 6 unless ($host_tcp_pop_ssl eq "disabled");
+	
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop" );
+	cmp_ok( $res->return_code, '==', 0, "POP server ok");
 
 
-$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'");
-cmp_ok( $res->return_code, '==', 0, "POP server returned +OK");
+	$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "POP server returned +OK");
 
 
-$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'");
-cmp_ok( $res->return_code, '==', 0, "Old syntax");
+	$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'");
+	cmp_ok( $res->return_code, '==', 0, "Old syntax");
+}
 
 
 $res = NPTest->testCmd( "./check_pop $host_nonresponsive" );
 $res = NPTest->testCmd( "./check_pop $host_nonresponsive" );
 cmp_ok( $res->return_code, '==', 2, "Non responsive host");
 cmp_ok( $res->return_code, '==', 2, "Non responsive host");