summaryrefslogtreecommitdiff
path: root/src/test/test.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2010-02-03 12:45:27 +0100
committerSebastian Hahn <sebastian@torproject.org>2010-02-04 00:06:56 +0100
commit82a5fbafab956de6fffc3c583a874830157d906d (patch)
treeb6e714c9d85ff11d259e59203a2c64934c2306b8 /src/test/test.c
parent7d5d4f9f0385a8594bf363bee2392e8b055499fb (diff)
downloadtor-82a5fbafab956de6fffc3c583a874830157d906d.tar.gz
tor-82a5fbafab956de6fffc3c583a874830157d906d.zip
New unit test, testing for b0red's exit policy
Diffstat (limited to 'src/test/test.c')
-rw-r--r--src/test/test.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/test/test.c b/src/test/test.c
index 7d836019da..e1f1d40cd4 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -648,7 +648,7 @@ test_policies(void)
{
int i;
smartlist_t *policy = NULL, *policy2 = NULL, *policy3 = NULL,
- *policy4 = NULL;
+ *policy4 = NULL, *policy5 = NULL;
addr_policy_t *p;
tor_addr_t tar;
config_line_t line;
@@ -675,7 +675,6 @@ test_policies(void)
test_assert(ADDR_POLICY_REJECTED ==
compare_addr_to_addr_policy(0xc0a80102, 2, policy));
- policy2 = NULL;
test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1, NULL, 1));
test_assert(policy2);
@@ -695,11 +694,45 @@ test_policies(void)
test_assert(p != NULL);
smartlist_add(policy4, p);
+ policy5 = smartlist_create();
+
+ p = router_parse_addr_policy_item_from_string("reject 0.0.0.0/8:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 169.254.0.0/16:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 127.0.0.0/8:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 10.0.0.0/8:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 172.16.0.0/12:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject 80.190.250.90:*",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject *:1-65534",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("reject *:65535",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+ p = router_parse_addr_policy_item_from_string("accept *:1-65535",-1);
+ test_assert(p != NULL);
+ smartlist_add(policy5, p);
+
test_assert(!exit_policy_is_general_exit(policy));
test_assert(exit_policy_is_general_exit(policy2));
test_assert(!exit_policy_is_general_exit(NULL));
test_assert(!exit_policy_is_general_exit(policy3));
test_assert(!exit_policy_is_general_exit(policy4));
+ test_assert(!exit_policy_is_general_exit(policy5));
test_assert(cmp_addr_policies(policy, policy2));
test_assert(cmp_addr_policies(policy, NULL));
@@ -813,6 +846,7 @@ test_policies(void)
addr_policy_list_free(policy2);
addr_policy_list_free(policy3);
addr_policy_list_free(policy4);
+ addr_policy_list_free(policy5);
tor_free(policy_str);
if (sm) {
SMARTLIST_FOREACH(sm, char *, s, tor_free(s));