aboutsummaryrefslogtreecommitdiff
path: root/plugins/t
diff options
context:
space:
mode:
authorGravatar Jan Wagner <waja@cyconet.org> 2017-01-04 13:29:00 +0100
committerGravatar Jan Wagner <waja@cyconet.org> 2017-01-04 13:29:00 +0100
commitd9a1fb15dd60935cf1655e6b9786b28e899c8dc8 (patch)
tree31a2708d65e6b03301f35a3ec5df3abe6d8b93a7 /plugins/t
parentf524b15e572c4316feb70917d05f6349bef996ef (diff)
parent6a0f4fe275bdf1c90de3d1b611293cf57cc3887b (diff)
downloadmonitoring-plugins-d9a1fb15dd60935cf1655e6b9786b28e899c8dc8.tar.gz
Merge remote-tracking branch 'upstream/pr/1456'
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/NPTest.cache.travis4
-rw-r--r--plugins/t/check_dns.t26
2 files changed, 25 insertions, 5 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis
index bcec9855..38c0a6b2 100644
--- a/plugins/t/NPTest.cache.travis
+++ b/plugins/t/NPTest.cache.travis
@@ -4,8 +4,10 @@
'NP_DNS_SERVER' => '8.8.8.8',
'NP_GOOD_NTP_SERVICE' => '',
'NP_HOSTNAME_INVALID' => 'nosuchhost',
- 'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
+ 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org',
'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
+ 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30',
+ 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30',
'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
'NP_HOST_DHCP_RESPONSIVE' => '',
'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 035e7682..cdfbe60d 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,26 +10,38 @@ use NPTest;
plan skip_all => "check_dns not compiled" unless (-x "check_dns");
-plan tests => 16;
+plan tests => 19;
my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
my $hostname_valid = getTestParameter(
"NP_HOSTNAME_VALID",
"A valid (known to DNS) hostname",
- "monitoring-plugins.org"
+ "monitoring-plugins.org",
);
my $hostname_valid_ip = getTestParameter(
"NP_HOSTNAME_VALID_IP",
"The IP address of the valid hostname $hostname_valid",
- "66.118.156.50",
+ "130.133.8.40",
+ );
+
+my $hostname_valid_cidr = getTestParameter(
+ "NP_HOSTNAME_VALID_CIDR",
+ "An valid CIDR range containing $hostname_valid_ip",
+ "130.133.8.41/30",
+ );
+
+my $hostname_invalid_cidr = getTestParameter(
+ "NP_HOSTNAME_INVALID_CIDR",
+ "An (valid) CIDR range NOT containing $hostname_valid_ip",
+ "130.133.8.39/30",
);
my $hostname_valid_reverse = getTestParameter(
"NP_HOSTNAME_VALID_REVERSE",
"The hostname of $hostname_valid_ip",
- "66-118-156-50.static.sagonet.net.",
+ "orwell.monitoring-plugins.org.",
);
my $hostname_invalid = getTestParameter(
@@ -87,3 +99,9 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
like ( $res->output, $successOutput, "Output OK");
+$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5");
+cmp_ok( $res->return_code, '==', 0, "Got expected address");
+
+$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5");
+cmp_ok( $res->return_code, '==', 2, "Got wrong address");
+like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK");