diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-06-01 13:21:03 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2017-08-19 16:42:26 +0300 |
commit | bce18a764252c66e605680e29a27ea30375a6db1 (patch) | |
tree | 579234b52e9c012d89ba1ed3d90051038a738c93 /src/test/test_hs_common.c | |
parent | 3e593f09addb210f1da39bd46f5fb904cac4e410 (diff) | |
download | tor-bce18a764252c66e605680e29a27ea30375a6db1.tar.gz tor-bce18a764252c66e605680e29a27ea30375a6db1.zip |
prop224: Refactor parse_extended_hostname() to parse v3 addrs.
We need this func so that we recognize SOCKS conns to v3 addresses.
- Also rename rend_valid_service_id() to rend_valid_v2_service_id()
- Also move parse_extended_hostname() tests to their own unittest, and
add a v3 address to the test as well.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_hs_common.c')
-rw-r--r-- | src/test/test_hs_common.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index c60deb2ab9..f7e8e2811f 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -14,6 +14,7 @@ #include "log_test_helpers.h" #include "hs_test_helpers.h" +#include "connection_edge.h" #include "hs_common.h" #include "hs_service.h" #include "config.h" @@ -696,6 +697,38 @@ test_disaster_srv(void *arg) ; } +static void +test_parse_extended_hostname(void *arg) +{ + (void) arg; + + char address1[] = "fooaddress.onion"; + char address2[] = "aaaaaaaaaaaaaaaa.onion"; + char address3[] = "fooaddress.exit"; + char address4[] = "www.torproject.org"; + char address5[] = "foo.abcdefghijklmnop.onion"; + char address6[] = "foo.bar.abcdefghijklmnop.onion"; + char address7[] = ".abcdefghijklmnop.onion"; + char address8[] = + "www.p3xnclpu4mu22dwaurjtsybyqk4xfjmcfz6z62yl24uwmhjatiwnlnad.onion"; + + tt_assert(BAD_HOSTNAME == parse_extended_hostname(address1)); + tt_assert(ONION_V2_HOSTNAME == parse_extended_hostname(address2)); + tt_str_op(address2,OP_EQ, "aaaaaaaaaaaaaaaa"); + tt_assert(EXIT_HOSTNAME == parse_extended_hostname(address3)); + tt_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4)); + tt_assert(ONION_V2_HOSTNAME == parse_extended_hostname(address5)); + tt_str_op(address5,OP_EQ, "abcdefghijklmnop"); + tt_assert(ONION_V2_HOSTNAME == parse_extended_hostname(address6)); + tt_str_op(address6,OP_EQ, "abcdefghijklmnop"); + tt_assert(BAD_HOSTNAME == parse_extended_hostname(address7)); + tt_assert(ONION_V3_HOSTNAME == parse_extended_hostname(address8)); + tt_str_op(address8, OP_EQ, + "p3xnclpu4mu22dwaurjtsybyqk4xfjmcfz6z62yl24uwmhjatiwnlnad"); + + done: ; +} + struct testcase_t hs_common_tests[] = { { "build_address", test_build_address, TT_FORK, NULL, NULL }, @@ -713,7 +746,10 @@ struct testcase_t hs_common_tests[] = { NULL, NULL }, { "desc_reupload_logic", test_desc_reupload_logic, TT_FORK, NULL, NULL }, - { "disaster_srv", test_disaster_srv, TT_FORK, NULL, NULL }, + { "disaster_srv", test_disaster_srv, TT_FORK, + NULL, NULL }, + { "parse_extended_hostname", test_parse_extended_hostname, TT_FORK, + NULL, NULL }, END_OF_TESTCASES }; |