[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [ascension] 07/57: fixes, added a few tests, updated README
From: |
gnunet |
Subject: |
[GNUnet-SVN] [ascension] 07/57: fixes, added a few tests, updated README and requirements |
Date: |
Sat, 13 Apr 2019 13:32:04 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository ascension.
commit 7efb97ffe9809344f007e82b693bb6190c8381d0
Author: rexxnor <address@hidden>
AuthorDate: Fri Sep 21 20:11:13 2018 +0200
fixes, added a few tests, updated README and requirements
---
README.md | 23 +++++++++++++
gnsmigrator/gnsmigrator.py | 19 ++++++-----
gnsmigrator/gnsmigrator_unit_tests.py | 64 +++++++++++++++++++++++++++++++++++
requirements.txt | 1 +
setup.py | 29 ++++++++++++++++
5 files changed, 127 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index b310ef2..010e377 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,26 @@
The main goal is to develop a tool to easily migrate existing DNS Zones to the
GNU Name System
+
+## How to use
+
+To use the program simply execute python3 on the gnsmigrator.py file.
+At a later stage this will be possible to do by installing the program and
after execute it directly using "gnsmigrator"
+
+
+Taken from the dosctring of the gnsmigrator.py file:
+```
+GNS Migrator
+
+Usage:
+ gnsmigrator.py <file>
+ gnsmigrator.py -h | --help
+ gnsmigrator.py --version
+
+Options:
+ <file> CSV File containing domains to transfer
+ -h --help Show this screen.
+ --version Show version.
+```
+
+
diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 811863e..0ef44b6 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -7,8 +7,9 @@ Usage:
gnsmigrator.py --version
Options:
+ <file> CSV File containing domains to transfer
-h --help Show this screen.
- --version Show version.
+ -v --version Show version.
"""
# imports
@@ -28,7 +29,6 @@ class GNSMigrator():
"""
Class that provides functionality to migrate zones
"""
-
@classmethod
def __init__(cls, domainlist):
cls.domainlist = domainlist
@@ -108,8 +108,9 @@ class GNSMigrator():
def add_records_to_gns(zonename, zone, domain):
"""
Checks if records are present
- :param param1: zone to lookup
- :returns: parts of zone that are not in GNS
+ :param zonename: zonename of zone to add records to
+ :param zone: the transfered zone
+ :param domain: full domain of zone
"""
# can optimize with for record in zone.iterate_rdatas.filter()
for record in zone.iterate_rdatas():
@@ -134,7 +135,7 @@ class GNSMigrator():
'-V', value,
'-e', '%ds' % ttl])
if rtype_str in ['A', 'AAAA']:
- # This is EXPERIMENTAL
+ # This is EXPERIMENTAL LEgacy HOstname implementation
subprocess.run([GNUNET_NAMESTORE_COMMAND,
'-z', zonename,
'-a', '-n', dnsname_str,
@@ -155,7 +156,7 @@ def main():
"""
Initializes object and handles arguments
"""
- args = docopt.docopt(__doc__, version='GNS Migrator 0.1a')
+ args = docopt.docopt(__doc__, version='GNS Migrator 0.0.1')
csvfile = args['<file>']
domainlist = []
with open(csvfile, 'r') as openedcsv:
@@ -171,10 +172,10 @@ def main():
zone, xfrinfo = zonetuple
zonename = gnsmigrator.get_lowest_domain_part(domain)
gnsmigrator.add_records_to_gns(zonename, zone, domain)
- print(xfrinfo)
- # gnsmigrator.add_records_to_gns(remaining_records)
+ # retain the information needed for a second zone transfer
+ #print(xfrinfo)
if __name__ == '__main__':
- # ensure gnunet is runnning
+ # TODO ensure gnunet is runnning
main()
diff --git a/gnsmigrator/gnsmigrator_unit_tests.py
b/gnsmigrator/gnsmigrator_unit_tests.py
new file mode 100644
index 0000000..12a56e7
--- /dev/null
+++ b/gnsmigrator/gnsmigrator_unit_tests.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+"""
+Tests of gnsmigrator
+"""
+
+import subprocess
+import unittest
+from unittest import TestCase
+import dns.exception
+import dns.resolver
+import gnsmigrator
+
+
+class TestGNSMigrator(TestCase):
+ """
+ Short Unit Tests for WebArchiver
+ """
+
+ def setUp(self):
+ """
+ Prepare data for tests
+ """
+ self.gnsmigrator = gnsmigrator.GNSMigrator(["example.fantasy"])
+ self.gnsmigrator2 = gnsmigrator.GNSMigrator(["example.com"])
+ self.gnsmigrator3 = gnsmigrator.GNSMigrator(["bfh.ch"])
+
+ def test_constructor(self):
+ """
+ Tests constructor
+ """
+ self.assertEqual("example.fantasy", self.gnsmigrator.domainlist)
+
+ def test_get_lowest_domain_part(self):
+ """
+ Tests constructor
+ """
+ self.assertEqual("example", self.gnsmigrator.get_lowest_domain_part(
+ self.gnsmigrator.domainlist[0]))
+
+ def test_bootstrap_zones(self):
+ """
+ Tests bootstrapping of zones
+ """
+ self.gnsmigrator.bootstrap_zones()
+ self.assertIn('example', subprocess.check_output(['gnunet-identity',
'-d']))
+ self.assertIn('fantasy', subprocess.check_output(['gnunet-identity',
'-d']))
+
+ def test_initial_zone_transfer(self):
+ """
+ Tests different ways of zone transfer not working
+ """
+ self.assertRaises(dns.resolver.NoAnswer,
self.gnsmigrator.initial_zone_transfer())
+ self.assertRaises(dns.resolver.NoAnswer,
self.gnsmigrator2.initial_zone_transfer())
+ self.assertRaises(dns.exception.FormError,
self.gnsmigrator3.initial_zone_transfer())
+
+def main():
+ """
+ Main method
+ """
+ unittest.main()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/requirements.txt b/requirements.txt
index 9f7a9d9..b9b1772 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,5 @@
cffi==1.11.5
+coverage==4.5.1
dnspython==1.15.0
docopt==0.6.2
pycparser==2.18
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..743885b
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+"""
+Setup file for installing the package
+"""
+
+import setuptools
+
+with open("README.md", "r") as fh:
+ long_description = fh.read()
+
+setuptools.setup(
+ name="gnsmigrator",
+ version="0.0.1",
+ author="Patrick Gerber",
+ author_email="address@hidden",
+ description="Tool to migrate DNS Zones to the GNU Name System",
+ long_description=long_description,
+ long_description_content_type="text/markdown",
+ url="https://gitlab.ti.bfh.ch/gerbp6/gnsmigrator",
+ packages=setuptools.find_packages(),
+ classifiers=[
+ "Programming Language :: Python :: 3",
+ ],
+ entry_points={
+ 'console_scripts': [
+ 'gnsmigrator=gnsmigrator:main',
+ ],
+ },
+)
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [ascension] 15/57: created baseclass and separated small from big zones, (continued)
- [GNUnet-SVN] [ascension] 15/57: created baseclass and separated small from big zones, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 21/57: fixed serial fetching and added serialization of zone, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 13/57: added zone merging of full and incremental zones, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 29/57: added warnings to logging if records failed to be added, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 27/57: unstable version, port specification possible, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 02/57: Added LICENSE, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 18/57: refactored adding of records, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 08/57: added GNS2DNS support and rudimentary Unittests (incomplete), gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 23/57: fixed non existing file, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 42/57: added dnscurve detection and log it, fix ttl bug with hierarchy, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 07/57: fixes, added a few tests, updated README and requirements,
gnunet <=
- [GNUnet-SVN] [ascension] 10/57: added incremental zone transfer logic, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 54/57: lint manpage, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 39/57: added daemonization, bumped version, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 57/57: ascension.1: remove texinfo syntax, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 49/57: minor cleanup, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 51/57: removed daemonization, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 26/57: added definitive support for IXFR, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 37/57: updated README, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 22/57: finished refactoring, fixed a few bugs, gnunet, 2019/04/13
- [GNUnet-SVN] [ascension] 30/57: updated gnsmigrator and removed c rebuilds, gnunet, 2019/04/13