gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: fix rest; uncrustify


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: fix rest; uncrustify
Date: Fri, 11 Oct 2019 14:50:18 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 559daabee fix rest; uncrustify
559daabee is described below

commit 559daabee673134f03d76f16d25c1e0ef23b4fdc
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Fri Oct 11 14:48:02 2019 +0200

    fix rest; uncrustify
---
 src/gns/Makefile.am                      |  4 ++
 src/gns/test_gns_cname_lookup.sh         |  4 +-
 src/gns/test_gns_gns2dns_cname_lookup.sh |  2 +-
 src/gns/test_gns_lookup.conf             |  2 +-
 src/gns/test_plugin_rest_gns.sh          | 67 +++++++++++++++++++++-----------
 src/util/gnunet-service-resolver.c       | 10 +++--
 6 files changed, 59 insertions(+), 30 deletions(-)

diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 4a152a6df..6cc09c098 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -268,6 +268,10 @@ check_SCRIPTS += \
   test_proxy.sh
 endif
 endif
+if HAVE_JSON
+check_SCRIPTS += \
+  test_plugin_rest_gns.sh
+endif
 endif
 
 
diff --git a/src/gns/test_gns_cname_lookup.sh b/src/gns/test_gns_cname_lookup.sh
index d168e4acb..f71346127 100755
--- a/src/gns/test_gns_cname_lookup.sh
+++ b/src/gns/test_gns_cname_lookup.sh
@@ -45,7 +45,7 @@ gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS 
-t CNAME -V $TEST_RE
 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V 
$TEST_IP_PLUS -e never -c test_gns_lookup.conf
 RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c 
test_gns_lookup.conf`
 RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c 
test_gns_lookup.conf`
-RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c 
test_gns_lookup.conf`
+RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c 
test_gns_lookup.conf | grep $TEST_IP_DNS`
 echo NOW
 gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf
 echo WON
@@ -76,7 +76,7 @@ else
   exit 1
 fi
 
-if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ]
+if echo "$RES_CNAME_DNS" | grep "$TEST_IP_DNS" > /dev/null
 then
   echo "PASS: IP resolution from DNS"
   exit 0
diff --git a/src/gns/test_gns_gns2dns_cname_lookup.sh 
b/src/gns/test_gns_gns2dns_cname_lookup.sh
index 87d684515..71e48a2bd 100755
--- a/src/gns/test_gns_gns2dns_cname_lookup.sh
+++ b/src/gns/test_gns_gns2dns_cname_lookup.sh
@@ -85,7 +85,7 @@ else
   ret=1
 fi
 
-if [ "$RES_IP6" = "$TEST_IP6" ]
+if echo "$RES_IP6" | grep "$TEST_IP6" > /dev/null
 then
   echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6."
 else
diff --git a/src/gns/test_gns_lookup.conf b/src/gns/test_gns_lookup.conf
index 2b874f80d..130d190e7 100644
--- a/src/gns/test_gns_lookup.conf
+++ b/src/gns/test_gns_lookup.conf
@@ -1,7 +1,7 @@
 @INLINE@ test_gns_defaults.conf
 
 [namecache]
-DISABLE = YES
+DISABLE = NO
 
 [PATHS]
 GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/
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 @@
-#!/usr/bin/bash
-
-#First, start gnunet-arm and the rest-service.
-#Exit 0 means success, exit 1 means failed test
+#!/bin/sh
+# This file is in the public domain.
+trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
+
+LOCATION=$(which gnunet-config)
+if [ -z $LOCATION ]
+then
+  LOCATION="gnunet-config"
+fi
+$LOCATION --version 1> /dev/null
+if test $? != 0
+then
+       echo "GNUnet command line tools cannot be found, check environmental 
variables PATH and GNUNET_PREFIX"
+       exit 77
+fi
+
+rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
 
 gns_link="http://localhost:7776/gns";
 wrong_link="http://localhost:7776/gnsandmore";
@@ -9,42 +22,50 @@ wrong_link="http://localhost:7776/gnsandmore";
 curl_get () {
     #$1 is link
     #$2 is grep
-    cache="$(curl -v "$1" 2>&1 | grep "$2")"
-    #echo $cache
+    cache="$(gnurl -v "$1" 2>&1 | grep "$2")"
+    echo "$cache"
     if [ "" == "$cache" ]
     then
+        gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
+        gnunet-arm -e -c test_gns_lookup.conf
         exit 1
     fi
 }
+TEST_TLD="testtld"
 
-gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1
+gnunet-arm -s -c test_gns_lookup.conf
+gnunet-arm -I
+gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
 
-curl_get "$gns_link/www.test_plugin_rest_gns" "error"
+curl_get "$gns_link/www.$TEST_TLD" "error"
 
-gnunet-identity -C "test_plugin_rest_gns"
+gnunet-identity -C "$TEST_TLD"  -c test_gns_lookup.conf
+sleep 0.5
+curl_get "$gns_link/www.$TEST_TLD" "\[\]"
 
-curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]"
+gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c 
test_gns_lookup.conf
 
-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_TLD" "1.1.1.1"
 
-curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1"
+gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c 
test_gns_lookup.conf
 
-gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA
+curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1"
 
-curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1"
+gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c 
test_gns_lookup.conf
 
-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_TLD" "1.1.1.2.*1::1.*1.1.1.1"
+curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1"
+curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1"
+curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" 
"1.1.1.2.*1::1.*1.1.1.1"
 
-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_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c 
test_gns_lookup.conf
+curl_get "$gns_link/www1.$TEST_TLD" "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-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf
+gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf
 
-gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1
+gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
 
-curl_get "$gns_link/www1.test_plugin_rest_gns" "error"
+curl_get "$gns_link/www1.$TEST_TLD" "error"
 
 exit 0
diff --git a/src/util/gnunet-service-resolver.c 
b/src/util/gnunet-service-resolver.c
index 23ba39fee..d7d456fba 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -642,9 +642,9 @@ try_cache (const char *hostname,
     const struct GNUNET_DNSPARSER_Record *record = rle->record;
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Found cache entry for '%s', record type '%u'\n",
+                "Checking cache entry for '%s', record is for '%s'\n",
                 hostname,
-                record_type);
+                record->name);
     if ((GNUNET_DNSPARSER_TYPE_CNAME == record->type) &&
         (GNUNET_DNSPARSER_TYPE_CNAME != record_type) && (GNUNET_NO == found))
     {
@@ -653,7 +653,8 @@ try_cache (const char *hostname,
       process_get (hostname, record_type, client_request_id, client);
       return GNUNET_YES;     /* counts as a cache "hit" */
     }
-    found |= send_reply (rle->record, record_type, client_request_id, client);
+    if (0 == strcmp (record->name, hostname))
+      found |= send_reply (rle->record, record_type, client_request_id, 
client);
   }
   if (GNUNET_NO == found)
     return GNUNET_NO; /* had records, but none matched! */
@@ -723,6 +724,9 @@ cache_answers (const char *name,
     {
       rc = GNUNET_new (struct ResolveCache);
       rc->hostname = GNUNET_strdup (name);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Caching record for name %s under %s\n",
+                  record->name, name);
       GNUNET_CONTAINER_DLL_insert (cache_head, cache_tail, rc);
       cache_size++;
     }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]