[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add test for checking the failure of the traceroute method



commit e63048bbe3e45ce597b80b8f7f7ac5de24557a54
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Fri Mar 15 16:01:27 2013 +0100

    Add test for checking the failure of the traceroute method
    
    Should raise an error when run as non root.
---
 ooni/errors.py         |    3 ++-
 ooni/geoip.py          |    4 ++--
 ooni/utils/__init__.py |    2 ++
 tests/test_geoip.py    |    6 +++---
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/ooni/errors.py b/ooni/errors.py
index 6b23727..62fcf93 100644
--- a/ooni/errors.py
+++ b/ooni/errors.py
@@ -14,7 +14,6 @@ from txsocksx.errors import HostUnreachable, ConnectionRefused
 from txsocksx.errors import TTLExpired, CommandNotSupported
 
 from socket import gaierror
-from ooni.utils import log
 def handleAllFailures(failure):
     """
     Here we make sure to trap all the failures that are supported by the
@@ -44,6 +43,8 @@ def failureToString(failure):
 
         A string representing the HTTP response error message.
     """
+    from ooni.utils import log
+
     string = None
     if isinstance(failure.value, ConnectionRefusedError):
         log.err("Connection refused. The backend may be down")
diff --git a/ooni/geoip.py b/ooni/geoip.py
index 55c4fa4..e6a221b 100644
--- a/ooni/geoip.py
+++ b/ooni/geoip.py
@@ -7,8 +7,8 @@ from twisted.web import client, http_headers
 from ooni.utils.net import userAgents, BodyReceiver
 from twisted.internet import reactor, defer, protocol
 
-from ooni.utils import log, net
-from ooni import config
+from ooni.utils import log, net, checkForRoot
+from ooni import config, errors
 
 try:
     import pygeoip
diff --git a/ooni/utils/__init__.py b/ooni/utils/__init__.py
index 340693b..b039c8a 100644
--- a/ooni/utils/__init__.py
+++ b/ooni/utils/__init__.py
@@ -6,6 +6,8 @@ import yaml
 import imp
 import os
 
+from ooni import errors
+
 class Storage(dict):
     """
     A Storage object is like a dictionary except `obj.foo` can be used
diff --git a/tests/test_geoip.py b/tests/test_geoip.py
index a4ad767..443d262 100644
--- a/tests/test_geoip.py
+++ b/tests/test_geoip.py
@@ -4,6 +4,7 @@ from twisted.trial import unittest
 from twisted.python.filepath import FilePath
 from twisted.protocols.policies import WrappingFactory
 
+from ooni import errors
 from ooni.geoip import ProbeIP, MaxMindGeoIP, TorProjectGeoIP
 from ooni.geoip import UbuntuGeoIP, HTTPGeoIPLookupper, IPToLocation
 
@@ -24,7 +25,6 @@ class MaxMindGeoIPResource(resource.Resource):
 
 class TorProjectGeoIPResource(resource.Resource):
     def render(self, request):
-
         return """
         Your IP address appears to be: <b>127.0.0.1</b>
         """
@@ -98,8 +98,8 @@ class TestProbeIP(GeoIPBaseTest):
             self.assertEqual(self.probe_ip.address, '127.0.0.1')
         return d
 
-    def test_ask_traceroute_service(self):
-        pass
+    def test_fail_traceroute_service(self):
+        self.assertRaises(errors.InsufficientPrivileges, self.probe_ip.askTraceroute)
 
     def test_ask_tor(self):
         pass



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits