1#!/usr/bin/perl -sw
2#
3# $Id: host.t 775 2009-05-27 08:09:42Z calle $
4
5require 5.008;
6use warnings;
7use strict;
8
9use Test::More tests => 10;
10
11use DNSCheck;
12
13######################################################################
14
15my $ht;
16
17eval { $ht = new DNSCheck({ configfile => './config.yaml' })->host; };
18
19ok(!$@, "Have an object $@");
20
21SKIP: {
22    skip "Failed to get an object to test", 4 unless defined($ht);
23    ok($ht->host_syntax('foo.bar.com') == 0,    'Good name');
24    ok($ht->host_syntax('xxx.' x 64) > 0,       'Name too long overall');
25    ok($ht->host_syntax('x' x 64 . '.com') > 0, 'Label too long');
26    ok($ht->host_syntax('foo.-bar.com') > 0, 'Label may not start with dash');
27    ok($ht->host_syntax('foo.bar-.com') > 0, 'Label may not end with dash');
28    ok($ht->host_syntax('foo.b------r.com') == 0, 'Label may contain dashes');
29    ok($ht->host_syntax('foo.bar.4711') > 0,
30        'Top-level may not be all-numeric');
31    ok($ht->host_syntax('a.bar.com') == 0, 'One-octet labels are allowed');
32    ok($ht->host_syntax('foo..com') > 0,   'Label must not be empty');
33}
34