-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathEDNS0MessageTests.java
More file actions
178 lines (167 loc) · 3.3 KB
/
Copy pathEDNS0MessageTests.java
File metadata and controls
178 lines (167 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// SPDX-License-Identifier: BSD-3-Clause
package org.xbill.DNS;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.io.IOException;
import org.junit.jupiter.api.Test;
class EDNS0MessageTests {
/* dig +nocookie foo.dns.addere.ch */
private static final byte[] EDNS0_EMPTY = {
0x7d, 0x59, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x66, 0x6f, 0x6f,
0x03, 0x64, 0x6e, 0x73, 0x06, 0x61, 0x64, 0x64, 0x65, 0x72, 0x65, 0x02, 0x63, 0x68, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* dig foo.dns.addere.ch */
private static final byte[] EDNS0_COOKIE = {
(byte) 0x95,
(byte) 0xa6,
0x01,
0x20,
0x00,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x03,
0x66,
0x6f,
0x6f,
0x03,
0x64,
0x6e,
0x73,
0x06,
0x61,
0x64,
0x64,
0x65,
0x72,
0x65,
0x02,
0x63,
0x68,
0x00,
0x00,
0x01,
0x00,
0x01,
0x00,
0x00,
0x29,
0x10,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x0c,
0x00,
0x0a,
0x00,
0x08,
0x28,
0x75,
(byte) 0x83,
0x7f,
0x00,
0x32,
(byte) 0xe5,
0x6f
};
/* dig +keepalive foo.dns.addere.ch */
private static final byte[] EDNS0_COOKIE_KEEPALIVE = {
(byte) 0x8e,
(byte) 0xdd,
0x01,
0x20,
0x00,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x01,
0x03,
0x66,
0x6f,
0x6f,
0x03,
0x64,
0x6e,
0x73,
0x06,
0x61,
0x64,
0x64,
0x65,
0x72,
0x65,
0x02,
0x63,
0x68,
0x00,
0x00,
0x01,
0x00,
0x01,
0x00,
0x00,
0x29,
0x10,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x10,
0x00,
0x0a,
0x00,
0x08,
(byte) 0xeb,
(byte) 0xed,
(byte) 0xfc,
0x4c,
0x1c,
0x45,
0x20,
0x01,
0x00,
0x0b,
0x00,
0x00
};
/* dig +keepalive +subnet=1.2.3.4 foo.dns.addere.ch */
private static final byte[] EDNS0_SUBNET_COOKIE_KEEPALIVE = {
0x42, 0x3a, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x66, 0x6f, 0x6f,
0x03, 0x64, 0x6e, 0x73, 0x06, 0x61, 0x64, 0x64, 0x65, 0x72, 0x65, 0x02, 0x63, 0x68, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x08,
0x00, 0x08, 0x00, 0x01, 0x20, 0x00, 0x01, 0x02, 0x03, 0x04, 0x00, 0x0a, 0x00, 0x08, 0x7c, 0x2e,
0x0d, 0x0e, (byte) 0x95, (byte) 0xf3, 0x4d, (byte) 0xff, 0x00, 0x0b, 0x00, 0x00
};
@Test
void testParseEdns0Empty() throws IOException {
Message msg = new Message(EDNS0_EMPTY);
assertArrayEquals(EDNS0_EMPTY, msg.toWire());
}
@Test
void testParseEdns0Cookie() throws IOException {
Message msg = new Message(EDNS0_COOKIE);
assertArrayEquals(EDNS0_COOKIE, msg.toWire());
}
@Test
void testParseEdns0CookieKeepalive() throws IOException {
Message msg = new Message(EDNS0_COOKIE_KEEPALIVE);
assertArrayEquals(EDNS0_COOKIE_KEEPALIVE, msg.toWire());
}
@Test
void testParseEdns0SubnetCookieKeepalive() throws IOException {
Message msg = new Message(EDNS0_SUBNET_COOKIE_KEEPALIVE);
assertArrayEquals(EDNS0_SUBNET_COOKIE_KEEPALIVE, msg.toWire());
}
}