aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts/t
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2006-10-27 15:37:31 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2006-10-27 15:37:31 +0000
commit6c61b8c7bfeaedfca53832c16b00b81f85ca5186 (patch)
treef647c7ada073ed41ea560444ca456ae2e366a34e /plugins-scripts/t
parent299c6bab02f4a2068a7ba8bdfefc6c155f7d7364 (diff)
downloadmonitoring-plugins-6c61b8c7bfeaedfca53832c16b00b81f85ca5186.tar.gz
More edge testcases. Allow anything if ends with a . as long as correct
characters git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1531 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/t')
-rw-r--r--plugins-scripts/t/utils.t21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins-scripts/t/utils.t b/plugins-scripts/t/utils.t
index 469988c9..4df5606b 100644
--- a/plugins-scripts/t/utils.t
+++ b/plugins-scripts/t/utils.t
@@ -4,8 +4,10 @@
#
# $Id$
#
+# Run with perl t/utils.t
-#use strict;
+use warnings;
+use strict;
use Test::More;
use NPTest;
@@ -19,16 +21,29 @@ my $hostname_checks = {
"host-hyphened.com" => 1,
"rubbish" => 1,
"-start.com" => 0,
- "endsindot." => 0,
+ "nonfqdn-but-endsindot." => 1,
+ "fqdn.and.endsindot." => 1,
"lots.of.dots.dot.org" => 1,
+ "endingwithdoubledots.." => 0,
+ "toomany..dots" => 0,
+ ".start.with.dot" => 0,
"10.20.30.40" => 1,
"10.20.30.40.50" => 0,
"10.20.30" => 0,
+ "10.20.30.40." => 1, # This is considered a hostname because of trailing dot. It probably won't exist though...
+ "888." => 1, # This is because it could be a domain
+ "host.888." => 1,
+ "where.did.that.!.come.from." => 0,
+ "no.underscores_.com" => 0,
};
-plan tests => scalar keys %$hostname_checks;
+plan tests => ((scalar keys %$hostname_checks) + 4);
foreach my $h (sort keys %$hostname_checks) {
is (utils::is_hostname($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
}
+is(utils::is_hostname(), 0, "No parameter errors");
+is(utils::is_hostname(""), 0, "Empty string errors");
+is(utils::is_hostname(0), 0, "0 also errors");
+is(utils::is_hostname(1), 0, "1 also errors");