aboutsummaryrefslogtreecommitdiff
path: root/src/gns/test_plugin_rest_gns.sh
blob: ec495a04b82780553e7d25938c8a10556c6ce3f6 (plain) (blame)
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
#!/usr/bin/bash

#First, start gnunet-arm and the rest-service.
#Exit 0 means success, exit 1 means failed test

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

curl_get () {
    #$1 is link
    #$2 is grep
    cache="$(curl -v "$1" 2>&1 | grep "$2")"
    #echo $cache
    if [ "" == "$cache" ]
    then
        exit 1
    fi
}

gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1

curl_get "$gns_link/www.test_plugin_rest_gns" "error"

gnunet-identity -C "test_plugin_rest_gns"

curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]"

gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A

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

gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA

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

gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A

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

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

gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1

curl_get "$gns_link/www1.test_plugin_rest_gns" "error"

exit 0