Skip to content

Commit

Permalink
Merge pull request #115 from farsightsec/tests-202309
Browse files Browse the repository at this point in the history
Add tests for base:dns, dnsqr, and dnsobs, update base:dnstap tests
  • Loading branch information
alesage authored Sep 7, 2023
2 parents d3a1c1f + e030145 commit 270b12f
Show file tree
Hide file tree
Showing 24 changed files with 956 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ TESTS =
BUILT_SOURCES =
EXTRA_DIST =
CLEANFILES =
DISTCLEANFILES =
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}

AM_CPPFLAGS = \
Expand All @@ -31,7 +32,6 @@ EXTRA_DIST += \
tests/json-utf8-tests/straycont.nmsg \
tests/json-utf8-tests/test.sh.in \
tests/json-utf8-tests/truncated.nmsg \
tests/nmsg.test \
tests/string-tests/empty-string.json \
tests/string-tests/empty-string.nmsg \
tests/string-tests/empty-string.pres \
Expand Down Expand Up @@ -365,6 +365,24 @@ EXTRA_DIST += tests/generic-tests/test.chalias
EXTRA_DIST += tests/generic-tests/test.gralias
EXTRA_DIST += tests/generic-tests/test.opalias

EXTRA_DIST += tests/nmsg-dns-tests/test1-dns.json
EXTRA_DIST += tests/nmsg-dns-tests/test1-dns.nmsg
EXTRA_DIST += tests/nmsg-dns-tests/test1-dns.pres
EXTRA_DIST += tests/nmsg-dns-tests/test2-dns.json
EXTRA_DIST += tests/nmsg-dns-tests/test2-dns.nmsg
EXTRA_DIST += tests/nmsg-dns-tests/test2-dns.pres
EXTRA_DIST += tests/nmsg-dns-tests/test3-dns.json
EXTRA_DIST += tests/nmsg-dnsobs-tests/test1-dnsobs.json
EXTRA_DIST += tests/nmsg-dnsobs-tests/test1-dnsobs.nmsg
EXTRA_DIST += tests/nmsg-dnsobs-tests/test1-dnsobs.pres
EXTRA_DIST += tests/nmsg-dnsqr-tests/test1-dnsqr.json
EXTRA_DIST += tests/nmsg-dnsqr-tests/test1-dnsqr.nmsg
EXTRA_DIST += tests/nmsg-dnsqr-tests/test1-dnsqr.pcap
EXTRA_DIST += tests/nmsg-dnsqr-tests/test1-dnsqr.pres
EXTRA_DIST += tests/nmsg-dnstap-tests/test1-dnstap.json
EXTRA_DIST += tests/nmsg-dnstap-tests/test1-dnstap.nmsg
EXTRA_DIST += tests/nmsg-dnstap-tests/test1-dnstap.pres

noinst_PROGRAMS += libmy/crc32c_test
libmy_crc32c_test_CFLAGS = $(AM_CFLAGS)
libmy_crc32c_test_SOURCES = \
Expand All @@ -383,7 +401,10 @@ noinst_PROGRAMS += \
examples/print_version

TESTS += tests/json-utf8-tests/test.sh
TESTS += tests/nmsg-dns-tests/test.sh
TESTS += tests/nmsg-dnsqr-tests/test.sh
TESTS += tests/nmsg-dnstap-tests/test.sh
TESTS += tests/nmsg-dnsobs-tests/test.sh
TESTS += tests/payload-crc32c-tests/test.sh
TESTS += tests/string-tests/test.sh
TESTS += tests/udp-checksum-tests/test.sh
Expand Down Expand Up @@ -414,6 +435,11 @@ check_PROGRAMS += tests/test-nmsg_output_set_rate
tests_test_nmsg_output_set_rate_SOURCES = tests/test-nmsg_output_set_rate.c
tests_test_nmsg_output_set_rate_LDADD = nmsg/libnmsg.la

DISTCLEANFILES += tests/nmsg-dns-tests/test*.out
DISTCLEANFILES += tests/nmsg-dnsobs-tests/test*.out
DISTCLEANFILES += tests/nmsg-dnsqr-tests/test*.out
DISTCLEANFILES += tests/nmsg-dnstap-tests/test*.out

#
##
### Examples
Expand Down
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ AC_CONFIG_FILES([Makefile doc/doxygen/Doxyfile nmsg/libnmsg.pc nmsg/version.h])
AC_CONFIG_FILES([tests/json-utf8-tests/test.sh],
[chmod +x tests/json-utf8-tests/test.sh])

