From d897d93998180e22bc92e8cf19063de4d29ef9aa Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 12 Aug 2021 11:21:26 +0100 Subject: [PATCH] add test for #767 --- xt/21-check_acl_no_ipaddr_only.t | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 xt/21-check_acl_no_ipaddr_only.t diff --git a/xt/21-check_acl_no_ipaddr_only.t b/xt/21-check_acl_no_ipaddr_only.t new file mode 100644 index 00000000..e0c95532 --- /dev/null +++ b/xt/21-check_acl_no_ipaddr_only.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +use strict; use warnings; + +BEGIN { $ENV{DANCER_ENVDIR} = '/dev/null'; } + +use Test::More 1.302083; +use Test::File::ShareDir::Dist { 'App-Netdisco' => 'share/' }; + +BEGIN { + use_ok( 'App::Netdisco::Util::DNS', 'hostname_from_ip' ); +} + +use Dancer qw/:script !pass/; + +config->{'dns'} = {no => ['::1','fe80::/10','127.0.0.0/8','169.254.0.0/16']}; +is(hostname_from_ip('127.0.0.1'), undef, '127.0.0.1 blocked'); + +config->{'dns'} = {no => ['::1','fe80::/10','169.254.0.0/16']}; +is(hostname_from_ip('127.0.0.1'), 'localhost', '127.0.0.1 allowed'); + +done_testing;