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