2019-12-18 09:52:52 +00:00
|
|
|
import sys, os
|
|
|
|
sys.path.append(".")
|
|
|
|
sys.path.append("src/")
|
|
|
|
import unittest, uuid
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
|
|
print("Test directory:", TEST_DIR)
|
|
|
|
os.environ["ONIONR_HOME"] = TEST_DIR
|
|
|
|
from utils import createdirs, identifyhome
|
|
|
|
import onionrsetup as setup
|
|
|
|
import onionrexceptions
|
|
|
|
|
|
|
|
|
|
|
|
createdirs.create_dirs()
|
|
|
|
setup.setup_config()
|
|
|
|
|
|
|
|
class TestBigBrother(unittest.TestCase):
|
2022-05-16 04:21:45 +00:00
|
|
|
def test_system(self):
|
|
|
|
import bigbrother
|
|
|
|
bigbrother.enable_ministries()
|
|
|
|
self.assertRaises(onionrexceptions.ArbitraryCodeExec, os.system, "echo test")
|
|
|
|
|
2019-12-18 09:52:52 +00:00
|
|
|
def test_requests_connect(self):
|
|
|
|
import bigbrother
|
|
|
|
bigbrother.enable_ministries()
|
|
|
|
with self.assertRaises(onionrexceptions.NetworkLeak):
|
|
|
|
requests.get('https://example.com')
|
2020-03-16 07:06:37 +00:00
|
|
|
with self.assertRaises(onionrexceptions.NetworkLeak):
|
|
|
|
requests.get('https://1.1.1.1/')
|
2019-12-18 09:52:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
unittest.main()
|