ascension

Migrate DNS zones to the GNU Name System
Log | Files | Refs | README | LICENSE

commit 1b658eb4cfbd21235fa8f0b9d8d4b4fafd83978d
parent 5ea0f07339abdca04b8bed6253b1940171c9f10e
Author: rexxnor <rexxnor+gnunet@brief.li>
Date:   Fri, 25 Jan 2019 17:19:02 +0100

added license headers, GNU coding style guidelines

Diffstat:
M.gitignore | 1+
RREADME.md -> README | 0
Mascension/ascension.py | 34++++++++++++++++++++++++++--------
Mascension/test/test_ascension_simple.sh | 7++++++-
Mascension/test/test_namestore_multiple.sh | 25+++++--------------------
Mascension/test/test_unit_ascension.py | 63++++++++++++++++++++++++++-------------------------------------
Mrequirements.txt | 1+
Msetup.py | 20+++++++++++++++++++-
8 files changed, 84 insertions(+), 67 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -96,3 +96,4 @@ ENV/ # mkdocs documentation /site .idea/ +managed-keys.bind.jnl diff --git a/README.md b/README diff --git a/ascension/ascension.py b/ascension/ascension.py @@ -1,13 +1,31 @@ #!/usr/bin/env python3 -"""Ascension - +# This file is part of Ascension. +# Copyright (C) 2019 GNUnet e.V. +# +# Ascension is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Ascension is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# SPDX-License-Identifier: AGPL3.0-or-later +# +# Author rexxnor +""" Usage: - ascension.py <domain> [-d] - ascension.py <domain> -p <port> [-d] - ascension.py <domain> -ns <transferns> [-d] - ascension.py <domain> -ns <transferns> -p <port> [-d] - ascension.py -h | --help - ascension.py -v | --version + ascension <domain> [-d] + ascension <domain> -p <port> [-d] + ascension <domain> -ns <transferns> [-d] + ascension <domain> -ns <transferns> -p <port> [-d] + ascension -h | --help + ascension -v | --version Options: <port> Port for zone transfer diff --git a/ascension/test/test_ascension_simple.sh b/ascension/test/test_ascension_simple.sh @@ -1,9 +1,14 @@ #!/bin/bash -# Author: rexxnor +# Copyright (C) 2019 rexxnor +# License AGPLv3+: GNU AGPL version 3 or later <https://www.gnu.org/licenses/agpl.html> +# This is free software: you are free to change and redistribute it. +# There is NO WARRANTY, to the extent permitted by law. +# # Returns 1 on basic error # Returns 2 on explicit test case errors # Returns 3 on implicit test case errors + # Shutdown named function cleanup { pkill named diff --git a/ascension/test/test_namestore_multiple.sh b/ascension/test/test_namestore_multiple.sh @@ -1,27 +1,12 @@ #!/bin/bash +# Copyright (C) 2019 rexxnor +# License AGPLv3+: GNU AGPL version 3 or later <https://www.gnu.org/licenses/agpl.html> +# This is free software: you are free to change and redistribute it. +# There is NO WARRANTY, to the extent permitted by law. # This file is in the public domain. -#trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT -# -#LOCATION=$(command -v 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 -s PATHS -o GNUNET_HOME -f)" -#command -v timeout &> /dev/null && DO_TIMEOUT="timeout 30" -# + ## VARS MYEGO=myego -#command -v timeout &> /dev/null && DO_TIMEOUT="timeout 15" -# -#gnunet-arm -s -c test_gns_lookup.conf gnunet-identity -C myego # HELPERS diff --git a/ascension/test/test_unit_ascension.py b/ascension/test/test_unit_ascension.py @@ -1,15 +1,31 @@ #!/usr/bin/env python3 """ -Unittests of ascension +This file is part of Ascension. +Copyright (C) 2019 GNUnet e.V. + +Ascension is free software: you can redistribute it and/or modify it +under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, +or (at your option) any later version. + +Ascension is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +SPDX-License-Identifier: AGPL3.0-or-later + +Author rexxnor """ import subprocess import unittest -import mock from unittest import TestCase from ascension import ascension - class TestAscender(TestCase): """ Short Unit Tests for WebArchiver @@ -19,51 +35,24 @@ class TestAscender(TestCase): """ Prepare data for tests """ - cls.ascension = ascension.Ascender(["pretty.fantasy"]) + cls.ascender = ascension.Ascender("notsopretty.fantasy", + transferns="ns1.example.com", + port=8000) def test_constructor(self): """ Tests constructor """ - self.assertEqual(["pretty.fantasy"], self.ascension.domainlist) - - def test_get_lowest_domain_part(self): - """ - Tests constructor - """ - self.assertEqual("pretty", self.ascension.get_lowest_domain_part( - self.ascension.domainlist[0])) - - def test_bootstrap_zones(self): - """ - Tests bootstrapping of zones with mocked subprocess commands - """ - self.ascension.bootstrap_zones() - # using mocked subprocesses to prevent inconsistent status - mocked_ident = mock.create_autospec(subprocess.check_output, return_value='fantasy PKEY') - self.assertIn('fantasy', mocked_ident(['gnunet-identity', '-d'])) - mocked_lookup = mock.create_autospec(subprocess.check_output, return_value='Got:') - self.assertIn('Got', mocked_lookup(['gnunet-gns', '-t', 'PKEY', '-u', 'pretty.fantasy'])) - mocked_failed_lookup = mock.create_autospec(subprocess.check_output, return_value=3) - self.assertIs(3, mocked_failed_lookup(['gnunet-gns', '-t', 'PKEY', '-u', 'pretty.pretty.fantasy'])) - - def test_initial_zone_transfer(self): - """ - Tests different ways of zone transfer not working - """ - self.ascension.initial_zone_transfer() - - # Needs to be done via mock stuff or expect weird stuff - #self.assertRaises(dns.resolver.NoAnswer, self.ascension.initial_zone_transfer()) - #self.assertRaises(dns.resolver.NoAnswer, self.ascension2.initial_zone_transfer()) + self.assertEqual("ns1.example.com", self.ascender.transferns) + self.assertEqual(8000, self.ascender.port) @classmethod def tearDownClass(cls): """ Removes all zones and cleans up testing environment """ - subprocess.run(['gnunet-identity', '-D', 'pretty']) - subprocess.run(['gnunet-identity', '-D', 'fantasy']) + subprocess.run(['gnunet-identity', '-D', 'pretty.fantasy']) + subprocess.run(['gnunet-identity', '-D', 'notsopretty.fantasy']) if __name__ == "__main__": unittest.main() diff --git a/requirements.txt b/requirements.txt @@ -1,3 +1,4 @@ +# This file is in the public domain coverage==4.5.2 daemon==1.2 daemonize==2.5.0 diff --git a/setup.py b/setup.py @@ -1,6 +1,24 @@ #!/usr/bin/env python3 """ -Setup file for installing the package +This file is part of Ascension. +Copyright (C) 2019 GNUnet e.V. + +Ascension is free software: you can redistribute it and/or modify it +under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, +or (at your option) any later version. + +Ascension is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +SPDX-License-Identifier: AGPL3.0-or-later + +Author rexxnor """ import setuptools