#!/bin/sh
# danectl - DNSSEC DANE implementation manager
# https://raf.org/danectl
# https://github.com/raforg/danectl
# https://codeberg.org/raforg/danectl
#
# Copyright (C) 2021-2023 raf <raf@raf.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# 20230412 raf <raf@raf.org>

# Test 1 replaces old "manual" records with new ones
# Test 2 appends new records only (no old records)
# Test 3 replaces old automatic records (from test 2) with new ones

ex=0

for t in 1 2 3
do
	cp tests/zonefile.orig$t tests/zonefile.tmp
	cat tests/zonefile.in | ./danectl-zonefile tests/zonefile.tmp
	diff -du tests/zonefile.new$t tests/zonefile.tmp
	rc=$?
	[ $rc = 0 ] && result=pass || result=fail
	echo Test danectl-zonefile $result $t
	rm tests/zonefile.tmp tests/zonefile.tmp.bak
	ex="`expr $ex + $rc`"
done

exit $ex
