Search in sources :

Example 1 with NSEC

use of org.minidns.record.NSEC in project minidns by MiniDNS.

the class DNSMessageTest method testExampleNsecLookup.

@Test
public void testExampleNsecLookup() throws Exception {
    DNSMessage m = getMessageFromResource("example-nsec");
    List<Record<? extends Data>> answers = m.answerSection;
    assertEquals(1, answers.size());
    assertEquals(TYPE.NSEC, answers.get(0).type);
    assertEquals(TYPE.NSEC, answers.get(0).payloadData.getType());
    NSEC nsec = (NSEC) answers.get(0).getPayload();
    assertCsEquals("www.example.com", nsec.next);
    ArrayList<TYPE> types = new ArrayList<>(Arrays.asList(TYPE.A, TYPE.NS, TYPE.SOA, TYPE.TXT, TYPE.AAAA, TYPE.RRSIG, TYPE.NSEC, TYPE.DNSKEY));
    for (TYPE type : nsec.types) {
        assertTrue(types.remove(type));
    }
    assertTrue(types.isEmpty());
}
Also used : NSEC(org.minidns.record.NSEC) ArrayList(java.util.ArrayList) Record(org.minidns.record.Record) Data(org.minidns.record.Data) TYPE(org.minidns.record.Record.TYPE) DNSMessage(org.minidns.dnsmessage.DNSMessage) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DNSMessage (org.minidns.dnsmessage.DNSMessage)1 Data (org.minidns.record.Data)1 NSEC (org.minidns.record.NSEC)1 Record (org.minidns.record.Record)1 TYPE (org.minidns.record.Record.TYPE)1