[Nagiosplug-devel] Testcase for is_hostname (was something else)

Ton Voon ton.voon at altinity.com
Fri Oct 27 16:01:31 CEST 2006


On 27 Oct 2006, at 09:39, Andreas Ericsson wrote:

> Ton Voon wrote:
>> Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts/t
>> In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7073/t
>>
>> Added Files:
>> 	utils.t
>> Log Message:
>> Fixed regression where hostnames with hyphens were rejected  
>> (1581402 - Holger Weiss)
>>
>>
>> --- NEW FILE: utils.t ---
>> #!/usr/bin/perl -w -I ..
>> #
>> # utils.pm tests
>> #
>> # $Id: utils.t,v 1.1 2006/10/26 21:02:21 tonvoon Exp $
>> #
>>
>> #use strict;
>> use Test::More;
>> use NPTest;
>>
>> use lib "..";
>> use utils;
>>
>> my $hostname_checks = {
>> 	"www.altinity.com" => 1,
>> 	"www.888.com" => 1,
>> 	"888.com" => 1,
>> 	"host-hyphened.com" => 1,
>> 	"rubbish" => 1,
>> 	"-start.com" => 0,
>> 	"endsindot." => 0,
>
> This is a bit odd, really. There's nothing wrong with a hostname  
> ending
> in a dot. What *is* odd is a hostname ending in a dot that cannot be a
> fully qualified domainname. "www.google.gom." is actually the *real*
> address. "www.google.com" gets auto-translated to add the last dot if
> there is none, whereas "www.google." is not a real address. This is  
> not
> because it ends with a dot, but because it's missing the top-domain  
> and
> the ending dot forbids library functions to amend anything to it.
>
> I would suggest changing the test-hostname to "nonfqdn-but-ends-in- 
> dot."
> so as to not confuse future hackers.
>

This is exactly the kind of discussions I want to see from using  
testcases! Better we spot these edge cases here, rather than in  
someone's use of the code.

Andreas, I'm not sure what you would like to see. Is it:
   "nonfqdn-but-ends-in-dot." => 0
   "otherwise.something." => 1
?

I know "something" is not an official top-level domain, but I think  
it is beyond the remit of is_hostname to find that out.

Ton

http://www.altinity.com
T: +44 (0)870 787 9243
F: +44 (0)845 280 1725
Skype: tonvoon


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20061027/ed4f8a86/attachment.html>


More information about the Devel mailing list