diff --git a/regress/unittests/hostkeys/test_iterate.c b/regress/unittests/hostkeys/test_iterate.c index 5904121ef..a5b17d7e4 100644 --- a/regress/unittests/hostkeys/test_iterate.c +++ b/regress/unittests/hostkeys/test_iterate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_iterate.c,v 1.6 2018/07/16 03:09:59 djm Exp $ */ +/* $OpenBSD: test_iterate.c,v 1.7 2020/12/21 01:31:06 djm Exp $ */ /* * Regress test for hostfile.h hostkeys_foreach() * @@ -194,6 +194,7 @@ struct expected expected_full[] = { KEY_UNSPEC, /* key type */ NULL, /* deserialised key */ NULL, /* comment */ + 0, /* note */ } }, { "dsa_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -207,6 +208,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #1", + 0, } }, { "ecdsa_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -220,6 +222,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #1", + 0, } }, { "ed25519_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -233,6 +236,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #1", + 0, } }, { "rsa_1.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -246,6 +250,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #1", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -259,6 +264,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -272,6 +278,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { "dsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -285,6 +292,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #2", + 0, } }, { "ecdsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -298,6 +306,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #2", + 0, } }, { "ed25519_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -311,6 +320,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #2", + 0, } }, { "rsa_2.pub" , -1, -1, HKF_MATCH_HOST, 0, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -324,6 +334,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #2", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -337,6 +348,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -350,6 +362,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { "dsa_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -363,6 +376,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #3", + 0, } }, { "ecdsa_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -376,6 +390,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #3", + 0, } }, { "ed25519_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -389,6 +404,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #3", + 0, } }, { "rsa_3.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, HKF_MATCH_IP, HKF_MATCH_IP, -1, { NULL, @@ -402,6 +418,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #3", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -415,6 +432,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -428,6 +446,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { "dsa_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, { NULL, @@ -441,6 +460,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #5", + 0, } }, { "ecdsa_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, { NULL, @@ -454,6 +474,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #5", + 0, } }, { "ed25519_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, { NULL, @@ -467,6 +488,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #5", + 0, } }, { "rsa_5.pub" , -1, -1, 0, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, -1, { NULL, @@ -480,6 +502,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #5", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -493,6 +516,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, /* * The next series have each key listed multiple times, as the @@ -511,6 +535,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #6", + 0, } }, { "dsa_6.pub" , -1, -1, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, 0, -1, { NULL, @@ -524,6 +549,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #6", + 0, } }, { "dsa_6.pub" , -1, -1, 0, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, -1, { NULL, @@ -537,6 +563,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #6", + 0, } }, { "ecdsa_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, { NULL, @@ -550,6 +577,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #6", + 0, } }, { "ecdsa_6.pub" , -1, -1, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, 0, -1, { NULL, @@ -563,6 +591,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #6", + 0, } }, { "ecdsa_6.pub" , -1, -1, 0, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, -1, { NULL, @@ -576,6 +605,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #6", + 0, } }, { "ed25519_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, { NULL, @@ -589,6 +619,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #6", + 0, } }, { "ed25519_6.pub" , -1, -1, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, 0, -1, { NULL, @@ -602,6 +633,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #6", + 0, } }, { "ed25519_6.pub" , -1, -1, 0, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, -1, { NULL, @@ -615,6 +647,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #6", + 0, } }, { "rsa_6.pub" , -1, -1, HKF_MATCH_HOST|HKF_MATCH_HOST_HASHED, 0, 0, 0, -1, { NULL, @@ -628,6 +661,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #6", + 0, } }, { "rsa_6.pub" , -1, -1, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, 0, -1, { NULL, @@ -641,6 +675,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #6", + 0, } }, { "rsa_6.pub" , -1, -1, 0, 0, 0, HKF_MATCH_IP|HKF_MATCH_IP_HASHED, -1, { NULL, @@ -654,6 +689,7 @@ struct expected expected_full[] = { KEY_RSA, NULL, /* filled at runtime */ "RSA #6", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -667,6 +703,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -680,6 +717,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -693,6 +731,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { "ed25519_4.pub" , -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -706,6 +745,7 @@ struct expected expected_full[] = { KEY_ED25519, NULL, /* filled at runtime */ "ED25519 #4", + 0, } }, { "ecdsa_4.pub" , -1, -1, HKF_MATCH_HOST, 0, 0, 0, -1, { NULL, @@ -719,6 +759,7 @@ struct expected expected_full[] = { KEY_ECDSA, NULL, /* filled at runtime */ "ECDSA #4", + 0, } }, { "dsa_4.pub" , -1, -1, HKF_MATCH_HOST, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -732,6 +773,7 @@ struct expected expected_full[] = { KEY_DSA, NULL, /* filled at runtime */ "DSA #4", + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -745,6 +787,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -758,6 +801,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, 0, 0, 0, -1, { NULL, @@ -771,6 +815,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -784,6 +829,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, HKF_MATCH_HOST, 0, 0, 0, -1, { NULL, @@ -797,6 +843,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -810,6 +857,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, NULL, + 0, } }, { NULL, -1, -1, 0, HKF_MATCH_HOST, 0, 0, -1, { NULL, @@ -823,6 +871,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, /* filled at runtime */ NULL, + 0, } }, { NULL, HKF_STATUS_OK, KEY_RSA, HKF_MATCH_HOST, 0, 0, 0, -1, { NULL, @@ -836,6 +885,7 @@ struct expected expected_full[] = { KEY_UNSPEC, NULL, /* filled at runtime */ NULL, + 0, } }, }; @@ -853,7 +903,7 @@ test_iterate(void) ctx.flags = HKF_WANT_PARSE_KEY; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, NULL, NULL, ctx.flags), 0); + check, &ctx, NULL, NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -864,7 +914,7 @@ test_iterate(void) ctx.flags = 0; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, NULL, NULL, ctx.flags), 0); + check, &ctx, NULL, NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -876,7 +926,7 @@ test_iterate(void) ctx.match_host_p = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "prometheus.example.com", NULL, ctx.flags), 0); + check, &ctx, "prometheus.example.com", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -888,7 +938,7 @@ test_iterate(void) ctx.match_host_s = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "sisyphus.example.com", NULL, ctx.flags), 0); + check, &ctx, "sisyphus.example.com", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -900,7 +950,7 @@ test_iterate(void) ctx.match_host_p = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "prometheus.example.com", NULL, ctx.flags), 0); + check, &ctx, "prometheus.example.com", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -912,7 +962,7 @@ test_iterate(void) ctx.match_host_s = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "sisyphus.example.com", NULL, ctx.flags), 0); + check, &ctx, "sisyphus.example.com", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -923,7 +973,7 @@ test_iterate(void) ctx.flags = 0; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "actaeon.example.org", NULL, ctx.flags), 0); + check, &ctx, "actaeon.example.org", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -934,7 +984,7 @@ test_iterate(void) ctx.flags = HKF_WANT_MATCH; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "actaeon.example.org", NULL, ctx.flags), 0); + check, &ctx, "actaeon.example.org", NULL, ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -946,7 +996,7 @@ test_iterate(void) ctx.match_ipv4 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -958,7 +1008,8 @@ test_iterate(void) ctx.match_ipv6 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "2001:db8::1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "2001:db8::1", + ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -970,7 +1021,7 @@ test_iterate(void) ctx.match_ipv4 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "192.0.2.1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -982,7 +1033,8 @@ test_iterate(void) ctx.match_ipv6 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "2001:db8::1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "2001:db8::1", + ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -993,7 +1045,8 @@ test_iterate(void) ctx.flags = 0; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "192.168.0.1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "192.168.0.1", + ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -1004,7 +1057,7 @@ test_iterate(void) ctx.flags = HKF_WANT_MATCH; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "tiresias.example.org", "::1", ctx.flags), 0); + check, &ctx, "tiresias.example.org", "::1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -1017,7 +1070,7 @@ test_iterate(void) ctx.match_ipv4 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags), 0); + check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -1031,7 +1084,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "prometheus.example.com", - "2001:db8::1", ctx.flags), 0); + "2001:db8::1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -1044,7 +1097,7 @@ test_iterate(void) ctx.match_ipv4 = 1; prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), - check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags), 0); + check, &ctx, "sisyphus.example.com", "192.0.2.1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); @@ -1058,7 +1111,7 @@ test_iterate(void) prepare_expected(expected_full, ctx.nexpected); ASSERT_INT_EQ(hostkeys_foreach(test_data_file("known_hosts"), check, &ctx, "prometheus.example.com", - "2001:db8::1", ctx.flags), 0); + "2001:db8::1", ctx.flags, 0), 0); cleanup_expected(expected_full, ctx.nexpected); TEST_DONE(); }