[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Add obfs4 bridge line unittests and regression tests for #12932.
commit 6f29393d48612f1a5fee97d889971fefa671b877
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Sat Sep 6 02:59:24 2014 +0000
Add obfs4 bridge line unittests and regression tests for #12932.
---
lib/bridgedb/test/test_https.py | 133 +++++++++++++++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
diff --git a/lib/bridgedb/test/test_https.py b/lib/bridgedb/test/test_https.py
index bb783fb..2262db3 100644
--- a/lib/bridgedb/test/test_https.py
+++ b/lib/bridgedb/test/test_https.py
@@ -218,3 +218,136 @@ class HTTPTests(unittest.TestCase):
self.assertEquals(PT, pt)
self.assertTrue(password.find("password=") != -1,
"Password field missing expected text")
+
+ def test_get_obfs4_ipv4(self):
+ """Try asking for obfs4 bridges, and check that the PT arguments in the
+ returned bridge lines were space-separated.
+
+ This is a regression test for #12932, see
+ https://bugs.torproject.org/12932.
+ """
+ if os.environ.get("CI"):
+ if not self.pid or not processExists(self.pid):
+ raise FailTest("Could not start BridgeDB process on CI server!")
+ if not self.pid or not processExists(self.pid):
+ raise SkipTest("Can't run test: no BridgeDB process running.")
+
+ self.openBrowser()
+ self.goToOptionsPage()
+
+ PT = 'obfs4'
+
+ try:
+ soup = self.submitOptions(transport=PT, ipv6=False,
+ captchaResponse=CAPTCHA_RESPONSE)
+ except ValueError as error:
+ if 'non-disabled' in str(error):
+ raise SkipTest("Pluggable Transport obfs4 is currently disabled.")
+
+ bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=6)
+ for bridge in bridges:
+ pt = bridge[0]
+ ptArgs = bridge[-3:]
+ self.assertEquals(PT, pt)
+ self.assertTrue(len(ptArgs) == 3,
+ ("Expected obfs4 bridge line to have 3 PT args, "
+ "found %d instead: %s") % (len(ptArgs), ptArgs))
+
+ def test_get_obfs4_ipv4_iatmode(self):
+ """Ask for obfs4 bridges and check that there is an 'iat-mode' PT
+ argument in the bridge lines.
+ """
+ if os.environ.get("CI"):
+ if not self.pid or not processExists(self.pid):
+ raise FailTest("Could not start BridgeDB process on CI server!")
+ if not self.pid or not processExists(self.pid):
+ raise SkipTest("Can't run test: no BridgeDB process running.")
+
+ self.openBrowser()
+ self.goToOptionsPage()
+
+ PT = 'obfs4'
+
+ try:
+ soup = self.submitOptions(transport=PT, ipv6=False,
+ captchaResponse=CAPTCHA_RESPONSE)
+ except ValueError as error:
+ if 'non-disabled' in str(error):
+ raise SkipTest("Pluggable Transport obfs4 is currently disabled.")
+
+ bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=6)
+ for bridge in bridges:
+ ptArgs = bridge[-3:]
+ hasIATMode = False
+ for arg in ptArgs:
+ if 'iat-mode' in arg:
+ hasIATMode = True
+
+ self.assertTrue(hasIATMode,
+ "obfs4 bridge line is missing 'iat-mode' PT arg.")
+
+ def test_get_obfs4_ipv4_publickey(self):
+ """Ask for obfs4 bridges and check that there is an 'public-key' PT
+ argument in the bridge lines.
+ """
+ if os.environ.get("CI"):
+ if not self.pid or not processExists(self.pid):
+ raise FailTest("Could not start BridgeDB process on CI server!")
+ if not self.pid or not processExists(self.pid):
+ raise SkipTest("Can't run test: no BridgeDB process running.")
+
+ self.openBrowser()
+ self.goToOptionsPage()
+
+ PT = 'obfs4'
+
+ try:
+ soup = self.submitOptions(transport=PT, ipv6=False,
+ captchaResponse=CAPTCHA_RESPONSE)
+ except ValueError as error:
+ if 'non-disabled' in str(error):
+ raise SkipTest("Pluggable Transport obfs4 is currently disabled.")
+
+ bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=6)
+ for bridge in bridges:
+ ptArgs = bridge[-3:]
+ hasPublicKey = False
+ for arg in ptArgs:
+ if 'public-key' in arg:
+ hasPublicKey = True
+
+ self.assertTrue(hasPublicKey,
+ "obfs4 bridge line is missing 'public-key' PT arg.")
+
+ def test_get_obfs4_ipv4_nodeid(self):
+ """Ask for obfs4 bridges and check that there is an 'node-id' PT
+ argument in the bridge lines.
+ """
+ if os.environ.get("CI"):
+ if not self.pid or not processExists(self.pid):
+ raise FailTest("Could not start BridgeDB process on CI server!")
+ if not self.pid or not processExists(self.pid):
+ raise SkipTest("Can't run test: no BridgeDB process running.")
+
+ self.openBrowser()
+ self.goToOptionsPage()
+
+ PT = 'obfs4'
+
+ try:
+ soup = self.submitOptions(transport=PT, ipv6=False,
+ captchaResponse=CAPTCHA_RESPONSE)
+ except ValueError as error:
+ if 'non-disabled' in str(error):
+ raise SkipTest("Pluggable Transport obfs4 is currently disabled.")
+
+ bridges = self.getBridgeLinesFromSoup(soup, fieldsPerBridge=6)
+ for bridge in bridges:
+ ptArgs = bridge[-3:]
+ hasNodeID = False
+ for arg in ptArgs:
+ if 'node-id' in arg:
+ hasNodeID = True
+
+ self.assertTrue(hasNodeID,
+ "obfs4 bridge line is missing 'node-id' PT arg.")
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits