test_plugin_rest_gns.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. # This file is in the public domain.
  3. trap "gnunet-arm -e -c test_gns_lookup.conf" INT
  4. LOCATION=$(which gnunet-config)
  5. if [ -z $LOCATION ]
  6. then
  7. LOCATION="gnunet-config"
  8. fi
  9. $LOCATION --version 1> /dev/null
  10. if test $? != 0
  11. then
  12. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  13. exit 77
  14. fi
  15. rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
  16. gns_link="http://localhost:7776/gns"
  17. wrong_link="http://localhost:7776/gnsandmore"
  18. curl_get () {
  19. #$1 is link
  20. #$2 is grep
  21. XURL=`which gnurl || which curl`
  22. if [ "" = "$XURL" ]
  23. then
  24. echo "HTTP client (curl/gnurl) not found, exiting"
  25. exit 77
  26. fi
  27. sleep 0.5
  28. cache="$(${XURL} -v "$1" 2>&1 | grep "$2")"
  29. #echo "$cache"
  30. if [ "" = "$cache" ]
  31. then
  32. gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
  33. gnunet-arm -e -c test_gns_lookup.conf
  34. echo "Download of $1 using $XURL failed"
  35. exit 1
  36. fi
  37. }
  38. TEST_TLD="testtld"
  39. gnunet-arm -s -c test_gns_lookup.conf
  40. curl_get "$gns_link/www.$TEST_TLD" "error"
  41. gnunet-identity -C "$TEST_TLD" -c test_gns_lookup.conf
  42. sleep 0.5
  43. curl_get "$gns_link/www.$TEST_TLD" "\[\]"
  44. gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf
  45. curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1"
  46. gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c test_gns_lookup.conf
  47. curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1"
  48. gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c test_gns_lookup.conf
  49. curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1"
  50. curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1"
  51. curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1"
  52. curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"
  53. gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf
  54. curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1"
  55. gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf
  56. gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf
  57. gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
  58. curl_get "$gns_link/www1.$TEST_TLD" "error"
  59. gnunet-arm -e -c test_gns_lookup.conf
  60. exit 0