use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.
the class DNSSECClientTest method testSignatureInFuture.
@SuppressWarnings("unchecked")
@Test
public void testSignatureInFuture() throws IOException {
Date signatureExpiration = new Date(System.currentTimeMillis() + 28L * 24L * 60L * 60L * 1000L);
Date signatureInception = new Date(System.currentTimeMillis() + 14 * 24 * 60 * 60 * 1000);
RRSIG outOfDateSig = rrsig(Record.TYPE.A, algorithm, 2, 3600, signatureExpiration, signatureInception, comZSK.getKeyTag(), "com", new byte[0]);
applyZones(client, signedRootZone(sign(rootKSK, "", rootPrivateKSK, algorithm, record("", rootKSK), record("", rootZSK)), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ds("com", digestType, comKSK))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ns("ns.com"))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("ns.com", a("1.1.1.1")))), signedZone("com", "ns.com", "1.1.1.1", sign(comKSK, "com", comPrivateKSK, algorithm, record("com", comKSK), record("com", comZSK)), sign(comPrivateZSK, outOfDateSig, record("example.com", a("1.1.1.2")))));
DNSMessage message = client.query("example.com", Record.TYPE.A);
assertNotNull(message);
assertFalse(message.authenticData);
checkCorrectExampleMessage(message);
}
use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.
the class DNSSECClientTest method testValidNSEC.
@SuppressWarnings("unchecked")
@Test
public void testValidNSEC() throws Exception {
DNSWorld world = applyZones(client, signedRootZone(sign(rootKSK, "", rootPrivateKSK, algorithm, record("", rootKSK), record("", rootZSK)), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ds("com", digestType, comKSK))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ns("ns.com"))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("ns.com", a("1.1.1.1")))), signedZone("com", "ns.com", "1.1.1.1", sign(comKSK, "com", comPrivateKSK, algorithm, record("com", comKSK), record("com", comZSK)), sign(comZSK, "com", comPrivateZSK, algorithm, record("example.com", a("1.1.1.2")))));
DNSMessage.Builder nsecMessage = DNSMessage.builder();
List<Record<? extends Data>> records = DNSSECWorld.merge(sign(comZSK, "com", comPrivateZSK, algorithm, record("example.com", nsec("www.example.com", Record.TYPE.A))), sign(comZSK, "com", comPrivateZSK, algorithm, record("example.com", soa("sns.dns.icann.org", "noc.dns.icann.org", 2015081265, 7200, 3600, 1209600, 3600))));
nsecMessage.setNameserverRecords(records);
nsecMessage.setAuthoritativeAnswer(true);
world.addPreparedResponse(new DNSSECWorld.AddressedNsecResponse(InetAddress.getByAddress("ns.com", new byte[] { 1, 1, 1, 1 }), nsecMessage.build()));
DNSMessage message = client.query("nsec.example.com", Record.TYPE.A);
client.setStripSignatureRecords(false);
assertNotNull(message);
assertEquals(0, message.answerSection.size());
assertTrue(message.authenticData);
}
use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.
the class DNSSECClientTest method testBasicValid.
@SuppressWarnings("unchecked")
@Test
public void testBasicValid() throws IOException {
applyZones(client, signedRootZone(sign(rootKSK, "", rootPrivateKSK, algorithm, record("", rootKSK), record("", rootZSK)), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ds("com", digestType, comKSK))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("com", ns("ns.com"))), sign(rootZSK, "", rootPrivateZSK, algorithm, record("ns.com", a("1.1.1.1")))), signedZone("com", "ns.com", "1.1.1.1", sign(comKSK, "com", comPrivateKSK, algorithm, record("com", comKSK), record("com", comZSK)), sign(comZSK, "com", comPrivateZSK, algorithm, record("example.com", a("1.1.1.2")))));
DNSMessage message = client.query("example.com", Record.TYPE.A);
assertNotNull(message);
assertTrue(message.authenticData);
checkCorrectExampleMessage(message);
}
use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.
the class DNSMessageTest method testTXTLookup.
@Test
public void testTXTLookup() throws Exception {
DNSMessage m = getMessageFromResource("codinghorror-txt");
HashSet<String> txtToBeFound = new HashSet<>();
txtToBeFound.add("google-site-verification=2oV3cW79A6icpGf-JbLGY4rP4_omL4FOKTqRxb-Dyl4");
txtToBeFound.add("keybase-site-verification=dKxf6T30x5EbNIUpeJcbWxUABJEnVWzQ3Z3hCumnk10");
txtToBeFound.add("v=spf1 include:spf.mandrillapp.com ~all");
List<Record<? extends Data>> answers = m.answerSection;
for (Record<? extends Data> r : answers) {
assertCsEquals("codinghorror.com", r.name);
Data d = r.getPayload();
assertTrue(d instanceof TXT);
assertEquals(TYPE.TXT, d.getType());
TXT txt = (TXT) d;
assertTrue(txtToBeFound.contains(txt.getText()));
txtToBeFound.remove(txt.getText());
}
assertEquals(txtToBeFound.size(), 0);
}
use of org.minidns.dnsmessage.DnsMessage in project minidns by MiniDNS.
the class DNSMessageTest method testMessageSelfEasyAnswersReconstruction.
@Test
public void testMessageSelfEasyAnswersReconstruction() throws Exception {
DNSMessage.Builder dmb = DNSMessage.builder();
dmb.addAnswer(record("www.example.com", a("127.0.0.1"))).addAnswer(record("www.example.com", ns("example.com")));
dmb.setRecursionAvailable(true);
dmb.setCheckingDisabled(true);
dmb.setQrFlag(false);
dmb.setId(43);
DNSMessage message = new DNSMessage(dmb.build().toArray());
assertEquals(0, message.questions.size());
assertEquals(2, message.answerSection.size());
assertEquals(0, message.additionalSection.size());
assertEquals(0, message.authoritySection.size());
assertTrue(message.recursionAvailable);
assertFalse(message.authenticData);
assertTrue(message.checkingDisabled);
assertFalse(message.qr);
assertEquals(43, message.id);
assertCsEquals("www.example.com", message.answerSection.get(0).name);
assertEquals(TYPE.A, message.answerSection.get(0).type);
assertCsEquals("127.0.0.1", message.answerSection.get(0).payloadData.toString());
assertCsEquals("www.example.com", message.answerSection.get(1).name);
assertEquals(TYPE.NS, message.answerSection.get(1).type);
assertCsEquals("example.com.", message.answerSection.get(1).payloadData.toString());
}
Aggregations