summaryrefslogtreecommitdiff
path: root/src/rest-plugins/test_plugin_rest_gns.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest-plugins/test_plugin_rest_gns.sh')
-rwxr-xr-xsrc/rest-plugins/test_plugin_rest_gns.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/rest-plugins/test_plugin_rest_gns.sh b/src/rest-plugins/test_plugin_rest_gns.sh
new file mode 100755
index 000000000..ec495a04b
--- /dev/null
+++ b/src/rest-plugins/test_plugin_rest_gns.sh
@@ -0,0 +1,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