diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/knot/semantic_check_data/dnskey_keytags.many | 30 | ||||
-rw-r--r-- | tests/knot/semantic_check_data/dnskey_keytags.more | 24 | ||||
-rw-r--r-- | tests/knot/test_semantic_check.in | 4 | ||||
-rw-r--r-- | tests/libknot/test_rrset.c | 42 | ||||
-rw-r--r-- | tests/libzscanner/data/57_SVCB.in | 6 | ||||
-rw-r--r-- | tests/libzscanner/data/57_SVCB.out | 16 |
6 files changed, 121 insertions, 1 deletions
diff --git a/tests/knot/semantic_check_data/dnskey_keytags.many b/tests/knot/semantic_check_data/dnskey_keytags.many new file mode 100644 index 0000000..efc87b6 --- /dev/null +++ b/tests/knot/semantic_check_data/dnskey_keytags.many @@ -0,0 +1,30 @@ +;; Zone dump (Knot DNS 3.4.dev0+1709028633.0c1de8c46) +example.com. 3600 SOA dns1.example.com. hostmaster.example.com. 2010111217 21600 3600 604800 86400 +example.com. 3600 NS dns1.example.com. +example.com. 3600 DNSKEY 256 3 13 Xw53weVKxFPqiBIzviMAZvRgdruTyHpHC3uYf9Twr9ug+cSyrYx4tteWUWPzsXgYnjATplJYY47KBMirTCR9BA== +example.com. 3600 DNSKEY 256 3 13 qvLsJ9NpDpzxzHg91N7Fj++5SU6H5DdAAGmAaS/FGYu9H93V1hfZ5a7QPrN5E8ZKhWWGc9Li/OULloYer3btZg== +example.com. 3600 DNSKEY 256 3 13 +qPQIbks9pY61AJkemnK89ly7IhjmdhiszwQAi3hpSybwMSWtp1LzrNna/nmX7DeDpanoZGljd8l2rjFBklYhg== +example.com. 3600 DNSKEY 257 3 13 0qemQB7NsmO+Q3EnIdMPfrlTMAJxxOAjrZVHKbtfmXmd9HUsjBOg8hI6o0h9kfMb/qM/OWJYq25C5nzwl1eJGw== +dns1.example.com. 3600 A 192.0.2.1 +;; DNSSEC signatures +example.com. 3600 RRSIG NS 13 2 3600 20440222113630 20240227100630 50687 example.com. Uc5BSG2ohqfkZaIfqa3JpsUBfv5av7j2xCd9AeGb0TyfdsTJeQPxbeSFtLCeeVt0YShGjxwUldnjxqOoZxKo9Q== +example.com. 3600 RRSIG NS 13 2 3600 20440222114545 20240227101545 50687 example.com. YTxdJfVKe4vExYay712yKVr1BTXV91/lN4yIo+NaBl/KcZUWwTgku4o4b7qQsprb6iIPueaBnbt2C6VpBXh0tw== +example.com. 3600 RRSIG NS 13 2 3600 20440222114918 20240227101918 50687 example.com. 5Tni3/OWhTSEd45fRemrnX90fpaXKg6oUnGyZ+eVqxmjfYSMDA1H0W8eTJXFGi4Tbrxn0uZeP+FzGlTvz9uj2A== +example.com. 3600 RRSIG SOA 13 2 3600 20440222115548 20240227102548 50687 example.com. DIZm9AnVxD3W3BdQ+XYY003wibKTtlesff2JJtOFqc18vLUcccG5JHfieClmTcFjQyPCVltK7sieaN5m4Deivw== +example.com. 3600 RRSIG SOA 13 2 3600 20440222115548 20240227102548 50687 example.com. h2WIMryLnmCyDr3/3lfh0UBLCGZH0RSTGN39d9dWmz2Ap2IEKdcEE6QG1pVxp23UNJo8IeawIR4Xw9emllZ2fQ== +example.com. 3600 RRSIG SOA 13 2 3600 20440222115548 20240227102548 50687 example.com. 2mEsdLT+UyNJJ5hA3Oo5ujJ0KZr/0G+Agrypl7a5ew9tZ07X7WCNw5D9orF7YlkX9TejTYijIUNWNksZyHnBfg== +example.com. 3600 RRSIG NSEC 13 2 3600 20440222113630 20240227100630 50687 example.com. akUd7/c8/sJTqB04KO3kQZwwb0i/7l8mvg10e7Somtc5nP5/gKsBpFDPGpvchZpVrlXME+eq+oRNfp3fQfBmvA== +example.com. 3600 RRSIG NSEC 13 2 3600 20440222114545 20240227101545 50687 example.com. QRn8TG6/7i15V7O+ktA3PQqlMqK8nq+4XKRCssW7tFtvZlkiIWBuwvXJVViby3bfc3+GmF+X2whJJSq3NQB2Ow== +example.com. 3600 RRSIG NSEC 13 2 3600 20440222114918 20240227101918 50687 example.com. 8rERTpgNiE11A//J4xf9t0jrECXiNoHvNZajdY8GzOkV3kCpMN9jkKw/Ppr6vkon+4CBHc7HuODQArIgfU6nUA== +example.com. 3600 RRSIG DNSKEY 13 2 3600 20440222115548 20240227102548 50687 example.com. HX2JTLzV6JLmb4SokV27+JVvejyA+FuifWaK96U2dSslvvXTWrAEqp/j3naJ0q9gjftUWUdKTOZ67FfsmH2XNg== +dns1.example.com. 3600 RRSIG A 13 3 3600 20440222113630 20240227100630 50687 example.com. Y8vvqbd55jo7zKx0uDVwaWScpGqti8sPXodjItsrN8gjA3d3A+7TVW71L9FSwww/Usl8cyXIC4ZUR5c7JIFNHQ== +dns1.example.com. 3600 RRSIG A 13 3 3600 20440222114545 20240227101545 50687 example.com. dGLOD3cxFqXoiDaMftaXGKUjK0EGloelABNLbto/+cUuxiBlwdMi9yskncK6kM4ncy1TsMM8SJXCYmbpD9lPlg== +dns1.example.com. 3600 RRSIG A 13 3 3600 20440222114918 20240227101918 50687 example.com. F2iOodkc/jF2ha5mmaEVwa4SMOtBxiipo8jqNqjiY1oXioIgdfxysSdmiY0x0IAddLhbMeUNlto3kHhK4fO5ew== +dns1.example.com. 3600 RRSIG NSEC 13 3 3600 20440222113630 20240227100630 50687 example.com. Opl4Clj6bRS/iTsJdEpJMX76XAGVt/OJQS3hRdpwDROdaskd69ENPPtdnOR0aNlG6NeMBXzH8HkMOIDv6k50kg== +dns1.example.com. 3600 RRSIG NSEC 13 3 3600 20440222114545 20240227101545 50687 example.com. wBH3KsAJkcuuO+73dUfTDGH5RnkFE8o6wfw905SV07K7G+2X4YY/SVkwNX0jp2JaQe1rWn0kvvqJSvOb/LMd1Q== +dns1.example.com. 3600 RRSIG NSEC 13 3 3600 20440222114918 20240227101918 50687 example.com. s6GL57MD/j0y+06EHspfjhp6raJW0+AoXsEIjojQJqfXyDTP1XgKQMeElB7q7oZK1Ks9aQ9mZrdo12D7yOPVkQ== +;; DNSSEC NSEC chain +example.com. 3600 NSEC dns1.example.com. NS SOA RRSIG NSEC DNSKEY +dns1.example.com. 3600 NSEC example.com. A RRSIG NSEC +;; Written 25 records +;; Time 2024-02-27 12:55:48 CET diff --git a/tests/knot/semantic_check_data/dnskey_keytags.more b/tests/knot/semantic_check_data/dnskey_keytags.more new file mode 100644 index 0000000..b6f5760 --- /dev/null +++ b/tests/knot/semantic_check_data/dnskey_keytags.more @@ -0,0 +1,24 @@ +;; Zone dump (Knot DNS 3.4.dev0+1709037013.b484eb414) +example.com. 3600 SOA dns1.example.com. hostmaster.example.com. 2010111215 21600 3600 604800 86400 +example.com. 3600 NS dns1.example.com. +example.com. 3600 DNSKEY 256 3 13 Xw53weVKxFPqiBIzviMAZvRgdruTyHpHC3uYf9Twr9ug+cSyrYx4tteWUWPzsXgYnjATplJYY47KBMirTCR9BA== +example.com. 3600 DNSKEY 256 3 13 qvLsJ9NpDpzxzHg91N7Fj++5SU6H5DdAAGmAaS/FGYu9H93V1hfZ5a7QPrN5E8ZKhWWGc9Li/OULloYer3btZg== +example.com. 3600 DNSKEY 257 3 13 0qemQB7NsmO+Q3EnIdMPfrlTMAJxxOAjrZVHKbtfmXmd9HUsjBOg8hI6o0h9kfMb/qM/OWJYq25C5nzwl1eJGw== +dns1.example.com. 3600 A 192.0.2.1 +;; DNSSEC signatures +example.com. 3600 RRSIG NS 13 2 3600 20241223152039 20240227135039 50687 example.com. +0LC6BlnPpDJoBc1siE+XPmyv589lY79MH1h2YwMtY6iEd35h2CeP6tH1l9y8kLabRCREyw0/DJaRsHNet6olQ== +example.com. 3600 RRSIG NS 13 2 3600 20440222113630 20240227100630 50687 example.com. Uc5BSG2ohqfkZaIfqa3JpsUBfv5av7j2xCd9AeGb0TyfdsTJeQPxbeSFtLCeeVt0YShGjxwUldnjxqOoZxKo9Q== +example.com. 3600 RRSIG SOA 13 2 3600 20241223152039 20240227135039 50687 example.com. baS1G2mzsLinOPmg3lqhLR/9kxJFzZnw07H0PzBBIcYGEe1myGg55+ZIJ+QR5cR13jqvHltRojL9bHWbFBCL5A== +example.com. 3600 RRSIG SOA 13 2 3600 20241223152039 20240227135039 50687 example.com. bfL8KJoz1sMRLx1MXATA5fLnNJDWtQkEugiHN1THyJUfm0oVQTfbVkrnFaUSwZHiovZ/s2rri1HNOdGnCm2wAA== +example.com. 3600 RRSIG NSEC 13 2 3600 20241223152039 20240227135039 50687 example.com. 9e8McGcJuWOtJ6mYlMOcktb1yDeNFDElLhmE3ULKSeUu+Dyyaye/rlK33qPptzXDoODQKG/0CCXRyz/nRgZ70g== +example.com. 3600 RRSIG NSEC 13 2 3600 20440222113630 20240227100630 50687 example.com. akUd7/c8/sJTqB04KO3kQZwwb0i/7l8mvg10e7Somtc5nP5/gKsBpFDPGpvchZpVrlXME+eq+oRNfp3fQfBmvA== +example.com. 3600 RRSIG DNSKEY 13 2 3600 20241223152039 20240227135039 50687 example.com. W9K24FgSjnUjv2lVyrC/ddZJfBMwkiu/NQsC2BpG2Sg69RUkI5FEnwZT7g1AfJEO+QWAqjNdZ/5iep+Lhpi3ow== +dns1.example.com. 3600 RRSIG A 13 3 3600 20241223152039 20240227135039 50687 example.com. JBBpxjsn+PETEDb//cbGfyaMuoOAuHcK6dX0MpJXTHl6WgNT05hFkfsW87BrG5VUv9Ffdg9wmECaiGQ1G4LXQA== +dns1.example.com. 3600 RRSIG A 13 3 3600 20440222113630 20240227100630 50687 example.com. Y8vvqbd55jo7zKx0uDVwaWScpGqti8sPXodjItsrN8gjA3d3A+7TVW71L9FSwww/Usl8cyXIC4ZUR5c7JIFNHQ== +dns1.example.com. 3600 RRSIG NSEC 13 3 3600 20241223152039 20240227135039 50687 example.com. Kn7GEREsUJqmgNyUKPhmlm1PRzIlhP2pORHCw+x699aDv/xtVprIT2d73SUWKW0PoCSU7SecsKiLPYx/t9ymIw== +dns1.example.com. 3600 RRSIG NSEC 13 3 3600 20440222113630 20240227100630 50687 example.com. Opl4Clj6bRS/iTsJdEpJMX76XAGVt/OJQS3hRdpwDROdaskd69ENPPtdnOR0aNlG6NeMBXzH8HkMOIDv6k50kg== +;; DNSSEC NSEC chain +example.com. 3600 NSEC dns1.example.com. NS SOA RRSIG NSEC DNSKEY +dns1.example.com. 3600 NSEC example.com. A RRSIG NSEC +;; Written 19 records +;; Time 2024-02-27 16:20:39 CET diff --git a/tests/knot/test_semantic_check.in b/tests/knot/test_semantic_check.in index cd50ef7..7675896 100644 --- a/tests/knot/test_semantic_check.in +++ b/tests/knot/test_semantic_check.in @@ -59,6 +59,7 @@ DNAME_CHILDREN="child record exists under DNAME" DNAME_MULTIPLE="multiple DNAME records" DNAME_EXTRA_NS="NS record exists beside DNAME" DNSKEY_INVALID="invalid DNSKEY" +DNSKEY_KEYTAGS="many DNSKEYs with equal keytag" DS_ALG="unknown algorithm in DS" DS_APEX="DS at the zone apex" NSEC3PARAM_FLAGS="invalid flags in NSEC3PARAM" @@ -111,6 +112,7 @@ expect_error "rrsig_rdata_ttl.signed" 0 1 "$RRSIG_UNVERIFIABLE" expect_error "duplicate.signature" 0 1 "$RRSIG_UNVERIFIABLE" expect_error "missing.signed" 0 1 "$NSEC_NONE" expect_error "dnskey_param_error.signed" 0 1 "$DNSKEY_INVALID" +expect_error "dnskey_keytags.many" 0 1 "$DNSKEY_KEYTAGS" expect_error "invalid_ds.signed" 0 2 "$DS_ALG \(keytag 60485" expect_error "cdnskey.invalid" 0 1 "$CDS_NOT_MATCH" expect_error "cdnskey.invalid.param" 0 1 "$CDS_NOT_MATCH" @@ -132,6 +134,7 @@ test_correct "glue_in_deleg.valid" test_correct "cdnskey.cds" test_correct "cdnskey.delete.both" test_correct "dname_apex_nsec3.signed" +test_correct "dnskey_keytags.more" test_correct "nsec3_optout_ent.valid" test_correct "nsec3_optout_ent.all" @@ -157,6 +160,7 @@ test_correct_no_dnssec "rrsig_rdata_ttl.signed" test_correct_no_dnssec "duplicate.signature" test_correct_no_dnssec "missing.signed" test_correct_no_dnssec "dnskey_param_error.signed" +test_correct_no_dnssec "dnskey_keytags.many" test_correct_no_dnssec "cdnskey.invalid" test_correct_no_dnssec "cdnskey.invalid.param" test_correct_no_dnssec "cdnskey.nocds" diff --git a/tests/libknot/test_rrset.c b/tests/libknot/test_rrset.c index cc67e0f..f91d143 100644 --- a/tests/libknot/test_rrset.c +++ b/tests/libknot/test_rrset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +34,43 @@ static bool check_rrset(const knot_rrset_t *rrset, const knot_dname_t *owner, rrset->ttl == ttl && rrset->rrs.count == 0; // We do not test rdataset here } +static void check_size(knot_rrset_t *rrset, uint8_t *rdata, size_t rdata_len) +{ + const size_t per_record_const = 10; + const size_t owner_len = knot_dname_size(rrset->owner); + assert(owner_len == 13); + + static size_t real = 0, estim = 0; + if (rdata_len > 0) { + real += owner_len + per_record_const + rdata_len; + estim += owner_len + per_record_const + rdata_len + (rdata_len & 1); + assert(real <= estim); + } + + int ret = knot_rrset_add_rdata(rrset, rdata, rdata_len, NULL); + is_int(ret, KNOT_EOK, "knot_rrset_add_rdata()"); + + is_int(real, knot_rrset_size(rrset), "knot_rrset_size()"); + is_int(estim, knot_rrset_size_estimate(rrset), "knot_rrset_size_estimate()"); +} + +static void test_rrset_size(void) +{ + knot_dname_t *owner = knot_dname_from_str_alloc("rrset.owner."); + assert(owner); + + knot_rrset_t rrset; + knot_rrset_init(&rrset, owner, KNOT_RRTYPE_TXT, KNOT_CLASS_IN, 7200); + + check_size(&rrset, (uint8_t *)"\x01""a", 2); + check_size(&rrset, (uint8_t *)"\x02""ab", 3); + check_size(&rrset, (uint8_t *)"\x03""abc", 4); + check_size(&rrset, (uint8_t *)"\x03""de", 3); + check_size(&rrset, (uint8_t *)"\x01""f", 2); + + knot_rrset_clear(&rrset, NULL); +} + int main(int argc, char *argv[]) { plan_lazy(); @@ -117,5 +154,8 @@ int main(int argc, char *argv[]) knot_rrset_free(rrset, NULL); knot_rrset_free(copy, NULL); + // Test rrset size computation functions. + test_rrset_size(); + return 0; } diff --git a/tests/libzscanner/data/57_SVCB.in b/tests/libzscanner/data/57_SVCB.in index c4ce534..78c07a6 100644 --- a/tests/libzscanner/data/57_SVCB.in +++ b/tests/libzscanner/data/57_SVCB.in @@ -10,6 +10,7 @@ $TTL 1 @ SVCB 1 . alpn="abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN1234\053" ; Text string of maximal length (255 chars) @ SVCB 1 . alpn="part1,part2,part3\\,part4\\\\" @ SVCB 1 . alpn=part1\,\p\a\r\t2\044part3\092,part4\092\\ +@ SVCB 1 . alpn=foo\\\092,bar @ SVCB 1 . no-default-alpn @ SVCB 1 . port=0 @ SVCB 1 . port="65535" @@ -63,6 +64,11 @@ example.com. SVCB 16 foo.example.org. alpn=f\\\092oo\092,bar,h2 @ SVCB 1 . alpn= @ SVCB 1 . alpn=a, @ SVCB 1 . alpn=a,,b +@ SVCB 1 . alpn=a\ +@ SVCB 1 . alpn=a\\ +@ SVCB 1 . alpn=a\\b +@ SVCB 1 . alpn=a\\\b +@ SVCB 1 . alpn=a\\092,b @ SVCB 1 . alpn="abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN1234\0536" ; Text string overflow (256 chars) @ SVCB 1 . no-default-alpn= @ SVCB 1 . no-default-alpn=h1 diff --git a/tests/libzscanner/data/57_SVCB.out b/tests/libzscanner/data/57_SVCB.out index a799eb7..3b701d2 100644 --- a/tests/libzscanner/data/57_SVCB.out +++ b/tests/libzscanner/data/57_SVCB.out @@ -50,6 +50,12 @@ OWNER=00 CLASS=0001 RRTTL=00000001 RTYPE=0040 +RDATA=0001000001000904666F6F5C03626172 +------ +OWNER=00 +CLASS=0001 +RRTTL=00000001 +RTYPE=0040 RDATA=00010000020000 ------ OWNER=00 @@ -242,6 +248,16 @@ WARNG=ZS_EMPTY_LIST_ITEM ------ WARNG=ZS_EMPTY_LIST_ITEM ------ +WARNG=ZS_BAD_NUMBER +------ +WARNG=ZS_BAD_ALPN_BACKSLASH +------ +WARNG=ZS_BAD_ALPN_BACKSLASH +------ +WARNG=ZS_BAD_ALPN_BACKSLASH +------ +WARNG=ZS_BAD_ALPN_BACKSLASH +------ WARNG=ZS_ITEM_OVERFLOW ------ WARNG=ZS_BAD_SVCB_PARAM |