aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2024-06-24 17:23:20 -0400
committerNick Mathewson <nickm@torproject.org>2024-06-26 11:42:36 -0400
commit71ca75cb199d4a925fc29e938fd5f013cba21049 (patch)
treefa650d7d9985a90a3c91571d699ef22062fcb477 /src
parent48c1bebd9ee9ad2aa3e6071038d3d9299b66ff0b (diff)
downloadtor-71ca75cb199d4a925fc29e938fd5f013cba21049.tar.gz
tor-71ca75cb199d4a925fc29e938fd5f013cba21049.zip
Add a test for a microdesc with no onion key.
Diffstat (limited to 'src')
-rw-r--r--src/test/test_microdesc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 315a38f257..1209811fb9 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -760,6 +760,35 @@ test_md_parse_id_ed25519(void *arg)
teardown_capture_of_logs();
}
+static void
+test_md_parse_no_onion_key(void *arg)
+{
+ (void)arg;
+
+ /* A correct MD with no onion key. */
+ const char GOOD_MD[] =
+ "onion-key\n"
+ "ntor-onion-key AppBt6CSeb1kKid/36ototmFA24ddfW5JpjWPLuoJgs=\n"
+ "id ed25519 VGhpcyBpc24ndCBhY3R1YWxseSBhIHB1YmxpYyBrZXk\n";
+
+ smartlist_t *mds = NULL;
+
+ mds = microdescs_parse_from_string(GOOD_MD,
+ NULL, 1, SAVED_NOWHERE, NULL);
+ tt_assert(mds);
+ tt_int_op(smartlist_len(mds), OP_EQ, 1);
+ const microdesc_t *md = smartlist_get(mds, 0);
+ tt_mem_op(md->ed25519_identity_pkey, OP_EQ,
+ "This isn't actually a public key", ED25519_PUBKEY_LEN);
+
+ done:
+ if (mds) {
+ SMARTLIST_FOREACH(mds, microdesc_t *, m, microdesc_free(m));
+ smartlist_free(mds);
+ }
+ teardown_capture_of_logs();
+}
+
static int mock_rgsbd_called = 0;
static routerstatus_t *mock_rgsbd_val_a = NULL;
static routerstatus_t *mock_rgsbd_val_b = NULL;
@@ -894,6 +923,7 @@ struct testcase_t microdesc_tests[] = {
{ "generate", test_md_generate, 0, NULL, NULL },
{ "parse", test_md_parse, 0, NULL, NULL },
{ "parse_id_ed25519", test_md_parse_id_ed25519, 0, NULL, NULL },
+ { "parse_no_onion_key", test_md_parse_no_onion_key, 0, NULL, NULL },
{ "reject_cache", test_md_reject_cache, TT_FORK, NULL, NULL },
{ "corrupt_desc", test_md_corrupt_desc, TT_FORK, NULL, NULL },
END_OF_TESTCASES