-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathIPSECKEYRecordTest.java
More file actions
71 lines (64 loc) · 2.51 KB
/
Copy pathIPSECKEYRecordTest.java
File metadata and controls
71 lines (64 loc) · 2.51 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
// SPDX-License-Identifier: BSD-3-Clause
package org.xbill.DNS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.net.InetAddress;
import org.junit.jupiter.api.Test;
class IPSECKEYRecordTest {
Name n = Name.fromConstantString("my.name.");
@Test
void ctor_0arg() {
IPSECKEYRecord ipsecKey = new IPSECKEYRecord();
assertEquals(0, ipsecKey.getPrecedence());
assertEquals(0, ipsecKey.getGatewayType());
assertEquals(0, ipsecKey.getAlgorithmType());
assertNull(ipsecKey.getGateway());
assertNull(ipsecKey.getKey());
}
@Test
void ctor_8arg() {
IPSECKEYRecord ipsecKey =
new IPSECKEYRecord(
n,
DClass.IN,
0,
1,
IPSECKEYRecord.Gateway.Name,
IPSECKEYRecord.Algorithm.DSA,
n,
"".getBytes());
assertEquals(1, ipsecKey.getPrecedence());
assertEquals(IPSECKEYRecord.Gateway.Name, ipsecKey.getGatewayType());
assertEquals(IPSECKEYRecord.Algorithm.DSA, ipsecKey.getAlgorithmType());
assertEquals(n, ipsecKey.getGateway());
assertEquals(0, ipsecKey.getKey().length);
}
@Test
void rdataFromString() throws IOException {
Tokenizer t = new Tokenizer("10 0 2 . CAFEBABE");
IPSECKEYRecord ipseckey = new IPSECKEYRecord();
ipseckey.rdataFromString(t, null);
assertEquals(10, ipseckey.getPrecedence());
assertEquals(IPSECKEYRecord.Gateway.None, ipseckey.getGatewayType());
assertEquals(IPSECKEYRecord.Algorithm.RSA, ipseckey.getAlgorithmType());
assertNull(ipseckey.getGateway());
assertEquals(6, ipseckey.getKey().length);
ipseckey = new IPSECKEYRecord();
t = new Tokenizer("( 10 1 2 192.0.2.3 CAFEBABE )");
ipseckey.rdataFromString(t, null);
assertEquals(1, ipseckey.getGatewayType());
assertInstanceOf(InetAddress.class, ipseckey.getGateway());
ipseckey = new IPSECKEYRecord();
t = new Tokenizer("10 2 2 2001:0DB8:0:8002::2000:1 CAFEBABE");
ipseckey.rdataFromString(t, null);
assertEquals(2, ipseckey.getGatewayType());
assertInstanceOf(InetAddress.class, ipseckey.getGateway());
ipseckey = new IPSECKEYRecord();
t = new Tokenizer("10 3 2 mygateway.example.com. CAFEBABE");
ipseckey.rdataFromString(t, null);
assertEquals(3, ipseckey.getGatewayType());
assertEquals(Name.fromConstantString("mygateway.example.com."), ipseckey.getGateway());
}
}