AC_CONFIG_FILES([tests/nmsg-dns-tests/test.sh],
[chmod +x tests/nmsg-dns-tests/test.sh])

AC_CONFIG_FILES([tests/nmsg-dnsobs-tests/test.sh],
[chmod +x tests/nmsg-dnsobs-tests/test.sh])

AC_CONFIG_FILES([tests/nmsg-dnsqr-tests/test.sh],
[chmod +x tests/nmsg-dnsqr-tests/test.sh])

AC_CONFIG_FILES([tests/nmsg-dnstap-tests/test.sh],
[chmod +x tests/nmsg-dnstap-tests/test.sh])

Expand Down
4 changes: 4 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ test-layout-fltmod_plugin
test-nmsg_output_set_rate
string-tests/test.sh
json-utf8-tests/test.sh
nmsg-dns-tests/test.sh
nmsg-dnsqr-tests/test.sh
nmsg-dnsobs-tests/test.sh
nmsg-dnstap-tests/test.sh
nmsg-dns*-tests/*.out
payload-crc32c-tests/test.sh
udp-checksum-tests/test.sh
*.log
Expand Down
89 changes: 89 additions & 0 deletions tests/nmsg-dns-tests/test.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/sh

status=0

check() {
if [ $? = "0" ]; then
echo "PASS: $*"
else
echo "FAIL: $*"
status=1
fi
}

NMSG_MSGMOD_DIR="@abs_top_builddir@/nmsg/base/.libs"
export NMSG_MSGMOD_DIR
NMSGTOOL="@abs_top_builddir@/src/nmsgtool"

SOURCE=@abs_top_srcdir@/tests/nmsg-dns-tests/test1-dns
OUTPUT=@abs_top_builddir@/tests/nmsg-dns-tests/test1-dns

# cleanup from previous run
rm -f ${OUTPUT}*out

$NMSGTOOL -r ${SOURCE}.nmsg > ${OUTPUT}.nmsg.pres.out
check read nmsg base:dns and create presentation output
cmp -s ${SOURCE}.pres ${OUTPUT}.nmsg.pres.out
check nmsg-to-presentation

$NMSGTOOL -r ${SOURCE}.nmsg -J ${OUTPUT}.nmsg.json.out
check read nmsg base:dns and create json output
cmp -s ${SOURCE}.json ${OUTPUT}.nmsg.json.out
check nmsg-to-json

# output should be same as input
$NMSGTOOL -r ${SOURCE}.nmsg -w ${OUTPUT}.nmsg.nmsg.out
check read nmsg base:dns and create nmsg output
cmp -s ${SOURCE}.nmsg ${OUTPUT}.nmsg.nmsg.out
check nmsg-to-nmsg

$NMSGTOOL -j ${SOURCE}.json > ${OUTPUT}.json.pres.out
check read json base:dns and create presentation output
cmp -s ${SOURCE}.pres ${OUTPUT}.json.pres.out
check json-to-presentation

# output should be same as input
$NMSGTOOL -j ${SOURCE}.json -J ${OUTPUT}.json.json.out
check read json base:dns and create json output
cmp -s ${SOURCE}.json ${OUTPUT}.json.json.out
check json-to-json

$NMSGTOOL -j ${SOURCE}.json -w ${OUTPUT}.json.nmsg.out
check read json base:dns and create nmsg output
cmp -s ${SOURCE}.nmsg ${OUTPUT}.json.nmsg.out
check json-to-nmsg

# another test input
# TODO: use a function since is repeated

$NMSGTOOL -r @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.nmsg > @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.nmsg.pres.out
check read nmsg base:dns and create presentation output
cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.pres @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.nmsg.pres.out
check nmsg-to-presentation

$NMSGTOOL -r @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.nmsg -J @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.nmsg.json.out
check read nmsg base:dns and create json output
cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.nmsg.json.out
check nmsg-to-json

$NMSGTOOL -j @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json > @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.pres.out
check read json base:dns and create presentation output
cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.pres @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.pres.out
check json-to-presentation

$NMSGTOOL -j @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json -J @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.json.out
check read json base:dns and create json output
cmp -s @abs_top_srcdir@/tests/nmsg-dns-tests/test2-dns.json @abs_top_builddir@/tests/nmsg-dns-tests/test2-dns.json.json.out
check json-to-json

# NOTE: --readpres is not fully implemented for base:dns so aborts

# JSON input mistakes should result in no output
$NMSGTOOL -dd -j @abs_top_srcdir@/tests/nmsg-dns-tests/test3-dns.json --writepres @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.out 2>@abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.stderr.out
check read broken json base:dns and create empty output
grep "JSON parse error:" @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.stderr.out >/dev/null
check reports JSON parse error
test ! -s @abs_top_builddir@/tests/nmsg-dns-tests/test3-dns.json.pres.out
check broken-json-to-empty-pres

exit $status
6 changes: 6 additions & 0 deletions tests/nmsg-dns-tests/test1-dns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"time":"2011-02-09 19:41:52.068575000","vname":"base","mname":"dns","message":{"rrname":"test1.example.net.","rrclass":"IN","rrtype":"TXT","rrttl":3600,"rdata":["\"Hello\""]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"qname":"test1.example.net.","qclass":"IN","qtype":"A","section":1,"rrname":"test1.example.net.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["10.11.12.13","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"test1.example.net.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["10.11.12.13","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"test1.example.net.","rrclass":"IN","rrtype":"SPF","rrttl":172800,"rdata":["\"10.11.12.13\"","\"10.12.13.14\""]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"qname":"test1.example.net.","qclass":"IN","qtype":"A","rrname":"test1.example.net.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["10.11.12.13"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"test1.example.net.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["10.11.12.13"]}}
Binary file added tests/nmsg-dns-tests/test1-dns.nmsg
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/nmsg-dns-tests/test1-dns.pres
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[36] [2011-02-09 19:41:52.068575000] [1:7 base dns] [00000000] [] []
rrname: test1.example.net.
rrclass: IN (1)
rrtype: TXT (16)
rrttl: 3600
rdata: "Hello"

[68] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
qname: test1.example.net.
qclass: IN (1)
qtype: A (1)
section: 1
rrname: test1.example.net.
rrclass: IN (1)
rrtype: A (1)
rrttl: 172800
rdata: 10.11.12.13
rdata: 10.12.13.14

[41] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: test1.example.net.
rrclass: IN (1)
rrtype: A (1)
rrttl: 172800
rdata: 10.11.12.13
rdata: 10.12.13.14

[57] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: test1.example.net.
rrclass: IN (1)
rrtype: SPF (99)
rrttl: 172800
rdata: "10.11.12.13"
rdata: "10.12.13.14"

[60] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
qname: test1.example.net.
qclass: IN (1)
qtype: A (1)
rrname: test1.example.net.
rrclass: IN (1)
rrtype: A (1)
rrttl: 172800
rdata: 10.11.12.13

[35] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: test1.example.net.
rrclass: IN (1)
rrtype: A (1)
rrttl: 172800
rdata: 10.11.12.13

8 changes: 8 additions & 0 deletions tests/nmsg-dns-tests/test2-dns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":".","rrclass":"IN","rrtype":"SOA","rrttl":86400,"rdata":["a.root-servers.net. nstld.verisign-grs.com. 2018110200 1800 900 604800 86400"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":".","rrclass":"IN","rrtype":"RRSIG","rrttl":86400,"rdata":["SOA 8 0 86400 1542258000 1541131200 2134 . YzIh/SUfJITb8q0y45FtmHYU2q3ozTWzFoFTVMGEQmKkVIxvASHxKJAtkQQbA1OUkwsoXZAKFPwPLLdBn7YsesIlMosEfVtLIZe8iNivbzTTp0R81QK4bZfXqRbsIzl9h0YNxbprrvz7rhrIa1QkKg8Eiz2pI12ero8bjSBlOt+vGlnxOriI7WfjtGNTZ5kzwfRcpbND5i0PZkfSPyL6mrOgI6Ak+F7jGos+4H86OPpikmOwKXOC50qs6ayX4YHMQgtdOXe7YMxzAEUUWR7aCg379dbwjRDrt3HhpLIlvxNzOqOQhCCBT0uez08+MEiJQ+g/9oDexqb9vPsZHTf8VQ=="]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":".","rrclass":"IN","rrtype":"NS","rrttl":518400,"rdata":["a.root-servers.net.","b.root-servers.net.","c.root-servers.net.","d.root-servers.net.","e.root-servers.net.","f.root-servers.net.","g.root-servers.net.","h.root-servers.net.","i.root-servers.net.","j.root-servers.net.","k.root-servers.net.","l.root-servers.net.","m.root-servers.net."]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":".","rrclass":"IN","rrtype":"NSEC","rrttl":86400,"rdata":["aaa. NS SOA RRSIG NSEC DNSKEY"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":".","rrclass":"IN","rrtype":"DNSKEY","rrttl":172800,"rdata":["256 3 8 AwEAAdp440E6Mz7c+Vl4sPd0lTv2Qnc85dTW64j0RDD7sS/zwxWDJ3QRES2VKDO0OXLMqVJSs2YCCSDKuZXpDPuf++YfAu0j7lzYYdWTGwyNZhEaXtMQJIKYB96pW6cRkiG2Dn8S2vvo/PxW9PKQsyLbtd8PcwWglHgReBVp7kEv/Dd+3b3YMukt4jnWgDUddAySg558Zld+c9eGWkgWoOiuhg4rQRkFstMX1pRyOSHcZuH38o1WcsT4y3eT0U/SR6TOSLIB/8Ftirux/h297oS7tCcwSPt0wwry5OFNTlfMo8v7WGurogfk8hPipf7TTKHIi20LWen5RCsvYsQBkYGpF78=","257 3 8 AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0=","257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU="]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"ns1.dns.nic.aaa.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["156.154.144.2"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"ns1.dns.nic.aaa.","rrclass":"IN","rrtype":"AAAA","rrttl":172800,"rdata":["2610:a1:1071::2"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"ac.","rrclass":"IN","rrtype":"DS","rrttl":86400,"rdata":["42665 8 1 D5E99D85351D361BD6B5B1582F634E8A85CF1BF7","23014 8 2 9F135B4B4C69C92383B997632E821E3C8AB9699658674CC96FDE5405ACB68B65","42665 8 2 4B15F405C98F4BC3A370B19E54DBE75DF201EDCD38577C51D277DC6559865D95"]}}
Binary file added tests/nmsg-dns-tests/test2-dns.nmsg
Binary file not shown.
72 changes: 72 additions & 0 deletions tests/nmsg-dns-tests/test2-dns.pres
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[77] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: .
rrclass: IN (1)
rrtype: SOA (6)
rrttl: 86400
rdata: a.root-servers.net. nstld.verisign-grs.com. 2018110200 1800 900 604800 86400

[289] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: .
rrclass: IN (1)
rrtype: RRSIG (46)
rrttl: 86400
rdata: SOA 8 0 86400 1542258000 1541131200 2134 . YzIh/SUfJITb8q0y45FtmHYU2q3ozTWzFoFTVMGEQmKkVIxvASHxKJAtkQQbA1OUkwsoXZAKFPwPLLdBn7YsesIlMosEfVtLIZe8iNivbzTTp0R81QK4bZfXqRbsIzl9h0YNxbprrvz7rhrIa1QkKg8Eiz2pI12ero8bjSBlOt+vGlnxOriI7WfjtGNTZ5kzwfRcpbND5i0PZkfSPyL6mrOgI6Ak+F7jGos+4H86OPpikmOwKXOC50qs6ayX4YHMQgtdOXe7YMxzAEUUWR7aCg379dbwjRDrt3HhpLIlvxNzOqOQhCCBT0uez08+MEiJQ+g/9oDexqb9vPsZHTf8VQ==

[297] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: .
rrclass: IN (1)
rrtype: NS (2)
rrttl: 518400
rdata: a.root-servers.net.
rdata: b.root-servers.net.
rdata: c.root-servers.net.
rdata: d.root-servers.net.
rdata: e.root-servers.net.
rdata: f.root-servers.net.
rdata: g.root-servers.net.
rdata: h.root-servers.net.
rdata: i.root-servers.net.
rdata: j.root-servers.net.
rdata: k.root-servers.net.
rdata: l.root-servers.net.
rdata: m.root-servers.net.

[27] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: .
rrclass: IN (1)
rrtype: NSEC (47)
rrttl: 86400
rdata: aaa. NS SOA RRSIG NSEC DNSKEY

[812] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: .
rrclass: IN (1)
rrtype: DNSKEY (48)
rrttl: 172800
rdata: 256 3 8 AwEAAdp440E6Mz7c+Vl4sPd0lTv2Qnc85dTW64j0RDD7sS/zwxWDJ3QRES2VKDO0OXLMqVJSs2YCCSDKuZXpDPuf++YfAu0j7lzYYdWTGwyNZhEaXtMQJIKYB96pW6cRkiG2Dn8S2vvo/PxW9PKQsyLbtd8PcwWglHgReBVp7kEv/Dd+3b3YMukt4jnWgDUddAySg558Zld+c9eGWkgWoOiuhg4rQRkFstMX1pRyOSHcZuH38o1WcsT4y3eT0U/SR6TOSLIB/8Ftirux/h297oS7tCcwSPt0wwry5OFNTlfMo8v7WGurogfk8hPipf7TTKHIi20LWen5RCsvYsQBkYGpF78=
rdata: 257 3 8 AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0=
rdata: 257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU=

[33] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: ns1.dns.nic.aaa.
rrclass: IN (1)
rrtype: A (1)
rrttl: 172800
rdata: 156.154.144.2

[45] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: ns1.dns.nic.aaa.
rrclass: IN (1)
rrtype: AAAA (28)
rrttl: 172800
rdata: 2610:a1:1071::2

[116] [2018-11-07 16:50:54.000000000] [1:7 base dns] [00000000] [] []
rrname: ac.
rrclass: IN (1)
rrtype: DS (43)
rrttl: 86400
rdata: 42665 8 1 D5E99D85351D361BD6B5B1582F634E8A85CF1BF7
rdata: 23014 8 2 9F135B4B4C69C92383B997632E821E3C8AB9699658674CC96FDE5405ACB68B65
rdata: 42665 8 2 4B15F405C98F4BC3A370B19E54DBE75DF201EDCD38577C51D277DC6559865D95

5 changes: 5 additions & 0 deletions tests/nmsg-dns-tests/test3-dns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"garbage-rrtype.test3.example.net.","rrclass":"IN","rrtype":"garbage","rrttl":172800,"rdata":["10.11.12.13","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"type99.test3.example.net.","rrclass":"IN","rrtype":"TYPE999","rrttl":172800,"rdata":["10.11.12.13","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"unknown-rrtype.test3.example.net.","rrclass":"IN","rrtype":"<UNKNOWN>","rrttl":172800,"rdata":["10.11.12.13","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"garbage-rdata.test3.example.net.","rrclass":"IN","rrtype":"A","rrttl":172800,"rdata":["not an IP address","10.12.13.14"]}}
{"time":"2018-11-07 16:50:54.000000000","vname":"base","mname":"dns","message":{"rrname":"garbage-rrttl.test3.example.net.","rrclass":"IN","rrtype":"A","rrttl":"not an TTL number","rdata":["10.11.12.13","10.12.13.14"]}}
59 changes: 59 additions & 0 deletions tests/nmsg-dnsobs-tests/test.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh

status=0

check() {
if [ $? = "0" ]; then
echo "PASS: $*"
else
echo "FAIL: $*"
status=1
fi
}

NMSG_MSGMOD_DIR="@abs_top_builddir@/nmsg/base/.libs"
export NMSG_MSGMOD_DIR
NMSGTOOL="@abs_top_builddir@/src/nmsgtool"
PAYLOAD="@abs_top_srcdir@/tests/nmsg-dnsobs-tests/test-dnsobs.nmsg"

SOURCE=@abs_top_srcdir@/tests/nmsg-dnsobs-tests/test1-dnsobs
OUTPUT=@abs_top_builddir@/tests/nmsg-dnsobs-tests/test1-dnsobs

# cleanup from previous run
rm -f ${OUTPUT}*out

$NMSGTOOL -r ${SOURCE}.nmsg > ${OUTPUT}.nmsg.pres.out
check read nmsg base:dnsobs and create dnsobs presentation output
cmp -s ${SOURCE}.pres ${OUTPUT}.nmsg.pres.out
check nmsg-to-presentation

# output should be same as input
$NMSGTOOL -r ${SOURCE}.nmsg -w ${OUTPUT}.nmsg.nmsg.out
check read nmsg base:dnsobs and create base:dnsobs nmsg output
cmp -s ${SOURCE}.nmsg ${OUTPUT}.nmsg.nmsg.out
check nmsg-to-nmsg

$NMSGTOOL -r ${SOURCE}.nmsg -J ${OUTPUT}.nmsg.json.out
check read nmsg base:dnsobs and create base:dnsobs json output
cmp -s ${SOURCE}.json ${OUTPUT}.nmsg.json.out
check nmsg-to-json

$NMSGTOOL --readjson ${SOURCE}.json > ${OUTPUT}.json.pres.out
check read json base:dnsobs and create dnsobs presentation output
cmp -s ${SOURCE}.pres ${OUTPUT}.json.pres.out
check json-to-presentation

$NMSGTOOL --readjson ${SOURCE}.json -w ${OUTPUT}.json.nmsg.out
check read json base:dnsobs and create base:dnsobs nmsg output
cmp -s ${SOURCE}.nmsg ${OUTPUT}.json.nmsg.out
check json-to-nmsg

# output should be same as input
$NMSGTOOL --readjson ${SOURCE}.json -J ${OUTPUT}.json.json.out
check read json base:dnsobs and create base:dnsobs json output
cmp -s ${SOURCE}.json ${OUTPUT}.json.json.out
check json-to-json

# NOTE: --readpres is not fully implemented for base:dnsobs

exit $status
Loading

0 comments on commit 270b12f

Please sign in to comment.