summaryrefslogtreecommitdiff
path: root/src/gns/test_plugin_rest_gns.sh
blob: da46330d67f13938c990aaecc79005f33cd95158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
# This file is in the public domain.
trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT

LOCATION=$(which gnunet-config)
if [ -z $LOCATION ]
then
  LOCATION="gnunet-config"
fi
$LOCATION --version 1> /dev/null
if test $? != 0
then
	echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
	exit 77
fi

rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`

gns_link="http://localhost:7776/gns"
wrong_link="http://localhost:7776/gnsandmore"

curl_get () {
    #$1 is link
    #$2 is grep
    cache="$(gnurl -v "$1" 2>&1 | grep "$2")"
    #echo "$cache"
    if [ "" == "$cache" ]
    then
        gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
        gnunet-arm -e -c test_gns_lookup.conf
        exit 1
    fi
}
TEST_TLD="testtld"

gnunet-arm -s -c test_gns_lookup.conf
curl_get "$gns_link/www.$TEST_TLD" "error"

gnunet-identity -C "$TEST_TLD"  -c test_gns_lookup.conf
sleep 0.5
curl_get "$gns_link/www.$TEST_TLD" "\[\]"

gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf

curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1"

gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c test_gns_lookup.conf

curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1"

gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c test_gns_lookup.conf

curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1"
curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1"
curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1"
curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"

gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf
curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1"

gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf
gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf

gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1

curl_get "$gns_link/www1.$TEST_TLD" "error"
gnunet-arm -e -c -c test_gns_lookup.conf
exit 0