xref: /netbsd-src/external/bsd/unbound/dist/testdata/serve_original_ttl.rpl (revision 7a540f2bd4f5b968566c2607d6462c7f2fb452cf)
1; config options
2server:
3	access-control: 127.0.0.1 allow_snoop
4	module-config: "validator iterator"
5	qname-minimisation: "no"
6	minimal-responses: no
7	serve-original-ttl: yes
8	cache-max-ttl: 1000
9	cache-min-ttl: 20
10	serve-expired: yes
11	serve-expired-reply-ttl: 123
12	ede: yes
13	ede-serve-expired: yes
14
15stub-zone:
16	name: "example.com"
17	stub-addr: 1.2.3.4
18CONFIG_END
19
20SCENARIO_BEGIN Test serve-original-ttl
21; Scenario overview:
22; - query for example.com. IN A
23; - check that we get an answer for example.com. IN A with the correct TTL
24; - query again after a couple seconds and check that we get the original TTL
25; (next steps are combination with serve-expired)
26; - query again after the TTL expired
27; - check that we get the expired cached answer with the original TTL
28
29; ns.example.com.
30RANGE_BEGIN 0 100
31	ADDRESS 1.2.3.4
32	ENTRY_BEGIN
33		MATCH opcode qtype qname
34		ADJUST copy_id
35		REPLY QR NOERROR
36		SECTION QUESTION
37			example.com. IN NS
38		SECTION ANSWER
39			example.com. IN NS ns.example.com.
40		SECTION ADDITIONAL
41			ns.example.com. IN A 1.2.3.4
42	ENTRY_END
43
44	ENTRY_BEGIN
45		MATCH opcode qtype qname
46		ADJUST copy_id
47		REPLY QR NOERROR
48		SECTION QUESTION
49			example.com. IN A
50		SECTION ANSWER
51			example.com. 10 IN A 5.6.7.8
52		SECTION AUTHORITY
53			example.com. IN NS ns.example.com.
54		SECTION ADDITIONAL
55			ns.example.com. IN A 1.2.3.4
56	ENTRY_END
57RANGE_END
58
59; Query with RD flag
60STEP 1 QUERY
61ENTRY_BEGIN
62	REPLY RD
63	SECTION QUESTION
64		example.com. IN A
65ENTRY_END
66
67; Check that we got the correct answer (should be cached)
68STEP 10 CHECK_ANSWER
69ENTRY_BEGIN
70	MATCH all ttl
71	REPLY QR RD RA NOERROR
72	SECTION QUESTION
73		example.com. IN A
74	SECTION ANSWER
75		example.com. 10 IN A 5.6.7.8
76	SECTION AUTHORITY
77		example.com. IN NS ns.example.com.
78	SECTION ADDITIONAL
79		ns.example.com. IN A 1.2.3.4
80ENTRY_END
81
82; Wait a couple of seconds (< 10)
83STEP 11 TIME_PASSES ELAPSE 5
84
85; Query again
86STEP 20 QUERY
87ENTRY_BEGIN
88	REPLY
89	SECTION QUESTION
90		example.com. IN A
91ENTRY_END
92
93; Check that we got the cached answer with the original TTL
94; (Passively checks that minimum and maximum TTLs are ignored)
95STEP 30 CHECK_ANSWER
96ENTRY_BEGIN
97	MATCH all ttl
98	REPLY QR RA NOERROR
99	SECTION QUESTION
100		example.com. IN A
101	SECTION ANSWER
102		example.com.  10 A 5.6.7.8
103	SECTION AUTHORITY
104		example.com. 3600 NS ns.example.com.
105	SECTION ADDITIONAL
106		ns.example.com. 3600 A 1.2.3.4
107ENTRY_END
108
109; Wait for the TTL to expire
110STEP 31 TIME_PASSES ELAPSE 3601
111
112; Query again
113STEP 40 QUERY
114ENTRY_BEGIN
115	REPLY DO
116	SECTION QUESTION
117		example.com. IN A
118ENTRY_END
119
120; Check that we got a stale answer with the original TTL
121STEP 50 CHECK_ANSWER
122ENTRY_BEGIN
123	MATCH all ttl ede=3
124	REPLY QR RA DO NOERROR
125	SECTION QUESTION
126		example.com. IN A
127	SECTION ANSWER
128		example.com.  10 A 5.6.7.8
129	SECTION AUTHORITY
130		example.com. NS ns.example.com.
131	SECTION ADDITIONAL
132		ns.example.com. A 1.2.3.4
133ENTRY_END
134
135; Give time for the pending query to get answered
136STEP 51 TRAFFIC
137
138SCENARIO_END
139