From: Björn Baumbach Date: Wed, 22 Feb 2023 14:22:58 +0000 (+0100) Subject: testprogs: fix some "net ads dns" tests X-Git-Tag: talloc-2.4.1~1501 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e62d580f45ed51b10af4d85ede8ec1bbaea0f72;p=thirdparty%2Fsamba.git testprogs: fix some "net ads dns" tests Use testit_grep_count instead of greping the output of testit. Running testit with "| grep" falsifies the test results. Signed-off-by: Björn Baumbach Reviewed-by: Andrew Bartlett --- diff --git a/testprogs/blackbox/test_net_ads_dns.sh b/testprogs/blackbox/test_net_ads_dns.sh index 072a4c5c311..27498808ade 100755 --- a/testprogs/blackbox/test_net_ads_dns.sh +++ b/testprogs/blackbox/test_net_ads_dns.sh @@ -53,13 +53,34 @@ echo "Starting ..." testit "admin user should be able to add a DNS entry $NAME.$REALM $IPADDRESS $IP6ADDRESS" $VALGRIND $net_tool ads dns register $NAME.$REALM $IPADDRESS $IP6ADDRESS -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1) -testit "We should be able to see the new name $NAME.$REALM $IPADDRESS" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS || failed=$(expr $failed + 1) -testit "We should be able to see the new name $NAME.$REALM $IP6ADDRESS" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS || failed=$(expr $failed + 1) +testit_grep_count \ + "We should be able to see the new name $NAME.$REALM $IPADDRESS" \ + "$IPADDRESS" \ + 1 \ + dig @$SERVER +short -t a $NAME.$REALM || + failed=$(expr $failed + 1) +testit_grep_count \ + "We should be able to see the new name $NAME.$REALM $IP6ADDRESS" \ + "$IP6ADDRESS" \ + 1 \ + dig @$SERVER +short -t aaaa $NAME.$REALM || + failed=$(expr $failed + 1) testit "We should be able to unregister the name $NAME.$REALM" $VALGRIND $net_tool ads dns unregister $NAME.$REALM -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1) -testit "The name $NAME.$REALM $IPADDRESS should not be there any longer" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS && failed=$(expr $failed + 1) -testit "The name $NAME.$REALM $IP6ADDRESS should not be there any longer" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS && failed=$(expr $failed + 1) +testit_grep_count \ + "The name $NAME.$REALM $IPADDRESS should not be there any longer" \ + "$IPADDRESS" \ + 0 \ + dig @$SERVER +short -t a $NAME.$REALM || + failed=$(expr $failed + 1) + +testit_grep_count \ + "The name $NAME.$REALM $IP6ADDRESS should not be there any longer" \ + "$IP6ADDRESS" \ + 0 \ + dig @$SERVER +short -t aaaa $NAME.$REALM || + failed=$(expr $failed + 1) # prime the kpasswd server, see "git blame" for an explanation $VALGRIND $net_tool user add $UNPRIVUSER $UNPRIVPASS -U$DC_USERNAME%$DC_PASSWORD @@ -83,14 +104,29 @@ testit "Unprivileged users should be able to add new names" $net_tool ads dns re # This should work as well testit "machine account should be able to add a DNS entry net ads dns register membername.$REALM $IPADDRMAC -P " $net_tool ads dns register membername.$REALM $IPADDRMAC -P || failed=$(expr $failed + 1) -testit "We should be able to see the new name membername.$REALM" dig @$SERVER +short -t a membername.$REALM | grep -q $IPADDRMAC || failed=$(expr $failed + 1) +testit_grep_count \ + "We should be able to see the new name membername.$REALM" \ + "$IPADDRMAC" \ + 1 \ + dig @$SERVER +short -t a membername.$REALM || + failed=$(expr $failed + 1) #Unprivileged users should not be able to overwrite other's names testit_expect_failure "Unprivileged users should not be able to modify existing names" $net_tool ads dns register membername.$REALM $UNPRIVIP -U$UNPRIVUSER%$UNPRIVPASS || failed=$(expr $failed + 1) testit "We should be able to unregister the name $NAME.$REALM $IPADDRESS" $VALGRIND $net_tool ads dns unregister $NAME.$REALM -P || failed=$(expr $failed + 1) -testit "The name $NAME.$REALM ($IPADDRESS) should not be there any longer" dig @$SERVER +short -t a $NAME.$REALM | grep -q $IPADDRESS && failed=$(expr $failed + 1) -testit "The name $NAME.$REALM ($IP6ADDRESS) should not be there any longer" dig @$SERVER +short -t aaaa $NAME.$REALM | grep -q $IP6ADDRESS && failed=$(expr $failed + 1) +testit_grep_count \ + "The name $NAME.$REALM ($IPADDRESS) should not be there any longer" \ + "$IPADDRESS" \ + 0 \ + dig @$SERVER +short -t a $NAME.$REALM || + failed=$(expr $failed + 1) +testit_grep_count \ + "The name $NAME.$REALM ($IP6ADDRESS) should not be there any longer" \ + "$IP6ADDRESS" \ + 0 \ + dig @$SERVER +short -t aaaa $NAME.$REALM || + failed=$(expr $failed + 1) exit $failed