[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] test_get_exit_policy failed if we get a public address
commit a0e13fbcc8fd8e0678b7906329d11e7f567839d1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Jan 16 09:09:06 2013 -0800
test_get_exit_policy failed if we get a public address
I forgot to account for the exit policy including a 'reject [public_addr]:*'
entry. This is a bit of a pain both because it's dynamic, and because it may or
may not be included at all. Accounting for this by just checking the policy
prefix and suffix instead.
---
test/integ/control/controller.py | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 8b75c6f..4d39a8b 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -264,6 +264,7 @@ class TestController(unittest.TestCase):
'reject 192.168.0.0/16:*',
'reject 10.0.0.0/8:*',
'reject 172.16.0.0/12:*',
+ # this is where 'reject [public_addr]:*' may or may not be
'reject *:25',
'reject *:119',
'reject *:135-139',
@@ -280,7 +281,17 @@ class TestController(unittest.TestCase):
runner = test.runner.get_runner()
with runner.get_tor_controller() as controller:
- self.assertEqual(expected, controller.get_exit_policy())
+ # We can't simply compare the policies because the tor policy may or may
+ # not have a reject entry for our public address. Hence, stripping it
+ # from the policy's string, then comparing those.
+
+ policy_str = str(controller.get_exit_policy())
+
+ public_addr_start = policy_str.find('reject 172.16.0.0/12:*') + 22
+ public_addr_end = policy_str.find(', reject *:25')
+
+ policy_str = policy_str[:public_addr_start] + policy_str[public_addr_end:]
+ self.assertEqual(str(expected), policy_str)
def test_authenticate(self):
"""
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits