aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrexxnor <rexxnor+gnunet@brief.li>2018-11-13 14:22:01 +0100
committerrexxnor <rexxnor+gnunet@brief.li>2018-11-13 14:28:08 +0100
commitc84054626c6cc460bad4b6562ee89c221be308aa (patch)
tree26a517d45e587f8d1ea75b906d3ef363ff12dc41
parent9d1e77b9331acb9bd8b6c99aa942f62b9759e650 (diff)
downloadgnunet-c84054626c6cc460bad4b6562ee89c221be308aa.tar.gz
gnunet-c84054626c6cc460bad4b6562ee89c221be308aa.zip
added -R tests for multiple arguments
-rw-r--r--src/namestore/test_namestore_put_multiple.sh124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/namestore/test_namestore_put_multiple.sh b/src/namestore/test_namestore_put_multiple.sh
new file mode 100644
index 000000000..48ad95a3c
--- /dev/null
+++ b/src/namestore/test_namestore_put_multiple.sh
@@ -0,0 +1,124 @@
1#!/bin/bash
2
3# Check for required packages
4if ! [ -x "$(command -v gnunet-namestore)" ]; then
5 echo 'bind/named is not installed' >&2
6 exit 1
7fi
8
9# Check if gnunet is running
10gnunet-arm -I 2&>1 /dev/null
11ret=$?
12if [ 0 -ne $ret ]; then
13 echo 'gnunet services are not running'
14 exit 1
15fi
16
17## GNUNET part
18# Check if identity exists and delets and readds it to get rid of entries in zone
19gnunet-identity -d | grep randomtestingid 2>&1 /dev/null
20ret=$?
21
22if [ 0 -ne $ret ]; then
23 gnunet-identity -D randomtestingid
24 gnunet-identity -C randomtestingid
25fi
26
27function minimize_ttl {
28 ttl=10000000
29 arr=$1
30 # parse each element and update ttl to smallest one
31 for i in "${arr[@]}"
32 do
33 currttl=$(echo -n "$i" | cut -d' ' -f1)
34 if [ "$currttl" -lt "$ttl" ]
35 then
36 ttl=$currttl
37 fi
38
39 done
40 echo "$ttl"
41}
42
43function get_record_type {
44 arr=$1
45 typ=$(echo -n "${arr[0]}" | cut -d' ' -f2)
46 echo "$typ"
47}
48
49function get_value {
50 arr=$1
51 val=$(echo -n "${arr[0]}" | cut -d' ' -f4-)
52 echo "$val"
53}
54
55function testing {
56 label=$1
57 records=$2
58 recordstring=""
59 typ=$(get_record_type "${records[@]}")
60 for i in "${records[@]}"
61 do
62 recordstring+="-R $i"
63 done
64 #echo "$recordstring"
65 gnunet-namestore -z randomtestingid -n "$label" "$recordstring" 2>&1 /dev/null
66 if [ 0 -ne $ret ]; then
67 echo "failed to add record $label: $recordstring"
68 fi
69 gnunet-gns -t "$typ" -u foo2.randomtestingid 2>&1 /dev/null
70 if [ 0 -ne $ret ]; then
71 echo "record $label could not be found"
72 fi
73}
74
75# TEST CASES
76# 1
77echo "Testing adding of single A record with -R"
78declare -a arr=('1200 A n 127.0.0.1')
79testing test1 "${arr[@]}"
80# 2
81echo "Testing adding of multiple A records with -R"
82declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2')
83testing test2 "${arr[@]}"
84# 3
85echo "Testing adding of multiple different records with -R"
86declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::')
87testing test3 "${arr[@]}"
88# 4
89echo "Testing adding of single GNS2DNS record with -R"
90declare -a arr=('86400 GNS2DNS n gnu.org@127.0.0.1')
91testing test4 "${arr[@]}"
92# 5
93echo "Testing adding of single GNS2DNS shadow record with -R"
94declare -a arr=('86409 GNS2DNS s gnu.org@127.0.0.250')
95testing test5 "${arr[@]}"
96# 6
97echo "Testing adding of multiple GNS2DNS record with -R"
98declare -a arr=('1 GNS2DNS n gnunet.org@127.0.0.1' '3600 GNS2DNS s gnunet.org@127.0.0.2')
99testing test6 "${arr[@]}"
100val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
101if [[ $val == *"127.0.0.1"* ]]; then
102 echo "shadow!"
103fi
104echo "Sleeping to let record expire"
105sleep 5
106val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
107if [[ $val == *"127.0.0.2"* ]]; then
108 echo "no shadow!"
109fi
110# 7
111echo "Testing adding MX record with -R"
112declare -a arr=('3600 MX n 10,mail')
113testing test7 "${arr[@]}"
114# 8
115echo "Testing adding TXT record with -R"
116declare -a arr=('3600 TXT n Pretty_Unicorns')
117testing test8 "${arr[@]}"
118# 8
119echo "Testing adding TXT record with -R"
120declare -a arr=('3600 SRV n _autodiscover_old._tcp.bfh.ch.')
121testing test8 "${arr[@]}"
122
123# CLEANUP
124gnunet-identity -D randomtestingid