diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-02-16 09:40:56 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-02-16 09:40:56 -0500 |
commit | 31be66ea5ae243644f79d7f8a7d728cd9537c79d (patch) | |
tree | f16567e3702a705a465fbfea087eda1fef71eb2e /src/test/test_controller.c | |
parent | 832d4636f5e05cd4e500b590749ca6bf9e9c10cd (diff) | |
parent | fc58c37e334fec71a204b7b0787d347b647618b8 (diff) | |
download | tor-31be66ea5ae243644f79d7f8a7d728cd9537c79d.tar.gz tor-31be66ea5ae243644f79d7f8a7d728cd9537c79d.zip |
Merge remote-tracking branch 'meejah/ticket-21329-onions-current'
Diffstat (limited to 'src/test/test_controller.c')
-rw-r--r-- | src/test/test_controller.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/test_controller.c b/src/test/test_controller.c index d9c0a1eaac..fc63d837f3 100644 --- a/src/test/test_controller.c +++ b/src/test/test_controller.c @@ -109,6 +109,44 @@ test_add_onion_helper_keyarg(void *arg) } static void +test_getinfo_helper_onion(void *arg) +{ + (void)arg; + control_connection_t dummy; + /* Get results out */ + char *answer = NULL; + const char *errmsg = NULL; + char *service_id = NULL; + int rt = 0; + + dummy.ephemeral_onion_services = NULL; + + /* successfully get an empty answer */ + rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg); + tt_assert(rt == 0); + tt_str_op(answer, OP_EQ, ""); + tor_free(answer); + + /* successfully get an empty answer */ + rt = getinfo_helper_onions(&dummy, "onions/detached", &answer, &errmsg); + tt_assert(rt == 0); + tt_str_op(answer, OP_EQ, ""); + tor_free(answer); + + /* get an answer for one onion service */ + service_id = tor_strdup("dummy_onion_id"); + dummy.ephemeral_onion_services = smartlist_new(); + smartlist_add(dummy.ephemeral_onion_services, service_id); + rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg); + tt_assert(rt == 0); + tt_str_op(answer, OP_EQ, "dummy_onion_id"); + + done: + tor_free(answer); + tor_free(service_id); +} + +static void test_rend_service_parse_port_config(void *arg) { const char *sep = ","; @@ -1332,6 +1370,7 @@ test_download_status_bridge(void *arg) struct testcase_t controller_tests[] = { { "add_onion_helper_keyarg", test_add_onion_helper_keyarg, 0, NULL, NULL }, + { "getinfo_helper_onion", test_getinfo_helper_onion, 0, NULL, NULL }, { "rend_service_parse_port_config", test_rend_service_parse_port_config, 0, NULL, NULL }, { "add_onion_helper_clientauth", test_add_onion_helper_clientauth, 0, NULL, |