2019-07-26 05:55:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys, os
|
|
|
|
sys.path.append(".")
|
2019-11-21 09:26:23 +00:00
|
|
|
sys.path.append("src/")
|
2019-07-26 05:55:20 +00:00
|
|
|
import unittest, uuid
|
|
|
|
|
|
|
|
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
|
|
print("Test directory:", TEST_DIR)
|
|
|
|
os.environ["ONIONR_HOME"] = TEST_DIR
|
2019-12-10 10:46:36 +00:00
|
|
|
from utils import networkmerger
|
2019-07-26 05:55:20 +00:00
|
|
|
from coredb import keydb
|
2019-09-08 09:48:16 +00:00
|
|
|
import onionrsetup as setup
|
2019-07-26 05:55:20 +00:00
|
|
|
from utils import createdirs
|
|
|
|
createdirs.create_dirs()
|
2019-08-05 23:09:04 +00:00
|
|
|
setup.setup_config()
|
2019-07-26 05:55:20 +00:00
|
|
|
class NetworkMergerTest(unittest.TestCase):
|
|
|
|
def test_valid_merge(self):
|
|
|
|
adders = 'facebookcorewwwi.onion,mporbyyjhmz2c62shctbi3ngrslne5lpcyav6uzhxok45iblodhgjoad.onion'
|
|
|
|
networkmerger.mergeAdders(adders)
|
|
|
|
added = keydb.listkeys.list_adders()
|
|
|
|
self.assertIn('mporbyyjhmz2c62shctbi3ngrslne5lpcyav6uzhxok45iblodhgjoad.onion', added)
|
|
|
|
self.assertNotIn('inwalidkcorewwi.onion', added)
|
|
|
|
self.assertIn('facebookcorewwwi.onion', added)
|
|
|
|
|
|
|
|
def test_invalid_mergeself(self):
|
|
|
|
adders = 'facebookc0rewwi.onion,sdfsdfsdf.onion, ssdf324, null, \n'
|
|
|
|
networkmerger.mergeAdders(adders)
|
|
|
|
added = keydb.listkeys.list_adders()
|
|
|
|
for adder in adders:
|
|
|
|
self.assertNotIn(adder, added)
|
|
|
|
|
2019-09-13 02:22:25 +00:00
|
|
|
unittest.main()
|