; SPDX-License-Identifier: GPL-3.0-or-later
	trust-anchor: "example. DNSKEY  257 3 7 AwEAAcUlFV1vhmqx6NSOUOq2R/dsR7Xm3upJ ( j7IommWSpJABVfW8Q0rOvXdM6kzt+TAu92L9 AbsUdblMFin8CVF3n4s= )"
CONFIG_END

SCENARIO_BEGIN Test stats module

RANGE_BEGIN 0 100
	ADDRESS 192.0.2.1

ENTRY_BEGIN
REPLY QR RA RD CD NOERROR
MATCH opcode question rcode
ADJUST copy_id
SECTION QUESTION
cd.test. IN TXT
SECTION ANSWER
cd.test. IN TXT "CD is set"
ENTRY_END

ENTRY_BEGIN
REPLY QR RA RD CD NOERROR
MATCH opcode question rcode
ADJUST copy_id
SECTION QUESTION
nodata.test. IN TXT
ENTRY_END

ENTRY_BEGIN
REPLY QR RA RD CD NXDOMAIN
MATCH opcode question
ADJUST copy_id
SECTION QUESTION
nxdomain.test. IN TXT
ENTRY_END

; failing DNSSEC-signed subdomain
ENTRY_BEGIN
REPLY QR RA RD CD SERVFAIL
MATCH opcode subdomain
ADJUST copy_id copy_query
SECTION QUESTION
bogus.test. IN TXT
ENTRY_END

; query for this name triggers check in Lua config
ENTRY_BEGIN
REPLY QR RA RD CD NOERROR
MATCH opcode question rcode
ADJUST copy_id
SECTION QUESTION
stats.test. IN TXT
SECTION ANSWER
stats.test. IN TXT "Ok, trigger query was not intercepted!"
ENTRY_END

ENTRY_BEGIN
REPLY QR RD RA CD TC NOERROR
MATCH opcode question rcode
ADJUST copy_id
SECTION QUESTION
tc.test. IN URI
ENTRY_END

RANGE_END


; +cd +rd
STEP 10 QUERY
ENTRY_BEGIN
REPLY RD CD NOERROR
SECTION QUESTION
cd.test. IN TXT
ENTRY_END

STEP 11 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA CD NOERROR
SECTION QUESTION
cd.test. IN TXT
SECTION ANSWER
cd.test. IN TXT "CD is set"
ENTRY_END

; +cd +cached +rd
STEP 12 QUERY
ENTRY_BEGIN
REPLY RD CD NOERROR
SECTION QUESTION
cd.test. IN TXT
ENTRY_END

STEP 13 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA CD NOERROR
SECTION QUESTION
cd.test. IN TXT
SECTION ANSWER
cd.test. IN TXT "CD is set"
ENTRY_END

; +nodata +rd
STEP 20 QUERY
ENTRY_BEGIN
REPLY RD NOERROR
SECTION QUESTION
nodata.test. IN TXT
SECTION ADDITIONAL
ENTRY_END

STEP 21 CHECK_ANSWER
ENTRY_BEGIN
REPLY QR RD RA NOERROR
MATCH all
SECTION QUESTION
nodata.test. IN TXT
ENTRY_END

; +nxdomain +rd
STEP 30 QUERY
ENTRY_BEGIN
REPLY RD NOERROR
SECTION QUESTION
nxdomain.test. IN TXT
SECTION ADDITIONAL
ENTRY_END

STEP 31 CHECK_ANSWER
ENTRY_BEGIN
REPLY QR RD RA NXDOMAIN
MATCH all
SECTION QUESTION
nxdomain.test. IN TXT
ENTRY_END

; +servfail +do +rd
STEP 40 QUERY
ENTRY_BEGIN
REPLY RD DO NOERROR
SECTION QUESTION
bogus.test. IN TXT
SECTION ADDITIONAL
ENTRY_END

STEP 41 CHECK_ANSWER
ENTRY_BEGIN
REPLY QR RD RA DO SERVFAIL
MATCH all
SECTION QUESTION
bogus.test. IN TXT
ENTRY_END

; no rd
STEP 50 QUERY
ENTRY_BEGIN
REPLY NOERROR
SECTION QUESTION
bogus.test. IN TXT
SECTION ADDITIONAL
ENTRY_END

STEP 51 CHECK_ANSWER
ENTRY_BEGIN
REPLY QR RA SERVFAIL
MATCH all
SECTION QUESTION
bogus.test. IN TXT
ENTRY_END




STEP 100 QUERY
ENTRY_BEGIN
REPLY RD NOERROR
SECTION QUESTION
stats.test. IN TXT
SECTION ADDITIONAL
ENTRY_END

STEP 101 CHECK_ANSWER
ENTRY_BEGIN
REPLY NOERROR
MATCH opcode question additional rcode answer
; AD must not be set in the answer
SECTION QUESTION
stats.test. IN TXT
SECTION ANSWER
stats.test. IN TXT "Ok, trigger query was not intercepted!"
ENTRY_END


SCENARIO_END
