aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_put_multiple.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/namestore/test_namestore_put_multiple.sh')
-rw-r--r--src/namestore/test_namestore_put_multiple.sh123
1 files changed, 0 insertions, 123 deletions
diff --git a/src/namestore/test_namestore_put_multiple.sh b/src/namestore/test_namestore_put_multiple.sh
deleted file mode 100644
index f33fb1c3a..000000000
--- a/src/namestore/test_namestore_put_multiple.sh
+++ /dev/null
@@ -1,123 +0,0 @@
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 deletes 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"
78testing test1 "${arr[@]}"
79# 2
80echo "Testing adding of multiple A records with -R"
81declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2')
82testing test2 "${arr[@]}"
83# 3
84echo "Testing adding of multiple different records with -R"
85declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::')
86testing test3 "${arr[@]}"
87# 4
88echo "Testing adding of single GNS2DNS record with -R"
89declare -a arr=('86400 GNS2DNS n gnu.org@127.0.0.1')
90testing test4 "${arr[@]}"
91# 5
92echo "Testing adding of single GNS2DNS shadow record with -R"
93declare -a arr=('86409 GNS2DNS s gnu.org@127.0.0.250')
94testing test5 "${arr[@]}"
95# 6
96echo "Testing adding of multiple GNS2DNS record with -R"
97declare -a arr=('1 GNS2DNS n gnunet.org@127.0.0.1' '3600 GNS2DNS s gnunet.org@127.0.0.2')
98testing test6 "${arr[@]}"
99val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
100if [[ $val == *"127.0.0.1"* ]]; then
101 echo "shadow!"
102fi
103echo "Sleeping to let record expire"
104sleep 5
105val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
106if [[ $val == *"127.0.0.2"* ]]; then
107 echo "no shadow!"
108fi
109# 7
110echo "Testing adding MX record with -R"
111declare -a arr=('3600 MX n 10,mail')
112testing test7 "${arr[@]}"
113# 8
114echo "Testing adding TXT record with -R"
115declare -a arr=('3600 TXT n Pretty_Unicorns')
116testing test8 "${arr[@]}"
117# 8
118echo "Testing adding TXT record with -R"
119declare -a arr=('3600 SRV n _autodiscover_old._tcp.bfh.ch.')
120testing test8 "${arr[@]}"
121
122# CLEANUP
123gnunet-identity -D randomtestingid