2 # This file is in the public domain.
3 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
5 LOCATION=$(which gnunet-config)
8 LOCATION="gnunet-config"
10 $LOCATION --version 1> /dev/null
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
17 # permissive DNS resolver we will use for the test
18 DNS_RESOLVER="8.8.8.8"
19 if ! nslookup gnunet.org $DNS_RESOLVER > /dev/null 2>&1
21 echo "Cannot reach DNS, skipping test"
26 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
28 TEST_IP_PLUS="127.0.0.1"
29 TEST_IP_DNS="131.159.74.67"
30 TEST_RECORD_CNAME_SERVER="server"
31 TEST_RECORD_CNAME_PLUS="server.+"
32 TEST_RECORD_CNAME_DNS="gnunet.org"
33 TEST_RECORD_NAME_SERVER="server"
34 TEST_RECORD_NAME_PLUS="www"
35 TEST_RECORD_NAME_DNS="www3"
37 TEST_DOMAIN_PLUS="www.$MY_EGO"
38 TEST_DOMAIN_DNS="www3.$MY_EGO"
39 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
41 gnunet-arm -s -c test_gns_lookup.conf
42 gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
43 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf
44 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf
45 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
46 RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf`
47 RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf`
48 RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf`
49 TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'`
50 gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf
51 gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf
52 gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
53 gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
54 gnunet-arm -e -c test_gns_lookup.conf
55 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
57 # make cmp case-insensitive by converting to lower case first
58 RES_CNAME_RAW=`echo $RES_CNAME_RAW | tr [A-Z] [a-z]`
59 TESTEGOZONE=`echo $TESTEGOZONE | tr [A-Z] [a-z]`
60 if [ "$RES_CNAME_RAW" = "server.$TESTEGOZONE" ]
62 echo "PASS: CNAME resolution from GNS"
64 echo "FAIL: CNAME resolution from GNS, got $RES_CNAME_RAW, expected server.$TESTEGOZONE."
68 if [ "$RES_CNAME" = "$TEST_IP_PLUS" ]
70 echo "PASS: IP resolution from GNS"
72 echo "FAIL: IP resolution from GNS, got $RES_CNAME, expected $TEST_IP_PLUS."
76 if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ]
78 echo "PASS: IP resolution from DNS"
81 echo "FAIL: IP resolution from DNS, got $RES_IP, expected $TEST_IP_DNS."