gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [ascension] 31/45: added testing for gnunet -K option and m


From: gnunet
Subject: [GNUnet-SVN] [ascension] 31/45: added testing for gnunet -K option and more
Date: Fri, 25 Jan 2019 10:02:31 +0100

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

rexxnor pushed a commit to branch master
in repository ascension.

commit 44514ef6e9139cd675ad8a4d85a93ca91b61aac9
Author: rexxnor <address@hidden>
AuthorDate: Mon Nov 12 17:38:18 2018 +0100

    added testing for gnunet -K option and more
---
 gnsmigrator/gnsmigrator.py                  |  2 +-
 gnsmigrator/gnunet.py                       | 61 ++++++++++++++++++
 gnsmigrator/test/basic_named.conf           | 25 ++++++++
 gnsmigrator/test/gnunet.zone                | 18 ++++++
 gnsmigrator/test/test_gnsmigrator_simple.sh | 24 +++++++
 gnsmigrator/test/test_gnunet_multiple.sh    | 99 +++++++++++++++++++++++++++++
 setup.py                                    |  2 +-
 7 files changed, 229 insertions(+), 2 deletions(-)

diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 6603637..2cef855 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -499,7 +499,7 @@ def main():
         logging.critical('GNUnet Services are not running!')
         sys.exit(1)
 
-    # Not ideal as this will always be
+    # argument parsing
     debug = args['--debug']
     domain = args.get('<domain>', None)
     transferns = args['<transferns>'] if args['<transferns>'] else None
