#!/usr/bin/perl
#
# Copyright 2004-2013 SPARTA, Inc.  All rights reserved.  See the COPYING
# file distributed with this software for details
#
#
# This script performs a very simple test of the DNSSEC-Tools config module.
# It parses the config file, using parseconfig(), and prints the parsed
# keyword/value pairs to the screen.  A simple config file will be created
# in the current directory for testing.
#
# This is a simple test in that the results are displayed to the screen
# and the tester is left the responsibility of ensuring that all worked
# as expected.  Automatic testing would be great, and it may come RSN.
#

use strict;

use Net::DNS::SEC::Tools::conf;

# my $conf = "/usr/local/etc/dnssec/dnssec-tools.conf";
my $conf = "./dnssec-tools.conf";

create_conffile();

test_parseconfig();

exit 0;

############################################################################

sub test_parseconfig
{
	my %dnssec_conf;

	%dnssec_conf = parseconfig($conf);

	print "keywords\tvalues\n";
	print "--------\t------\n";
	foreach my $k (sort(keys(%dnssec_conf)))
	{
		print "<$k>	<$dnssec_conf{$k}>\n";
	}
}

############################################################################

sub create_conffile
{
	open(CNF,"> $conf");
	print CNF <<EOF;
#
# key management tools configuration
#

#
# Settings for dnssec-keygen.
#
algorithm	rsasha1
ksklength	1024
zsklength	512


#
# Settings for dnssec-signzone.
#
endtime		+259200		# RRSIGs good for three days.
EOF

	close(CNF);
}
