diff options
Diffstat (limited to 'src/gns/test_plugin_rest_gns.sh')
-rwxr-xr-x | src/gns/test_plugin_rest_gns.sh | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/src/gns/test_plugin_rest_gns.sh b/src/gns/test_plugin_rest_gns.sh index ec495a04b..09f155e01 100755 --- a/src/gns/test_plugin_rest_gns.sh +++ b/src/gns/test_plugin_rest_gns.sh | |||
@@ -1,7 +1,20 @@ | |||
1 | #!/usr/bin/bash | 1 | #!/bin/sh |
2 | 2 | # This file is in the public domain. | |
3 | #First, start gnunet-arm and the rest-service. | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | #Exit 0 means success, exit 1 means failed test | 4 | |
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
5 | 18 | ||
6 | gns_link="http://localhost:7776/gns" | 19 | gns_link="http://localhost:7776/gns" |
7 | wrong_link="http://localhost:7776/gnsandmore" | 20 | wrong_link="http://localhost:7776/gnsandmore" |
@@ -9,42 +22,50 @@ wrong_link="http://localhost:7776/gnsandmore" | |||
9 | curl_get () { | 22 | curl_get () { |
10 | #$1 is link | 23 | #$1 is link |
11 | #$2 is grep | 24 | #$2 is grep |
12 | cache="$(curl -v "$1" 2>&1 | grep "$2")" | 25 | cache="$(gnurl -v "$1" 2>&1 | grep "$2")" |
13 | #echo $cache | 26 | echo "$cache" |
14 | if [ "" == "$cache" ] | 27 | if [ "" == "$cache" ] |
15 | then | 28 | then |
29 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 | ||
30 | gnunet-arm -e -c test_gns_lookup.conf | ||
16 | exit 1 | 31 | exit 1 |
17 | fi | 32 | fi |
18 | } | 33 | } |
34 | TEST_TLD="testtld" | ||
19 | 35 | ||
20 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | 36 | gnunet-arm -s -c test_gns_lookup.conf |
37 | gnunet-arm -I | ||
38 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 | ||
21 | 39 | ||
22 | curl_get "$gns_link/www.test_plugin_rest_gns" "error" | 40 | curl_get "$gns_link/www.$TEST_TLD" "error" |
23 | 41 | ||
24 | gnunet-identity -C "test_plugin_rest_gns" | 42 | gnunet-identity -C "$TEST_TLD" -c test_gns_lookup.conf |
43 | sleep 0.5 | ||
44 | curl_get "$gns_link/www.$TEST_TLD" "\[\]" | ||
25 | 45 | ||
26 | curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" | 46 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf |
27 | 47 | ||
28 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A | 48 | curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1" |
29 | 49 | ||
30 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" | 50 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c test_gns_lookup.conf |
31 | 51 | ||
32 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA | 52 | curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1" |
33 | 53 | ||
34 | curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" | 54 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c test_gns_lookup.conf |
35 | 55 | ||
36 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A | 56 | curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1" |
57 | curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1" | ||
58 | curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1" | ||
59 | curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" | ||
37 | 60 | ||
38 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" | 61 | gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf |
39 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" | 62 | curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1" |
40 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1" | ||
41 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" | ||
42 | 63 | ||
43 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A | 64 | gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf |
44 | curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" | 65 | gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf |
45 | 66 | ||
46 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | 67 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 |
47 | 68 | ||
48 | curl_get "$gns_link/www1.test_plugin_rest_gns" "error" | 69 | curl_get "$gns_link/www1.$TEST_TLD" "error" |
49 | 70 | ||
50 | exit 0 | 71 | exit 0 |