diff --git a/gnsmigrator/gnunet.py b/gnsmigrator/gnunet.py
new file mode 100644
index 0000000..8a935f0
--- /dev/null
+++ b/gnsmigrator/gnunet.py
@@ -0,0 +1,61 @@
+from ctypes import c_char_p
+from ctypes import c_size_t
+from ctypes import c_uint32
+from ctypes import c_uint64
+from ctypes import c_void_p
+from ctypes import CDLL
+from ctypes import Structure
+from enum import Enum
+from dataclasses import dataclass
+
+class GNUnetGNSRecordFlags(Enum):
+    """
+    Flags that can be set for a record.
+    """
+    GNUNET_GNSRECORD_RF_NONE = 0
+    GNUNET_GNSRECORD_RF_PRIVATE = 2
+    GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 8
+    GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16
+
+class GNUnetGNSRecordData():
+    """
+    Representation of a GNS Record in python
+    """
+    _fields_ = [("data", c_void_p),
+                ("expiration_time", c_uint64),
+                ("data_size", c_size_t),
+                ("record_type", c_uint32),
+                ("flags", GNUnetGNSRecordFlags)]
+
+class GNUnetEcdsaPrivateKey(Structure):
+    """
+    Representation of GNUNET_CRYPTO_EcdsaPrivateKey
+    """
+    _fields_ = [("d", c_char_p)]
+
+class GNUnetConfigurationHandle(Structure):
+    """
+    Representation of GNUNET_CONFIGURATION_HANDLE
+    """
+    pass
+
+class GNUnetMQHandle(Structure):
+    """
+    Representation of GNUNET_CONFIGURATION_HANDLE
+    """
+    pass
+
+class GNUnetNamestoreHandle():
+    """
+    Representation of GNUNET_NAMESTORE_Handle
+    """
+    _fields_ = [("cfg": GNUnetConfigurationHandle),
+                ("mq": GNUnetMQHandle),
+                ("op_head": GNUnetNamestoreQueueEntry),
+                ("op_tail": GNUnetNamestoreQueueEntry),
+                ("z_head": GNUnetNamestoreZoneIterator),
+                ("z_tail": GNUnetNamestoreZoneIterator),
+                ("reconnect_task": GNUnetSchedulerTask),
+                ("reconnect_delay": GNUnetTimeRelative),
+                ("reconnet": int),
+                ("last_op_id_used": c_uint32_t)]
diff --git a/gnsmigrator/test/basic_named.conf 
b/gnsmigrator/test/basic_named.conf
new file mode 100644
index 0000000..920e7af
--- /dev/null
+++ b/gnsmigrator/test/basic_named.conf
@@ -0,0 +1,25 @@
+options {
+    directory ".";
+    pid-file "/run/named/named.pid";
+
+    // Uncomment these to enable IPv6 connections support
+    // IPv4 will still work:
+    // listen-on-v6 { any; };
+    // Add this for no IPv4:
+    // listen-on { none; };
+
+    allow-recursion { 127.0.0.1; };
+    allow-transfer { 127.0.0.1; };
+    allow-update { none; };
+
+    version none;
+    hostname none;
+    server-id none;
+};
+
+zone "gnunet.org" IN {
+    type master;
+    file "gnunet.zone";
+    allow-query { any; };
+    allow-transfer { any; };
+};
diff --git a/gnsmigrator/test/gnunet.zone b/gnsmigrator/test/gnunet.zone
new file mode 100644
index 0000000..8fa7124
--- /dev/null
+++ b/gnsmigrator/test/gnunet.zone
@@ -0,0 +1,18 @@
+$TTL   3600
+@      IN      SOA     ns1.gnunet.org. root.gnunet.org. (
+                             2018090830                ; Serial
+                        3600           ; Refresh
+                         1800          ; Retry
+                       604800          ; Expire
+                        3600 )         ; Negative Cache TTL
+@      IN      NS      ns1.gnunet.org.
+@      IN      A       127.0.0.1
+www    IN      A       127.0.0.1
+owncloud       IN      A       127.0.0.1
+nextcloud      IN      A       127.0.0.1
+mail   IN      MX      10      mail.gnunet.org.
+mail   IN      A       127.0.0.1
+foo    IN      AAAA    2002::
+asdf   IN      CNAME   www
+ns1    IN      A       127.0.0.1
+ns2    IN      A       37.35.124.161
diff --git a/gnsmigrator/test/test_gnsmigrator_simple.sh 
b/gnsmigrator/test/test_gnsmigrator_simple.sh
new file mode 100644
index 0000000..2cb6045
--- /dev/null
+++ b/gnsmigrator/test/test_gnsmigrator_simple.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Check for required packages
+if ! [ -x "$(command -v named)" ]; then
+    echo 'bind/named is not installed' >&2
+    exit 1
+fi
+
+# Start named with a simple zone
+named -c basic_named.conf -p 5000
+
+# Check if domain resolves
+nslookup gnunet.org 127.0.0.1 -port=5000
+if $?; then
+    echo "Something went wrong with named"
+    exit 1
+fi
+
+# Let gnsmigrator run on gnunet.org test domain
+
+
+
+# Shutdown named
+pkill named
diff --git a/gnsmigrator/test/test_gnunet_multiple.sh 
b/gnsmigrator/test/test_gnunet_multiple.sh
new file mode 100644
index 0000000..8d78567
--- /dev/null
+++ b/gnsmigrator/test/test_gnunet_multiple.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+# Check for required packages
+if ! [ -x "$(command -v gnunet-namestore)" ]; then
+    echo 'bind/named is not installed' >&2
+    exit 1
+fi
+
+# Check if gnunet is running
+gnunet-arm -I 2&>1 /dev/null
+ret=$?
+if [ 0 -ne $ret ]; then
+    echo 'gnunet services are not running'
+    exit 1
+fi
+
+## GNUNET part
+# Check if identity exists and delets and readds it to get rid of entries in 
zone
+gnunet-identity -d | grep randomtestingid 2>&1 /dev/null
+ret=$?
+
+if [ 0 -ne $ret ]; then
+    gnunet-identity -D randomtestingid
+    gnunet-identity -C randomtestingid
+fi
+
+function minimize_ttl {
+    ttl=10000000
+    arr=$1
+    # parse each element and update ttl to smallest one
+    for i in "address@hidden"
+    do
+        currttl=$(echo -n "$i" | cut -d' ' -f1)
+        if [ "$currttl"  -lt "$ttl" ]
+        then
+            ttl=$currttl
+        fi
+
+    done
+    echo "$ttl"
+}
+
+function get_record_type {
+    arr=$1
+    typ=$(echo -n "${arr[0]}" | cut -d' ' -f2)
+    echo "$typ"
+}
+
+function get_value {
+    arr=$1
+    val=$(echo -n "${arr[0]}" | cut -d' ' -f4)
+    echo "$val"
+}
+
+function testing {
+    label=$1
+    records=$2
+    recordstring=""
+    typ=$(get_record_type "address@hidden")
+    for i in "address@hidden"
+    do
+        recordstring+="-R $i"
+    done
+    #echo "$recordstring"
+    gnunet-namestore -z randomtestingid -n "$label" "$recordstring" 2>&1  
/dev/null
+    if [ 0 -ne $ret ]; then
+        echo "failed to add record $label: $recordstring"
+    fi
+    gnunet-gns -t "$typ" -u foo2.randomtestingid 2>&1 /dev/null
+    if [ 0 -ne $ret ]; then
+        echo "record $label could not be found"
+    fi
+}
+
+# TEST CASES
+# 1
+echo "Testing adding of single A record with -R"
+declare -a arr=('1200 A n 127.0.0.1')
+testing test1 "address@hidden"
+# 2
+echo "Testing adding of multiple A records with -R"
+declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2')
+testing test2 "address@hidden"
+# 3
+echo "Testing adding of multiple different records with -R"
+declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::')
+testing test3 "address@hidden"
+# 4
+echo "Testing adding of single GNS2DNS record with -R"
+declare -a arr=('86400 GNS2DNS n address@hidden')
+testing test4 "address@hidden"
+# 5
+echo "Testing adding of single GNS2DNS shadow record with -R"
+declare -a arr=('86409 GNS2DNS s address@hidden')
+testing test5 "address@hidden"
+# 6
+echo "Testing adding of multiple GNS2DNS record with -R"
+declare -a arr=('86400 GNS2DNS s address@hidden' '86400 GNS2DNS s 
address@hidden')
+testing test6 "address@hidden"
diff --git a/setup.py b/setup.py
index 0adbe62..ba58cad 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
 
 setuptools.setup(
     name="gnsmigrator",
-    version="0.1.1",
+    version="0.1.2",
     author="Patrick Gerber",
     author_email="address@hidden",
     description="Tool to migrate DNS Zones to the GNU Name System",

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



reply via email to

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