Skip to content
Snippets Groups Projects
Commit 729a4eda authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Added tests for SRV and NAPTR + some fixes

refs #2041 @1h30m
refs #2042 @10m
parent c8f8ab69
No related branches found
No related tags found
No related merge requests found
......@@ -92,8 +92,6 @@ static const rdata_descriptor_t rdata_descriptors[] = {
KNOT_RDATA_WF_END } },
[KNOT_RRTYPE_SPF] = { { KNOT_RDATA_WF_REMAINDER,
KNOT_RDATA_WF_END } },
[KNOT_RRTYPE_TKEY] = { { KNOT_RDATA_WF_REMAINDER,
KNOT_RDATA_WF_END } },
[KNOT_RRTYPE_TSIG] = { { KNOT_RDATA_WF_UNCOMPRESSED_DNAME,
KNOT_RDATA_WF_REMAINDER,
KNOT_RDATA_WF_END } },
......
......@@ -85,7 +85,6 @@ enum knot_rr_type {
KNOT_RRTYPE_SPF = 99, /*!< Sender policy framework. */
KNOT_RRTYPE_TKEY = 249, /*!< Secret key for TSIG. */
KNOT_RRTYPE_TSIG = 250, /*!< Transaction signature. */
KNOT_RRTYPE_IXFR = 251, /*!< Incremental zone transfer. */
KNOT_RRTYPE_AXFR = 252, /*!< Authoritative zone transfer. */
......
......@@ -27,10 +27,10 @@
#ifndef _ZSCANNER__FILE_LOADER_H_
#define _ZSCANNER__FILE_LOADER_H_
#include <stdint.h>
#include <stdint.h> // uint32_t
#include "common/descriptor_new.h" // KNOT_CLASS_IN
#include "zscanner/scanner.h" // uint32_t
#include "zscanner/scanner.h" // scanner_t
#define SETTINGS_BUFFER_LENGTH 1024
......
......@@ -1647,40 +1647,40 @@
}
r_type =
( "A"i %{ s->r_type = KNOT_RRTYPE_A; }
| "NS"i %{ s->r_type = KNOT_RRTYPE_NS; }
| "CNAME"i %{ s->r_type = KNOT_RRTYPE_CNAME; }
| "SOA"i %{ s->r_type = KNOT_RRTYPE_SOA; }
| "PTR"i %{ s->r_type = KNOT_RRTYPE_PTR; }
| "HINFO"i %{ s->r_type = KNOT_RRTYPE_HINFO; }
| "MINFO"i %{ s->r_type = KNOT_RRTYPE_MINFO; }
| "MX"i %{ s->r_type = KNOT_RRTYPE_MX; }
| "TXT"i %{ s->r_type = KNOT_RRTYPE_TXT; }
| "RP"i %{ s->r_type = KNOT_RRTYPE_RP; }
| "AFSDB"i %{ s->r_type = KNOT_RRTYPE_AFSDB; }
| "RT"i %{ s->r_type = KNOT_RRTYPE_RT; }
| "KEY"i %{ s->r_type = KNOT_RRTYPE_KEY; }
| "AAAA"i %{ s->r_type = KNOT_RRTYPE_AAAA; }
| "LOC"i %{ s->r_type = KNOT_RRTYPE_LOC; }
| "SRV"i %{ s->r_type = KNOT_RRTYPE_SRV; }
| "NAPTR"i %{ s->r_type = KNOT_RRTYPE_NAPTR; }
| "KX"i %{ s->r_type = KNOT_RRTYPE_KX; }
| "CERT"i %{ s->r_type = KNOT_RRTYPE_CERT; }
| "DNAME"i %{ s->r_type = KNOT_RRTYPE_DNAME; }
| "APL"i %{ s->r_type = KNOT_RRTYPE_APL; }
| "DS"i %{ s->r_type = KNOT_RRTYPE_DS; }
| "SSHFP"i %{ s->r_type = KNOT_RRTYPE_SSHFP; }
| "IPSECKEY"i %{ s->r_type = KNOT_RRTYPE_IPSECKEY; }
| "RRSIG"i %{ s->r_type = KNOT_RRTYPE_RRSIG; }
| "NSEC"i %{ s->r_type = KNOT_RRTYPE_NSEC; }
| "DNSKEY"i %{ s->r_type = KNOT_RRTYPE_DNSKEY; }
| "DHCID"i %{ s->r_type = KNOT_RRTYPE_DHCID; }
| "NSEC3"i %{ s->r_type = KNOT_RRTYPE_NSEC3; }
| "NSEC3PARAM"i %{ s->r_type = KNOT_RRTYPE_NSEC3PARAM; }
| "TLSA"i %{ s->r_type = KNOT_RRTYPE_TLSA; }
| "SPF"i %{ s->r_type = KNOT_RRTYPE_SPF; }
| "TYPE"i . type_number
) $!_r_type_error;
( "A"i %{ s->r_type = KNOT_RRTYPE_A; }
| "NS"i %{ s->r_type = KNOT_RRTYPE_NS; }
| "CNAME"i %{ s->r_type = KNOT_RRTYPE_CNAME; }
| "SOA"i %{ s->r_type = KNOT_RRTYPE_SOA; }
| "PTR"i %{ s->r_type = KNOT_RRTYPE_PTR; }
| "HINFO"i %{ s->r_type = KNOT_RRTYPE_HINFO; }
| "MINFO"i %{ s->r_type = KNOT_RRTYPE_MINFO; }
| "MX"i %{ s->r_type = KNOT_RRTYPE_MX; }
| "TXT"i %{ s->r_type = KNOT_RRTYPE_TXT; }
| "RP"i %{ s->r_type = KNOT_RRTYPE_RP; }
| "AFSDB"i %{ s->r_type = KNOT_RRTYPE_AFSDB; }
| "RT"i %{ s->r_type = KNOT_RRTYPE_RT; }
| "KEY"i %{ s->r_type = KNOT_RRTYPE_KEY; }
| "AAAA"i %{ s->r_type = KNOT_RRTYPE_AAAA; }
| "LOC"i %{ s->r_type = KNOT_RRTYPE_LOC; }
| "SRV"i %{ s->r_type = KNOT_RRTYPE_SRV; }
| "NAPTR"i %{ s->r_type = KNOT_RRTYPE_NAPTR; }
| "KX"i %{ s->r_type = KNOT_RRTYPE_KX; }
| "CERT"i %{ s->r_type = KNOT_RRTYPE_CERT; }
| "DNAME"i %{ s->r_type = KNOT_RRTYPE_DNAME; }
| "APL"i %{ s->r_type = KNOT_RRTYPE_APL; }
| "DS"i %{ s->r_type = KNOT_RRTYPE_DS; }
| "SSHFP"i %{ s->r_type = KNOT_RRTYPE_SSHFP; }
| "IPSECKEY"i %{ s->r_type = KNOT_RRTYPE_IPSECKEY; }
| "RRSIG"i %{ s->r_type = KNOT_RRTYPE_RRSIG; }
| "NSEC"i %{ s->r_type = KNOT_RRTYPE_NSEC; }
| "DNSKEY"i %{ s->r_type = KNOT_RRTYPE_DNSKEY; }
| "DHCID"i %{ s->r_type = KNOT_RRTYPE_DHCID; }
| "NSEC3"i %{ s->r_type = KNOT_RRTYPE_NSEC3; }
| "NSEC3PARAM"i %{ s->r_type = KNOT_RRTYPE_NSEC3PARAM; }
| "TLSA"i %{ s->r_type = KNOT_RRTYPE_TLSA; }
| "SPF"i %{ s->r_type = KNOT_RRTYPE_SPF; }
| "TYPE"i . type_number
) $!_r_type_error;
# END
# BEGIN - Top level processing
......
......@@ -4,17 +4,17 @@ TESTS_DIR="./tests"
OUTS_DIR="/tmp/zscanner_tests"
TEST_BIN="../../unittests-zscanner -m 2"
SEPARATION="========================================================="
mkdir -p ${OUTS_DIR}/${TESTS_DIR}
cp -r ${TESTS_DIR}/includes ${OUTS_DIR}
separation="========================================================="
echo $separation
echo ${SEPARATION}
for file in `find $TESTS_DIR -name "*.in" | sort`; do
fileout=`echo "$file" | sed 's/.in/.out/'`
$TEST_BIN . $file > ${OUTS_DIR}/$fileout
echo $fileout
diff ${OUTS_DIR}/$fileout $fileout
echo $separation
for file in `find ${TESTS_DIR} -name "*.in" | sort`; do
fileout=`echo "${file}" | sed 's/.in/.out/'`
${TEST_BIN} . ${file} > ${OUTS_DIR}/${fileout}
echo ${fileout}
diff ${OUTS_DIR}/${fileout} ${fileout}
echo ${SEPARATION}
done
$ORIGIN .
$TTL 1
; OK
@ SRV 0 0 0 @ ; The simplest variant
_ldap._tcp.test.tld. SRV 0 0 0 @ ; Underscores in owner
@ SRV 65535 65535 65535 @ ; Maximal numbers
@ SRV 0 0 0 \0320\ \\\"\.\@\*.tld. ; Dname with specials
@ TYPE33 \# 7 000000000000 00 ; TYPE + Hexadecimal rdata
@ TYPE33 0 0 0 @ ; TYPE
@ srv 0 0 0 @ ; Type in lower-case
; KO
@ SRV
@ SRV ; Empty rdata
@ SRV \# 0 ; Hex empty rdata
@ SRV \# ; Missing hex length
@ SRV 1h 0 0 @ ; Bad priority
@ SRV 0 1h 0 @ ; Bad weight
@ SRV 0 0 1h @ ; Bad port
@ SRV 0 0 0 % ; Bad target
@ SRV 65536 0 0 @ ; Priority overflow
@ SRV 0 65536 0 @ ; Weight overflow
@ SRV 0 0 65536 @ ; Port overflow
@ SRV 0 0 0 @ x ; Unexpected item
@ SRV 0 0 0 ; Missing item
@ SRV \# 7 00000000000000 00 ; Too long rdata
@ SRV \# 8 000000000000 00 ; Bad rdata length
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 00
------
OWNER=055f6c646170045f746370047465737403746c6400
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=FFFFFFFFFFFF 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 082030205C222E402A03746C6400
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0021
RDATA=000000000000 00
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_HEX_CHAR
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_RDATA
------
WARNG=ZSCANNER_ENUMBER16_OVERFLOW
------
WARNG=ZSCANNER_ENUMBER16_OVERFLOW
------
WARNG=ZSCANNER_ENUMBER16_OVERFLOW
------
WARNG=ZSCANNER_EBAD_REST
------
WARNG=ZSCANNER_EBAD_RDATA
------
WARNG=ZSCANNER_EBAD_RDATA_LENGTH
------
WARNG=ZSCANNER_EBAD_RDATA_LENGTH
------
$ORIGIN .
$TTL 1
; OK
@ NAPTR 0 0 "" "" "" @ ; The simplest variant
@ NAPTR 65535 65535 "" "" "" @ ; Maximal numbers
@ NAPTR 65535 65535 "" "" "!^urn:cid:.+@([^\.]+\.)(.*)$!\\2!i" @ ; Regexp example
@ NAPTR 0 0 "" "" "" \0320\ \\\"\.\@\*.tld. ; Dname with specials
@ TYPE35 \# 8 00000000000000 00 ; TYPE + Hexadecimal rdata
@ TYPE35 0 0 "" "" "" @ ; TYPE
@ naptr 0 0 "" "" "" @ ; Type in lower-case
; KO
@ NAPTR
@ NAPTR ; Empty rdata
@ NAPTR \# 0 ; Hex empty rdata
@ NAPTR \# ; Missing hex length
@ NAPTR 65536 0 "" "" "" @ ; Order overflow
@ NAPTR 0 65536 "" "" "" @ ; Preference overflow
@ NAPTR 0 0 "" "" "" @ x ; Unexpected item
@ NAPTR 0 0 "" "" "" ; Missing item
@ NAPTR \# 8 0000000000000000 00 ; Too long rdata
@ NAPTR \# 7 00000000000000 00 ; Bad rdata length
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=00000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=FFFFFFFF000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=FFFFFFFF00001F215E75726E3A6369643A2E2B40285B5E2E5D2B2E29282E2A2924215C322169 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=00000000000000 082030205C222E402A03746C6400
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=00000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=00000000000000 00
------
OWNER=00
CLASS=0001
RRTTL=00000001
RTYPE=0023
RDATA=00000000000000 00
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_EBAD_HEX_CHAR
------
WARNG=ZSCANNER_EBAD_NUMBER
------
WARNG=ZSCANNER_ENUMBER16_OVERFLOW
------
WARNG=ZSCANNER_ENUMBER16_OVERFLOW
------
WARNG=ZSCANNER_EBAD_REST
------
WARNG=ZSCANNER_EBAD_RDATA
------
WARNG=ZSCANNER_EBAD_RDATA_LENGTH
------
WARNG=ZSCANNER_EBAD_RDATA_LENGTH
------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment