From 46ec4c5ae30e9137e303a1f7187da16da6378eb4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2024 02:53:35 +0200 Subject: Adding debian version 2.7.6-2. Signed-off-by: Daniel Baumann --- debian/tests/authoritative-server | 193 ++++++++++++++++++++++++++++++++++++++ debian/tests/control | 5 + debian/tests/kdig | 11 +++ 3 files changed, 209 insertions(+) create mode 100755 debian/tests/authoritative-server create mode 100644 debian/tests/control create mode 100755 debian/tests/kdig (limited to 'debian/tests') diff --git a/debian/tests/authoritative-server b/debian/tests/authoritative-server new file mode 100755 index 0000000..a2ae9c5 --- /dev/null +++ b/debian/tests/authoritative-server @@ -0,0 +1,193 @@ +#!/bin/bash + +# Author: Daniel Kahn Gillmor +# 2018-11-02 +# License: GPLv3+ + +# error on exit +set -e +# for handling jobspecs: +set -m + +if [ -z "$AUTOPKGTEST_ARTIFACTS" ]; then + d="$(mktemp -d)" + remove="$d" +else + d="$AUTOPKGTEST_ARTIFACTS" +fi +ip="${TESTIP:-127.$(( $RANDOM % 256 )).$(( $RANDOM % 256 )).$(( $RANDOM % 256 ))}" +port="${PORT:-8123}" +knotd="${KNOTD:-/usr/sbin/knotd}" +kdig="${KDIG:-$(which kdig)}" +kzonecheck="${KZONECHECK:-$(which kzonecheck)}" +knotc="${KNOTC:-/usr/sbin/knotc}" +test_address="${TEST_ADDRESS:-192.0.2.199}" +get_kaspdb="${GET_KASPDB:-/usr/lib/knot/get_kaspdb}" +get_user="${GET_USER:-/usr/lib/knot/get_user}" +kasp_json2lmdb="${KASP_JSON2LMDB:-/usr/lib/knot/kasp_json2lmdb}" + +declare -a knot_args=(--socket "$d/knot.sock" --config="$d/knot.conf" --verbose) + +printf "%s + %s roundtrip tests\n------------\n workdir: %s\n IP addr: %s\n knot args: %s\n" "$knotd" "$kdig" "$d" "$ip" "${knot_args[*]}" + +section() { + printf "\n%s\n" "$1" + sed 's/./-/g' <<<"$1" +} + +cleanup () { + section "cleaning up" + find "$d" -ls + "${knotc}" "${knot_args[@]}" stop + wait %1 + tail -n +1 -v "$d"/*.err + if [ "$remove" ]; then + printf "\ncleaning up working directory %s\n" "$remove" + rm -rf "$remove" + fi +} +trap cleanup EXIT + +section "set up config file and zonefile" + +user=$(id -nu) +group=$(id -ng) +cat > "$d/knot.conf" < "$d/example.net.zone" <"$d/kasp-db/zone_example.net.json" < "$d/kasp-db/keys/bf033546160229f56a8c90ca6ed3b599060b0067.pem" < "$d/kasp-db/keys/ff81022ffd8e16256b3ac8e136f5f068fbe9b714.pem" < "$d/knotd.err" & + +# FIXME: this is an annoying poll -- would be better if we could be +# alerted when the daemon is done setting up the socket, but i don't +# want to "--daemonize" if i can avoid it because i want the shell to +# remain in direct supervision of all its processes +tried=0 +while [ $tried -lt 10 ] ; do + if "${knotc}" "${knot_args[@]}" status 2>&1; then + break; + fi + sleep 0.5 + tried=$(( $tried + 1 )) +done +if [ $tried -ge 10 ]; then + printf "failed to use %s\n" "${knotc}" >&2 + exit 1 +fi + + +section "querying knot" +"${kdig}" -p "${port}" @"${ip}" -t A test.example.net test2.example.net +answer="$("${kdig}" +short -p "${port}" @"${ip}" -t A test.example.net)" +if ! [ "$answer" = "$test_address" ]; then + printf "test.example.net mismatch!\nexpected: %s\n got: %s\n" "$test_address" "$answer" >&2 + exit 1 +fi +answer2="$("${kdig}" +short -p "${port}" @"${ip}" -t A test2.example.net)" +if ! [ "$answer2" = "" ]; then + printf "test2.example.net gave unexpected answer!\n got: %s\n" "$answer2" >&2 + exit 1 +fi + +section "modifying zone" +printf "test2 1D IN A $test_address\n" >>"$d/example.net.zone" +sed -i 's/^@ 1D IN SOA.*/@ 1D IN SOA a.ns hostmaster 2018110100 3h 15m 1w 1d/' "$d/example.net.zone" +"${knotc}" "${knot_args[@]}" reload + +section "querying again" +"${kdig}" -p "${port}" @"${ip}" -t A test.example.net test2.example.net +answer="$("${kdig}" +short -p "${port}" @"${ip}" -t A test.example.net)" +if ! [ "$answer" = "$test_address" ]; then + printf "test.example.net mismatch!\nexpected: %s\n got: %s\n" "$test_address" "$answer" >&2 + exit 1 +fi +answer2="$("${kdig}" +short -p "${port}" @"${ip}" -t A test2.example.net)" +if ! [ "$answer2" = "$test_address" ]; then + printf "test2.example.net mismatch!\nexpected: %s\n got: %s\n" "$test_address" "$answer2" >&2 + exit 1 +fi + +section "testing python transition helpers" +"${get_kaspdb}" "$d/knot.conf" +got_user="$(${get_user} "$d/knot.conf")" +if [ "$got_user" != "$user" ]; then + printf "user account mismatch!\nexpected: %s\n got: %s\n" "$user" "$got_user" >&2 + exit 1 +fi +"${kasp_json2lmdb}" --import "$d/kasp-db" + diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..c654e9b --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,5 @@ +Tests: kdig +Depends: knot-dnsutils, ca-certificates + +Tests: authoritative-server +Depends: knot, knot-dnsutils, findutils, python3-lmdb, python3-yaml diff --git a/debian/tests/kdig b/debian/tests/kdig new file mode 100755 index 0000000..a2f388e --- /dev/null +++ b/debian/tests/kdig @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +expected=93.184.216.34 +answer=$(kdig +short +tls-ca +tls-hostname=dns.cmrg.net @dns.cmrg.net example.org) + +if [ "$answer" != "$expected" ]; then + printf "expected: %s\ngot: %s\n" "$expected" "$answer" >&2 + kdig +tls-ca +tls-hostname=dns.cmrg.net @dns.cmrg.net example.org +fi -- cgit v1.2.3