]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check display of EDE option
authorMark Andrews <marka@isc.org>
Mon, 11 May 2020 05:23:49 +0000 (15:23 +1000)
committerMark Andrews <marka@isc.org>
Wed, 13 May 2020 02:18:55 +0000 (12:18 +1000)
(cherry picked from commit e6b0153f8a3736bbc1aecd0237cde108d38c8a27)
(cherry picked from commit 88e11a9971fe88c9af23592f956a93b6090db2bb)

bin/tests/system/digdelv/tests.sh

index 69194cc931e18b443d4e2a5802f92e32e31acebd..3d1010e1b77d0eb49751e96c92ebff499ae4019c 100644 (file)
@@ -502,7 +502,8 @@ ret=0
   echo_i "checking ednsopt LLQ prints as expected ($n)"
   ret=0
   $DIG $DIGOPTS @10.53.0.3 +ednsopt=llq:0001000200001234567812345678fefefefe +qr a.example > dig.out.test$n 2>&1 || ret=1
-  grep 'LLQ: Version: 1, Opcode: 2, Error: 0, Identifier: 1311768465173141112, Lifetime: 4278124286$' dig.out.test$n > /dev/null || ret=1
+  pat='LLQ: Version: 1, Opcode: 2, Error: 0, Identifier: 1311768465173141112, Lifetime: 4278124286$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=`expr $status + $ret`
 
@@ -588,6 +589,51 @@ ret=0
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=`expr $status + $ret`
 
+  n=`expr $n + 1`
+  echo_i "check that Extended DNS Error 0 is printed correctly ($n)"
+  # First defined EDE code, additional text "foo".
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=ede:0000666f6f a.example +qr > dig.out.test$n 2>&1 || ret=1
+  pat='^; EDE: 0 (Other): (foo)$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo_i "check that Extended DNS Error 24 is printed correctly ($n)"
+  # Last defined EDE code, no additional text.
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=ede:0018 a.example +qr > dig.out.test$n 2>&1 || ret=1
+  pat='^; EDE: 24 (Invalid Data)$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo_i "check that Extended DNS Error 25 is printed correctly ($n)"
+  # First undefined EDE code, additional text "foo".
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=ede:0019666f6f a.example +qr > dig.out.test$n 2>&1 || ret=1
+  pat='^; EDE: 25: (foo)$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo_i "check that invalid Extended DNS Error (length 0) is printed ($n)"
+  # EDE payload is too short
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=ede a.example +qr > dig.out.test$n 2>&1 || ret=1
+  pat='^; EDE$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=`expr $status + $ret`
+
+  n=$((n+1))
+  echo_i "check that invalid Extended DNS Error (length 1) is printed ($n)"
+  # EDE payload is too short
+  $DIG $DIGOPTS @10.53.0.3 +ednsopt=ede:00 a.example +qr > dig.out.test$n 2>&1 || ret=1
+  pat='^; EDE: 00 (".")$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=`expr $status + $ret`
+
   n=`expr $n + 1`
   echo_i "check that dig handles malformed option '+ednsopt=:' gracefully ($n)"
   ret=0
@@ -600,7 +646,8 @@ ret=0
   echo_i "check that dig -q -m works ($n)"
   ret=0
   $DIG $DIGOPTS @10.53.0.3 -q -m > dig.out.test$n 2>&1
-  grep '^;-m\..*IN.*A$' dig.out.test$n > /dev/null || ret=1
+  pat='^;-m\..*IN.*A$'
+  tr -d '\r' < dig.out.test$n | grep "$pat" > /dev/null || ret=1
   grep "Dump of all outstanding memory allocations" dig.out.test$n > /dev/null && ret=1
   if [ $ret != 0 ]; then echo_i "failed"; fi
   status=`expr $status + $ret`