Search in sources :

Example 1 with DNSWorld

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);
}
Also used : DNSSECWorld.rrsigRecord(org.minidns.dnssec.DNSSECWorld.rrsigRecord) Record(org.minidns.record.Record) Data(org.minidns.record.Data) DNSWorld(org.minidns.DNSWorld) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DNSWorld (org.minidns.DNSWorld)1 DNSMessage (org.minidns.dnsmessage.DNSMessage)1 DNSSECWorld.rrsigRecord (org.minidns.dnssec.DNSSECWorld.rrsigRecord)1 Data (org.minidns.record.Data)1 Record (org.minidns.record.Record)1