From: Aram Sargsyan Date: Tue, 14 Jul 2026 11:25:09 +0000 (+0000) Subject: Add a new check in the tsig unit test X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f5cb4f645f01d7f5860a47596d766fe4c2603660;p=thirdparty%2Fbind9.git Add a new check in the tsig unit test The new check creates more TSIG keys than the maximum allowed number, and expectes that all the newly created keys are findable just after they were created. I.e., when full, the newly created key should not evicted. --- diff --git a/tests/dns/tsig_test.c b/tests/dns/tsig_test.c index 58a9f4adff2..39336ffcf3e 100644 --- a/tests/dns/tsig_test.c +++ b/tests/dns/tsig_test.c @@ -522,6 +522,45 @@ ISC_RUN_TEST_IMPL(tsig_delete) { tsig_delete(true); } +ISC_RUN_TEST_IMPL(tsig_maxkeys) { + dns_fixedname_t fkeyname; + dns_name_t *keyname = dns_fixedname_initname(&fkeyname); + dns_tsigkeyring_t *ring = NULL; + dns_tsigkeyring_create(isc_g_mctx, &ring); + assert_non_null(ring); + + /* + * Insert more than the the maximum allowed generated keys. When full, + * the last created key should be findable, i.e. not evicted. + */ + for (size_t i = 0; i < DNS_TSIG_MAXGENERATEDKEYS + 1; i++) { + char str[32]; + isc_result_t result; + + snprintf(str, sizeof(str), "tsig-key-%zu", i); + result = dns_name_fromstring(keyname, str, dns_rootname, 0, + NULL); + assert_int_equal(result, ISC_R_SUCCESS); + + /* Add a new key. */ + dns_tsigkey_t *key = NULL; + result = dns_tsigkey_createfromkey(keyname, DST_ALG_HMACSHA256, + NULL, true, false, NULL, 0, + 0, isc_g_mctx, &key); + assert_int_equal(result, ISC_R_SUCCESS); + result = dns_tsigkeyring_add(ring, key); + assert_int_equal(result, ISC_R_SUCCESS); + dns_tsigkey_detach(&key); + + /* Find the newly created key. */ + result = dns_tsigkey_find(&key, keyname, NULL, ring); + assert_int_equal(result, ISC_R_SUCCESS); + dns_tsigkey_detach(&key); + } + + dns_tsigkeyring_detach(&ring); +} + /* Tests the dns__tsig_algvalid function */ ISC_RUN_TEST_IMPL(algvalid) { UNUSED(state); @@ -543,6 +582,7 @@ ISC_TEST_ENTRY(tsig_badsig) ISC_TEST_ENTRY(tsig_badtime) ISC_TEST_ENTRY(tsig_delete) ISC_TEST_ENTRY(tsig_tcp) +ISC_TEST_ENTRY(tsig_maxkeys) ISC_TEST_LIST_END ISC_TEST_MAIN