aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-11-18 14:32:13 +1100
committerNick Mathewson <nickm@torproject.org>2016-12-01 09:44:53 -0500
commit91abd60cad2fa3ca9f85fe20956f5f6a336c9c67 (patch)
treed59b13bcc25d8bf12b8b58662c80f85869150d53 /src/test/test_hs.c
parent1d1d37bbc672f28ac481511df3a5dc4c9c732ed0 (diff)
downloadtor-91abd60cad2fa3ca9f85fe20956f5f6a336c9c67.tar.gz
tor-91abd60cad2fa3ca9f85fe20956f5f6a336c9c67.zip
Update unit tests for 20484, 20529
Add extra logging and extra validity checks for hidden services.
Diffstat (limited to 'src/test/test_hs.c')
-rw-r--r--src/test/test_hs.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/test/test_hs.c b/src/test/test_hs.c
index b42bc590c0..e1f39b1f7a 100644
--- a/src/test/test_hs.c
+++ b/src/test/test_hs.c
@@ -571,8 +571,28 @@ test_single_onion_poisoning(void *arg)
service_1->directory = dir1;
service_2->directory = dir2;
+ /* The services own the directory pointers now */
dir1 = dir2 = NULL;
- smartlist_add(services, service_1);
+ /* Add port to service 1 */
+ service_1->ports = smartlist_new();
+ service_2->ports = smartlist_new();
+ char *err_msg = NULL;
+ rend_service_port_config_t *port1 = rend_service_parse_port_config("80", " ",
+ &err_msg);
+ tt_assert(port1);
+ tt_assert(!err_msg);
+ smartlist_add(service_1->ports, port1);
+
+ rend_service_port_config_t *port2 = rend_service_parse_port_config("90", " ",
+ &err_msg);
+ /* Add port to service 2 */
+ tt_assert(port2);
+ tt_assert(!err_msg);
+ smartlist_add(service_2->ports, port2);
+
+ /* Add the first service */
+ ret = rend_service_check_dir_and_add(services, mock_options, service_1, 0);
+ tt_assert(ret == 0);
/* But don't add the second service yet. */
/* Service directories, but no previous keys, no problem! */
@@ -636,7 +656,7 @@ test_single_onion_poisoning(void *arg)
tt_assert(ret == 0);
/* Now add the second service: it has no key and no poison file */
- smartlist_add(services, service_2);
+ ret = rend_service_check_dir_and_add(services, mock_options, service_2, 0);
/* A new service, and an existing poisoned service. Not ok. */
mock_options->HiddenServiceSingleHopMode = 0;
@@ -698,13 +718,11 @@ test_single_onion_poisoning(void *arg)
done:
/* The test harness deletes the directories at exit */
+ smartlist_free(services);
rend_service_free(service_1);
rend_service_free(service_2);
- smartlist_free(services);
UNMOCK(get_options);
tor_free(mock_options->DataDirectory);
- tor_free(dir1);
- tor_free(dir2);
}
struct testcase_t hs_tests[] = {