[Pkg-privacy-commits] [obfsproxy] 128/353: Add integration tests for obfs2 with shared secret.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository obfsproxy.
commit 6da914e644724eb744f35d3c4d2e64589b82249b
Author: George Kadianakis <desnacked at riseup.net>
Date: Tue Mar 5 00:50:48 2013 +0200
Add integration tests for obfs2 with shared secret.
Also make the integration testers more resistant to transports that
need some time to bootstrap (like the iterated hashing in
obfs2-with-shared-secret).
---
obfsproxy/test/int_tests/pits.py | 6 ++++--
obfsproxy/test/int_tests/pits_transcript.py | 4 +++-
obfsproxy/test/int_tests/test_pits.py | 20 ++++++++++++++++++++
obfsproxy/test/tester.py | 15 +++++++++++++--
4 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/obfsproxy/test/int_tests/pits.py b/obfsproxy/test/int_tests/pits.py
index 4cdb3cd..b5b96b1 100644
--- a/obfsproxy/test/int_tests/pits.py
+++ b/obfsproxy/test/int_tests/pits.py
@@ -211,11 +211,13 @@ class TestReader(object):
except StopIteration: # Test case is over.
return self.assertTrue(self.pits.transcript.test_was_success(self.script))
+ time.sleep(0.3)
+
self.pits.do_command(line)
- # 0.2 seconds should be enough time for the network operations to complete,
+ # 0.4 seconds should be enough time for the network operations to complete,
# so that we can move to the next command.
- d = task.deferLater(reactor, 0.2, self._do_command)
+ d = task.deferLater(reactor, 0.4, self._do_command)
return d
def cleanup(self):
diff --git a/obfsproxy/test/int_tests/pits_transcript.py b/obfsproxy/test/int_tests/pits_transcript.py
index db33f70..be0ba49 100644
--- a/obfsproxy/test/int_tests/pits_transcript.py
+++ b/obfsproxy/test/int_tests/pits_transcript.py
@@ -66,8 +66,10 @@ class Transcript(object):
if tokens[0] == 'P' or tokens[0] == '#': # Ignore
continue
- elif tokens[0] in ['!', '*']: # Inbound events
+ elif tokens[0] == '!': # Count '!' as inbound event
inbound_events.append(line)
+ elif tokens[0] == '*': # Count '*' as outbound event
+ outbound_events.append(line)
elif tokens[0] == '>': # Data towards inbound socket
if not tokens[1] in inbound_data:
inbound_data[tokens[1]] = ''
diff --git a/obfsproxy/test/int_tests/test_pits.py b/obfsproxy/test/int_tests/test_pits.py
index fac99d5..29f87aa 100644
--- a/obfsproxy/test/int_tests/test_pits.py
+++ b/obfsproxy/test/int_tests/test_pits.py
@@ -23,6 +23,20 @@ class PITSTest(twisted.trial.unittest.TestCase):
'127.0.0.1:%d' % pits.SERVER_OBFSPORT,
'--dest=127.0.0.1:%d' % self.treader.pits.get_pits_inbound_address().port))
+ def _doTest_shared_secret(self, transport_name, test_case_file):
+ self.treader = pits.TestReader(self.assertTrue, test_case_file)
+ return self.treader.do_test(
+ ('%s' % transport_name,
+ 'client',
+ '127.0.0.1:%d' % pits.CLIENT_OBFSPORT,
+ '--shared-secret=test',
+ '--dest=127.0.0.1:%d' % pits.SERVER_OBFSPORT),
+ ('%s' % transport_name,
+ 'server',
+ '127.0.0.1:%d' % pits.SERVER_OBFSPORT,
+ '--shared-secret=test',
+ '--dest=127.0.0.1:%d' % self.treader.pits.get_pits_inbound_address().port))
+
# XXX This is pretty ridiculous. Find a smarter way to make up for the
# absense of load_tests().
def test_dummy_1(self):
@@ -37,6 +51,12 @@ class PITSTest(twisted.trial.unittest.TestCase):
def test_obfs2_2(self):
return self._doTest("obfs2", "../test_case_simple.pits")
+ def test_obfs2_shared_secret_1(self):
+ return self._doTest_shared_secret("obfs2", "../test_case.pits")
+
+ def test_obfs2_shared_secret_2(self):
+ return self._doTest_shared_secret("obfs2", "../test_case_simple.pits")
+
def test_obfs3_1(self):
return self._doTest("obfs3", "../test_case.pits")
diff --git a/obfsproxy/test/tester.py b/obfsproxy/test/tester.py
index abad45f..9e8716b 100644
--- a/obfsproxy/test/tester.py
+++ b/obfsproxy/test/tester.py
@@ -118,7 +118,7 @@ def connect_with_retry(addr):
retry += 1
time.sleep(0.05)
-SOCKET_TIMEOUT = 1.0
+SOCKET_TIMEOUT = 2.0
class ReadWorker(object):
"""
@@ -202,7 +202,7 @@ class DirectTest(object):
# transfer a file. Then check whether the output is the same
# as the input.
self.input_chan.sendall(TEST_FILE)
- time.sleep(1)
+ time.sleep(2)
try:
output = self.output_reader.get()
except Queue.Empty:
@@ -240,6 +240,17 @@ class DirectObfs2(DirectTest, unittest.TestCase):
"127.0.0.1:%d" % ENTRY_PORT,
"--dest=127.0.0.1:%d" % SERVER_PORT)
+class DirectObfs2_ss(DirectTest, unittest.TestCase):
+ transport = "obfs2"
+ server_args = ("obfs2", "server",
+ "127.0.0.1:%d" % SERVER_PORT,
+ "--shared-secret=test",
+ "--dest=127.0.0.1:%d" % EXIT_PORT)
+ client_args = ("obfs2", "client",
+ "127.0.0.1:%d" % ENTRY_PORT,
+ "--shared-secret=test",
+ "--dest=127.0.0.1:%d" % SERVER_PORT)
+
class DirectB64(DirectTest, unittest.TestCase):
transport = "b64"
server_args = ("b64", "server",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git
More information about the Pkg-privacy-commits
mailing list