summaryrefslogtreecommitdiff
path: root/src/test/test_controller.c
diff options
context:
space:
mode:
authorJohn Brooks <john.brooks@dereferenced.net>2015-04-13 21:08:31 -0600
committerNick Mathewson <nickm@torproject.org>2016-05-09 14:28:58 -0400
commitdcc11674db53cc89228ec2e8d49f30bdf6c9b8a3 (patch)
tree377e6122eaaa7733f18425d679658be442143228 /src/test/test_controller.c
parentd15354c73b08342f9c1d22917c80194380c75e2c (diff)
downloadtor-dcc11674db53cc89228ec2e8d49f30bdf6c9b8a3.tar.gz
tor-dcc11674db53cc89228ec2e8d49f30bdf6c9b8a3.zip
Add client auth for ADD_ONION services
Diffstat (limited to 'src/test/test_controller.c')
-rw-r--r--src/test/test_controller.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index b40825bb5d..2ab1c811a8 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -154,10 +154,61 @@ test_rend_service_parse_port_config(void *arg)
tor_free(err_msg);
}
+static void
+test_add_onion_helper_clientauth(void *arg)
+{
+ rend_authorized_client_t *client = NULL;
+ char *err_msg = NULL;
+ int created = 0;
+
+ (void)arg;
+
+ /* Test "ClientName" only. */
+ client = add_onion_helper_clientauth("alice", &created, &err_msg);
+ tt_assert(client);
+ tt_assert(created);
+ tt_assert(!err_msg);
+ rend_authorized_client_free(client);
+
+ /* Test "ClientName:Blob" */
+ client = add_onion_helper_clientauth("alice:475hGBHPlq7Mc0cRZitK/B",
+ &created, &err_msg);
+ tt_assert(client);
+ tt_assert(!created);
+ tt_assert(!err_msg);
+ rend_authorized_client_free(client);
+
+ /* Test invalid client names */
+ client = add_onion_helper_clientauth("no*asterisks*allowed", &created,
+ &err_msg);
+ tt_assert(!client);
+ tt_assert(err_msg);
+ tor_free(err_msg);
+
+ /* Test invalid auth cookie */
+ client = add_onion_helper_clientauth("alice:12345", &created, &err_msg);
+ tt_assert(!client);
+ tt_assert(err_msg);
+ tor_free(err_msg);
+
+ /* Test invalid syntax */
+ client = add_onion_helper_clientauth(":475hGBHPlq7Mc0cRZitK/B", &created,
+ &err_msg);
+ tt_assert(!client);
+ tt_assert(err_msg);
+ tor_free(err_msg);
+
+ done:
+ rend_authorized_client_free(client);
+ tor_free(err_msg);
+}
+
struct testcase_t controller_tests[] = {
{ "add_onion_helper_keyarg", test_add_onion_helper_keyarg, 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,
+ NULL },
END_OF_TESTCASES
};