diff options
| author | Jan Wagner <waja@cyconet.org> | 2017-01-04 13:29:00 +0100 |
|---|---|---|
| committer | Jan Wagner <waja@cyconet.org> | 2017-01-04 13:29:00 +0100 |
| commit | d9a1fb15dd60935cf1655e6b9786b28e899c8dc8 (patch) | |
| tree | 31a2708d65e6b03301f35a3ec5df3abe6d8b93a7 /plugins/t/check_dns.t | |
| parent | f524b15e572c4316feb70917d05f6349bef996ef (diff) | |
| parent | 6a0f4fe275bdf1c90de3d1b611293cf57cc3887b (diff) | |
| download | monitoring-plugins-d9a1fb15dd60935cf1655e6b9786b28e899c8dc8.tar.gz | |
Merge remote-tracking branch 'upstream/pr/1456'
Diffstat (limited to 'plugins/t/check_dns.t')
| -rw-r--r-- | plugins/t/check_dns.t | 26 |
1 files changed, 22 insertions, 4 deletions
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; | |||
| 10 | 10 | ||
| 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); | 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); |
| 12 | 12 | ||
| 13 | plan tests => 16; | 13 | plan tests => 19; |
| 14 | 14 | ||
| 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; |
| 16 | 16 | ||
| 17 | my $hostname_valid = getTestParameter( | 17 | my $hostname_valid = getTestParameter( |
| 18 | "NP_HOSTNAME_VALID", | 18 | "NP_HOSTNAME_VALID", |
| 19 | "A valid (known to DNS) hostname", | 19 | "A valid (known to DNS) hostname", |
| 20 | "monitoring-plugins.org" | 20 | "monitoring-plugins.org", |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | my $hostname_valid_ip = getTestParameter( | 23 | my $hostname_valid_ip = getTestParameter( |
| 24 | "NP_HOSTNAME_VALID_IP", | 24 | "NP_HOSTNAME_VALID_IP", |
| 25 | "The IP address of the valid hostname $hostname_valid", | 25 | "The IP address of the valid hostname $hostname_valid", |
| 26 | "66.118.156.50", | 26 | "130.133.8.40", |
| 27 | ); | ||
| 28 | |||
| 29 | my $hostname_valid_cidr = getTestParameter( | ||
| 30 | "NP_HOSTNAME_VALID_CIDR", | ||
| 31 | "An valid CIDR range containing $hostname_valid_ip", | ||
| 32 | "130.133.8.41/30", | ||
| 33 | ); | ||
| 34 | |||
| 35 | my $hostname_invalid_cidr = getTestParameter( | ||
| 36 | "NP_HOSTNAME_INVALID_CIDR", | ||
| 37 | "An (valid) CIDR range NOT containing $hostname_valid_ip", | ||
| 38 | "130.133.8.39/30", | ||
| 27 | ); | 39 | ); |
| 28 | 40 | ||
| 29 | my $hostname_valid_reverse = getTestParameter( | 41 | my $hostname_valid_reverse = getTestParameter( |
| 30 | "NP_HOSTNAME_VALID_REVERSE", | 42 | "NP_HOSTNAME_VALID_REVERSE", |
| 31 | "The hostname of $hostname_valid_ip", | 43 | "The hostname of $hostname_valid_ip", |
| 32 | "66-118-156-50.static.sagonet.net.", | 44 | "orwell.monitoring-plugins.org.", |
| 33 | ); | 45 | ); |
| 34 | 46 | ||
| 35 | my $hostname_invalid = getTestParameter( | 47 | my $hostname_invalid = getTestParameter( |
| @@ -87,3 +99,9 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev | |||
| 87 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); | 99 | cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); |
| 88 | like ( $res->output, $successOutput, "Output OK"); | 100 | like ( $res->output, $successOutput, "Output OK"); |
| 89 | 101 | ||
| 102 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5"); | ||
| 103 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | ||
| 104 | |||
| 105 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); | ||
| 106 | cmp_ok( $res->return_code, '==', 2, "Got wrong address"); | ||
| 107 | like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); | ||
