use of org.minidns.DNSWorld 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);
}
Aggregations