From: James Coglan Date: Wed, 19 Jun 2024 11:01:06 +0000 (+0100) Subject: resolved: tests for dns_cache_put() for NXDOMAIN with no SOA X-Git-Tag: v257-rc1~832^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1074c9001da609f585adc1cbbf0ee2130b9aec35;p=thirdparty%2Fsystemd.git resolved: tests for dns_cache_put() for NXDOMAIN with no SOA --- diff --git a/src/resolve/test-dns-cache.c b/src/resolve/test-dns-cache.c index e5efd540ace..3411bb55fae 100644 --- a/src/resolve/test-dns-cache.c +++ b/src/resolve/test-dns-cache.c @@ -352,6 +352,18 @@ TEST(dns_a_nxdomain_is_cached) { ASSERT_FALSE(dns_cache_is_empty(&cache)); } +TEST(dns_a_nxdomain_no_soa_not_cached) { + _cleanup_(dns_cache_unrefp) DnsCache cache = new_cache(); + _cleanup_(put_args_unrefp) PutArgs put_args = mk_put_args(); + + put_args.key = dns_resource_key_new(DNS_CLASS_IN, DNS_TYPE_A, "www.example.com"); + ASSERT_NOT_NULL(put_args.key); + put_args.rcode = DNS_RCODE_NXDOMAIN; + + ASSERT_OK(cache_put(&cache, &put_args)); + ASSERT_TRUE(dns_cache_is_empty(&cache)); +} + TEST(dns_a_nxdomain_any_class_is_not_cached) { _cleanup_(dns_cache_unrefp) DnsCache cache = new_cache(); _cleanup_(put_args_unrefp) PutArgs put_args = mk_put_args();