]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: tests for dns_cache_put() for NXDOMAIN with no SOA
authorJames Coglan <james@neighbourhood.ie>
Wed, 19 Jun 2024 11:01:06 +0000 (12:01 +0100)
committerJames Coglan <james@neighbourhood.ie>
Tue, 23 Jul 2024 13:08:31 +0000 (14:08 +0100)
src/resolve/test-dns-cache.c

index e5efd540ace2c87b127ec3898d24f9924e3e42fe..3411bb55faecfdd035fda86c9e4a03a4c772d67f 100644 (file)
@@ -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();