From 4f6f83f383c13943339097bc91e913ae363fc4e9 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 12 Sep 2019 21:22:25 -0500 Subject: [PATCH] moved tests to parent directory --- .gitignore | 2 +- SECURITY.md | 2 +- run_tests.sh | 3 +-- {onionr/tests => tests}/test_blocks.py | 3 ++- {onionr/tests => tests}/test_commands.py | 3 ++- {onionr/tests => tests}/test_database_actions.py | 3 ++- {onionr/tests => tests}/test_default_config_json.py | 3 ++- {onionr/tests => tests}/test_forward_secrecy.py | 3 ++- {onionr/tests => tests}/test_getopenport.py | 3 ++- {onionr/tests => tests}/test_highlevelcrypto.py | 3 ++- {onionr/tests => tests}/test_identifyhome.py | 3 ++- {onionr/tests => tests}/test_keymanager.py | 3 ++- {onionr/tests => tests}/test_networkmerger.py | 3 ++- {onionr/tests => tests}/test_onionrusers.py | 3 ++- {onionr/tests => tests}/test_storagecounter.py | 3 ++- {onionr/tests => tests}/test_stringvalidations.py | 3 ++- {onionr/tests => tests}/test_zfill.py | 3 ++- 17 files changed, 31 insertions(+), 18 deletions(-) rename {onionr/tests => tests}/test_blocks.py (96%) rename {onionr/tests => tests}/test_commands.py (93%) rename {onionr/tests => tests}/test_database_actions.py (97%) rename {onionr/tests => tests}/test_default_config_json.py (93%) rename {onionr/tests => tests}/test_forward_secrecy.py (96%) rename {onionr/tests => tests}/test_getopenport.py (90%) rename {onionr/tests => tests}/test_highlevelcrypto.py (99%) rename {onionr/tests => tests}/test_identifyhome.py (91%) rename {onionr/tests => tests}/test_keymanager.py (97%) rename {onionr/tests => tests}/test_networkmerger.py (96%) rename {onionr/tests => tests}/test_onionrusers.py (98%) rename {onionr/tests => tests}/test_storagecounter.py (97%) rename {onionr/tests => tests}/test_stringvalidations.py (98%) rename {onionr/tests => tests}/test_zfill.py (95%) diff --git a/.gitignore b/.gitignore index cc6624db..4bd1073a 100755 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ core venv/* onionr/fs* onionr/tmp/* - +testdata/* *.dll *.exe diff --git a/SECURITY.md b/SECURITY.md index 47a7f806..48c58f88 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -17,7 +17,7 @@ The following exploits are of particular interest: * Discovering true server IPs when behind Tor/I2P (aside from Tor/i2p-level attacks) * Easily discovering which nodes are the block creator * XSS, CSRF, clickjacking, DNS rebinding -* Timing attacks against the local http server ([see blog post](https://www.chaoswebs.net/blog/timebleed-breaking-privacy-with-a-simple-timing-attack.html)) +* Timing attacks against the local http server that are exploitable from a browser ([see blog post](https://www.chaoswebs.net/blog/timebleed-breaking-privacy-with-a-simple-timing-attack.html)) * Discovering direct connection servers as a non participant. * Cryptography/protocol issues * Denying nodes access to the network by segmenting them out with Sybil nodes diff --git a/run_tests.sh b/run_tests.sh index c59e6b3a..74cb596f 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,5 +1,4 @@ #!/bin/bash -cd onionr; rm -rf testdata; mkdir testdata; ran=0 @@ -14,4 +13,4 @@ for f in tests/*.py; do python3 "$f" || close # if needed let "ran++" done -echo "ran $ran test files successfully in $SECONDS seconds" \ No newline at end of file +echo "ran $ran test files successfully in $SECONDS seconds" diff --git a/onionr/tests/test_blocks.py b/tests/test_blocks.py similarity index 96% rename from onionr/tests/test_blocks.py rename to tests/test_blocks.py index 242b4bfa..48f3fd4e 100755 --- a/onionr/tests/test_blocks.py +++ b/tests/test_blocks.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid, hashlib import onionrblocks @@ -30,4 +31,4 @@ class OnionrBlockTests(unittest.TestCase): bl = onionrblocks.insert(message, asymPeer=onionrcrypto.pub_key) self.assertIn(bytesconverter.str_to_bytes(message), onionrblockapi.Block(bl, decrypt=True).bcontent) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_commands.py b/tests/test_commands.py similarity index 93% rename from onionr/tests/test_commands.py rename to tests/test_commands.py index 7eb6fcae..35502f9e 100644 --- a/onionr/tests/test_commands.py +++ b/tests/test_commands.py @@ -1,6 +1,7 @@ from unittest.mock import patch import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) @@ -16,4 +17,4 @@ class OnionrTests(unittest.TestCase): with patch.object(sys, 'argv', testargs): parser.register() -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_database_actions.py b/tests/test_database_actions.py similarity index 97% rename from onionr/tests/test_database_actions.py rename to tests/test_database_actions.py index 54607f43..da71645a 100755 --- a/onionr/tests/test_database_actions.py +++ b/tests/test_database_actions.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid, sqlite3 TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) @@ -36,4 +37,4 @@ class OnionrTests(unittest.TestCase): keydb.transportinfo.set_address_info(adder, 'success', 1000) self.assertEqual(keydb.transportinfo.get_address_info(adder, 'success'), 1000) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_default_config_json.py b/tests/test_default_config_json.py similarity index 93% rename from onionr/tests/test_default_config_json.py rename to tests/test_default_config_json.py index 7cd69687..e7273a82 100644 --- a/onionr/tests/test_default_config_json.py +++ b/tests/test_default_config_json.py @@ -1,5 +1,6 @@ import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid, json TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) @@ -18,4 +19,4 @@ class OnionrConfig(unittest.TestCase): with open(TEST_DIR + 'config.json') as conf: json.loads(conf.read()) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_forward_secrecy.py b/tests/test_forward_secrecy.py similarity index 96% rename from onionr/tests/test_forward_secrecy.py rename to tests/test_forward_secrecy.py index e8db44d2..7071baae 100755 --- a/onionr/tests/test_forward_secrecy.py +++ b/tests/test_forward_secrecy.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os, random sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR_1 = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' TEST_DIR_2 = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -40,4 +41,4 @@ class OnionrForwardSecrecyTests(unittest.TestCase): self.assertEqual(decrypted, message.encode()) return -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_getopenport.py b/tests/test_getopenport.py similarity index 90% rename from onionr/tests/test_getopenport.py rename to tests/test_getopenport.py index fb82e224..78c42905 100644 --- a/onionr/tests/test_getopenport.py +++ b/tests/test_getopenport.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -13,4 +14,4 @@ class GetOpenPortTest(unittest.TestCase): open_port = int(netcontroller.get_open_port()) self.assertGreaterEqual(open_port, 1024) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_highlevelcrypto.py b/tests/test_highlevelcrypto.py similarity index 99% rename from onionr/tests/test_highlevelcrypto.py rename to tests/test_highlevelcrypto.py index 4d1a86cf..962ba2ce 100755 --- a/onionr/tests/test_highlevelcrypto.py +++ b/tests/test_highlevelcrypto.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid, hashlib, base64 import nacl.exceptions import nacl.signing, nacl.hash, nacl.encoding @@ -118,4 +119,4 @@ class OnionrCryptoTests(unittest.TestCase): self.assertTrue(gen1 == gen2) self.assertTrue(stringvalidators.validate_pub_key(gen1[0])) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_identifyhome.py b/tests/test_identifyhome.py similarity index 91% rename from onionr/tests/test_identifyhome.py rename to tests/test_identifyhome.py index 1e649fb6..7ab803ab 100644 --- a/onionr/tests/test_identifyhome.py +++ b/tests/test_identifyhome.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid from utils import identifyhome @@ -12,4 +13,4 @@ class IdentifyHomeTest(unittest.TestCase): os.environ["ONIONR_HOME"] = "testhome" self.assertEqual(os.getcwd() + "/testhome/", identifyhome.identify_home()) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_keymanager.py b/tests/test_keymanager.py similarity index 97% rename from onionr/tests/test_keymanager.py rename to tests/test_keymanager.py index 271e7231..610ee67c 100644 --- a/onionr/tests/test_keymanager.py +++ b/tests/test_keymanager.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -35,4 +36,4 @@ class KeyManagerTest(unittest.TestCase): with open(filepaths.keys_file, 'r') as keyfile: self.assertNotIn(new_key, keyfile.read()) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_networkmerger.py b/tests/test_networkmerger.py similarity index 96% rename from onionr/tests/test_networkmerger.py rename to tests/test_networkmerger.py index 79d01a36..dc9c9f0d 100644 --- a/onionr/tests/test_networkmerger.py +++ b/tests/test_networkmerger.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -28,4 +29,4 @@ class NetworkMergerTest(unittest.TestCase): for adder in adders: self.assertNotIn(adder, added) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_onionrusers.py b/tests/test_onionrusers.py similarity index 98% rename from onionr/tests/test_onionrusers.py rename to tests/test_onionrusers.py index fd880f15..4d902eca 100755 --- a/onionr/tests/test_onionrusers.py +++ b/tests/test_onionrusers.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid import json TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -89,4 +90,4 @@ class OnionrUserTests(unittest.TestCase): else: self.assertTrue(False) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_storagecounter.py b/tests/test_storagecounter.py similarity index 97% rename from onionr/tests/test_storagecounter.py rename to tests/test_storagecounter.py index dbd2e75c..2ba0c0d2 100644 --- a/onionr/tests/test_storagecounter.py +++ b/tests/test_storagecounter.py @@ -1,5 +1,6 @@ import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' @@ -44,4 +45,4 @@ class TestStorageCounter(unittest.TestCase): self.assertEqual(counter.get_amount(), start_value) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_stringvalidations.py b/tests/test_stringvalidations.py similarity index 98% rename from onionr/tests/test_stringvalidations.py rename to tests/test_stringvalidations.py index 6e44484d..dd1bb3ad 100755 --- a/onionr/tests/test_stringvalidations.py +++ b/tests/test_stringvalidations.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys, os sys.path.append(".") +sys.path.append("onionr/") import unittest, uuid TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/' print("Test directory:", TEST_DIR) @@ -68,4 +69,4 @@ class OnionrValidations(unittest.TestCase): #print('testing', x) self.assertFalse(stringvalidators.is_integer_string(x)) -unittest.main() \ No newline at end of file +unittest.main() diff --git a/onionr/tests/test_zfill.py b/tests/test_zfill.py similarity index 95% rename from onionr/tests/test_zfill.py rename to tests/test_zfill.py index e13ce1bb..2fb4471b 100644 --- a/onionr/tests/test_zfill.py +++ b/tests/test_zfill.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import unittest, sys sys.path.append(".") +sys.path.append("onionr/") from utils import reconstructhash @@ -18,4 +19,4 @@ class ZFill_Hash(unittest.TestCase): h = "0000e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87" h_no = "e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87" self.assertEqual(reconstructhash.deconstruct_hash(h), h_no) -unittest.main() \ No newline at end of file +unittest.main()