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