Skip to content

Commit

Permalink
Merge branch 'develop' into fix/9380-stem_r7
Browse files Browse the repository at this point in the history
  • Loading branch information
isislovecruft committed Dec 28, 2014
2 parents 28981fc + 3972bfa commit 08daf29
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Expand Up @@ -55,6 +55,11 @@ before_script:
- sed -r -i -e "s/(EMAIL_DOMAINS)(.*)(])/\1\2\, '127.0.0.1']/" run/bridgedb.conf
# Change EMAIL_SMTP_PORT to 2525:
- sed -r -i -e "s/(EMAIL_SMTP_PORT = )([1-9]{2,5})/\12525/" run/bridgedb.conf
# Enable plaintext HTTP distribution, otherwise the mechanize-based tests in
# test_https.py will fail with CERTIFICATE_VERIFY_FAILED because urllib2
# won't recognize ourt self-signed certificate:
- sed -r -i -e "s/(HTTP_UNENCRYPTED_BIND_IP = )(None)/\1'127.0.0.1'/" run/bridgedb.conf
- sed -r -i -e "s/(HTTP_UNENCRYPTED_PORT = )(None)/\16788/" run/bridgedb.conf
- leekspin -n 100
- cp -t run networkstatus-bridges cached-extrainfo* bridge-descriptors
- ./scripts/make-ssl-cert
Expand Down
78 changes: 55 additions & 23 deletions lib/bridgedb/test/test_https.py
Expand Up @@ -35,7 +35,7 @@
from bridgedb.test.util import processExists
from bridgedb.test.util import getBridgeDBPID

HTTPS_ROOT = 'https://127.0.0.1:6789'
HTTP_ROOT = 'http://127.0.0.1:6788'
CAPTCHA_RESPONSE = 'Tvx74Pmy'


Expand All @@ -56,31 +56,31 @@ def openBrowser(self):
self.br = mechanize.Browser()
# prevents 'HTTP Error 403: request disallowed by robots.txt'
self.br.set_handle_robots(False)
self.br.open(HTTPS_ROOT)
self.br.open(HTTP_ROOT)

# -------------- Home/Root page
self.assertTrue(self.br.viewing_html())
self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
self.assertEquals(self.br.response().geturl(), HTTP_ROOT)
self.assertEquals(self.br.title(), "BridgeDB")
return self.br

def goToOptionsPage(self):
# check that we are on the root page
self.assertTrue(self.br.viewing_html())
self.assertEquals(self.br.response().geturl(), HTTPS_ROOT)
self.assertEquals(self.br.response().geturl(), HTTP_ROOT)

# follow the link with the word 'bridges' in it.
# Could also use: text='bridges'
# Could also use: url='/options'
self.br.follow_link(text_regex='bridges')

# ------------- Options
self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
self.assertEquals(self.br.response().geturl(), HTTP_ROOT + "/options")
return self.br

def submitOptions(self, transport, ipv6, captchaResponse):
# check that we are on the options page
self.assertEquals(self.br.response().geturl(), HTTPS_ROOT + "/options")
self.assertEquals(self.br.response().geturl(), HTTP_ROOT + "/options")

# At this point, we'd like to be able to set some values in
# the 'advancedOptions' form. Unfortunately the HTML form
Expand All @@ -97,7 +97,7 @@ def submitOptions(self, transport, ipv6, captchaResponse):
self.br.submit()

# ------------- Captcha
EXPECTED_URL = HTTPS_ROOT + "/bridges?transport=%s" % transport
EXPECTED_URL = HTTP_ROOT + "/bridges?transport=%s" % transport
if ipv6:
EXPECTED_URL += "&ipv6=yes"
self.assertEquals(self.br.response().geturl(), EXPECTED_URL)
Expand Down Expand Up @@ -148,8 +148,12 @@ def test_get_obfs2_ipv4(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand All @@ -166,8 +170,12 @@ def test_get_obfs3_ipv4(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand All @@ -184,8 +192,12 @@ def test_get_vanilla_ipv4(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand All @@ -202,8 +214,12 @@ def test_get_scramblesuit_ipv4(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand All @@ -229,8 +245,12 @@ def test_get_obfs4_ipv4(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand Down Expand Up @@ -260,8 +280,12 @@ def test_get_obfs4_ipv4_iatmode(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand Down Expand Up @@ -293,8 +317,12 @@ def test_get_obfs4_ipv4_publickey(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand Down Expand Up @@ -326,8 +354,12 @@ def test_get_obfs4_ipv4_nodeid(self):
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.")
else:
raise SkipTest(("The mechanize tests cannot handle self-signed "
"TLS certificates, and thus require opening "
"another port for running a plaintext HTTP-only "
"BridgeDB webserver. Because of this, these tests "
"are only run on CI servers."))

self.openBrowser()
self.goToOptionsPage()
Expand Down

0 comments on commit 08daf29

Please sign in to comment.