[tor-commits] [ooni-probe/master] Implement more thorough end 2 end tests for oonibackend
art at torproject.org
art at torproject.org
Thu Sep 5 22:14:23 UTC 2013
commit 7e6885926987b191d0eb0145240e334cd5347e84
Author: Arturo Filastò <art at fuffa.org>
Date: Tue Aug 27 17:16:02 2013 +0200
Implement more thorough end 2 end tests for oonibackend
---
ooni/tests/test_oonibclient.py | 42 ++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/ooni/tests/test_oonibclient.py b/ooni/tests/test_oonibclient.py
index 0f22786..aef48b7 100644
--- a/ooni/tests/test_oonibclient.py
+++ b/ooni/tests/test_oonibclient.py
@@ -12,12 +12,14 @@ from ooni.oonibclient import OONIBClient
data_dir = '/tmp/testooni'
config.advanced.data_dir = data_dir
+
input_id = '37e60e13536f6afe47a830bfb6b371b5cf65da66d7ad65137344679b24fdccd1'
+deck_id = 'd4ae40ecfb3c1b943748cce503ab8233efce7823f3e391058fc0f87829c644ed'
class TestOONIBClient(unittest.TestCase):
def setUp(self):
host = '127.0.0.1'
- port = 8888
+ port = 8889
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host, port))
@@ -26,6 +28,7 @@ class TestOONIBClient(unittest.TestCase):
except: pass
os.mkdir(data_dir)
os.mkdir(os.path.join(data_dir, 'inputs'))
+ os.mkdir(os.path.join(data_dir, 'decks'))
except Exception as ex:
self.skipTest("OONIB must be listening on port 8888 to run this test (tor_hidden_service: false)")
self.oonibclient = OONIBClient('http://' + host + ':' + str(port))
@@ -53,16 +56,22 @@ class TestOONIBClient(unittest.TestCase):
@defer.inlineCallbacks
def test_get_deck_list(self):
- input_list = yield self.oonibclient.getInputList()
- self.assertTrue(isinstance(input_list, list))
+ deck_list = yield self.oonibclient.getDeckList()
+ self.assertTrue(isinstance(deck_list, list))
+ @defer.inlineCallbacks
def test_get_deck_descriptor(self):
- pass
+ deck_descriptor = yield self.oonibclient.getDeck(deck_id)
+ for key in ['name', 'description',
+ 'version', 'author', 'date', 'id']:
+ self.assertTrue(hasattr(deck_descriptor, key))
+ @defer.inlineCallbacks
def test_download_deck(self):
- pass
+ yield self.oonibclient.downloadDeck(deck_id)
def test_lookup_invalid_helpers(self):
+ self.oonibclient.address = 'http://127.0.0.1:8888'
return self.failUnlessFailure(
self.oonibclient.lookupTestHelpers([
'sdadsadsa', 'dns'
@@ -70,17 +79,26 @@ class TestOONIBClient(unittest.TestCase):
@defer.inlineCallbacks
def test_lookup_test_helpers(self):
+ self.oonibclient.address = 'http://127.0.0.1:8888'
required_helpers = [u'http-return-json-headers', u'dns']
helpers = yield self.oonibclient.lookupTestHelpers(required_helpers)
self.assertEqual(set(helpers.keys()), set(required_helpers + [u'default']))
@defer.inlineCallbacks
- def test_get_nettest_list(self):
- input_list = yield self.oonibclient.getInputList()
- self.assertTrue(isinstance(input_list, list))
+ def test_invalid_requests(self):
+
+ @defer.inlineCallbacks
+ def all_requests(path):
+ for mthd in ['GET', 'POST', 'PUT', 'OPTION']:
+ try:
+ yield self.oonibclient.queryBackend(mthd, path)
+ except:
+ pass
- def test_get_nettest_descriptor(self):
- pass
+ for path in ['/policy/input', '/policy/nettest',
+ '/input', '/input/'+'a'*64, '/fooo']:
+ yield all_requests(path)
- def test_download_nettest(self):
- pass
+ for path in ['/bouncer']:
+ self.oonibclient.address = 'http://127.0.0.1:8888'
+ yield all_requests(path)
More information about the tor-commits
mailing list