From 5f423906de8adee3fbe928f4a997e0f8dd57d51a Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Thu, 17 Aug 2023 15:43:14 +0200 Subject: [PATCH] - Fix ip_ratelimit test to work with dig that enables DNS cookies. --- doc/Changelog | 1 + testdata/ip_ratelimit.tdir/ip_ratelimit.test | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 285341417..15625c23c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -10,6 +10,7 @@ `queries_cookie_invalid` information. The `ip\-ratelimit\-cookie:` value determines a rate limit for queries with cookies, if desired. - Fix regional_alloc_init for potential unaligned source of the copy. + - Fix ip_ratelimit test to work with dig that enables DNS cookies. 2 August 2023: George - Move a cache reply callback in worker.c closer to the cache reply diff --git a/testdata/ip_ratelimit.tdir/ip_ratelimit.test b/testdata/ip_ratelimit.tdir/ip_ratelimit.test index 7af7d108c..f58b7edcb 100644 --- a/testdata/ip_ratelimit.tdir/ip_ratelimit.test +++ b/testdata/ip_ratelimit.tdir/ip_ratelimit.test @@ -15,8 +15,14 @@ get_make total_runs=6 success_threshold=4 # 2/3*total_runs +if dig -h 2>&1 | grep "cookie" >/dev/null; then + nocookie="+nocookie" +else + nocookie="" +fi + echo "> First get a valid cookie" -dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:0102030405060708 +tcp +retry=0 +time=1 test. TXT >outfile 2>&1 +dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:0102030405060708 $nocookie +tcp +retry=0 +time=1 test. TXT >outfile 2>&1 if test "$?" -ne 0; then echo "exit status not OK" echo "> cat logfiles" @@ -56,7 +62,7 @@ for i in $(seq 1 $total_runs); do exit 1 fi # Expect no answer because of limit - dig @127.0.0.1 -p $UNBOUND_PORT +retry=0 +time=1 test. TXT >outfile 2>&1 + dig @127.0.0.1 -p $UNBOUND_PORT $nocookie +retry=0 +time=1 test. TXT >outfile 2>&1 if test "$?" -eq 0; then continue fi @@ -71,7 +77,7 @@ for i in $(seq 1 $total_runs); do exit 1 fi # Expect answer because of DNS cookie - dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:$cookie +retry=0 +time=1 test. TXT >outfile 2>&1 + dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:$cookie $nocookie +retry=0 +time=1 test. TXT >outfile 2>&1 if test "$?" -ne 0; then continue fi @@ -118,7 +124,7 @@ for i in $(seq 1 $total_runs); do exit 1 fi # Expect no answer because of limit - dig @127.0.0.1 -p $UNBOUND_PORT +retry=0 +time=1 test. TXT >outfile 2>&1 + dig @127.0.0.1 -p $UNBOUND_PORT $nocookie +retry=0 +time=1 test. TXT >outfile 2>&1 if test "$?" -eq 0; then continue fi @@ -133,7 +139,7 @@ for i in $(seq 1 $total_runs); do exit 1 fi # Expect no answer because of ip-ratelimit-cookie - dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:$cookie +retry=0 +time=1 test. TXT >outfile 2>&1 + dig @127.0.0.1 -p $UNBOUND_PORT +ednsopt=10:$cookie $nocookie +retry=0 +time=1 test. TXT >outfile 2>&1 if test "$?" -eq 0; then continue fi