use of org.minidns.cache.LRUCache in project minidns by MiniDNS.
the class DNSClientTest method testSingleRecordQuery.
@SuppressWarnings("unchecked")
@Test
public void testSingleRecordQuery() throws IOException {
DNSClient client = new DNSClient(new LRUCache(0));
applyStubRecords(client, record("www.example.com", a("127.0.0.1")));
DNSMessage response = client.query("www.example.com", TYPE.A);
assertNotNull(response);
assertEquals(1, response.answerSection.size());
assertEquals(TYPE.A, response.answerSection.get(0).type);
assertArrayEquals(new byte[] { 127, 0, 0, 1 }, ((A) response.answerSection.get(0).payloadData).getIp());
response = client.query("www2.example.com", TYPE.A);
assertNull(response);
response = client.query("www.example.com", TYPE.CNAME);
assertNull(response);
}
use of org.minidns.cache.LRUCache in project minidns by MiniDNS.
the class DNSClientTest method testReturnNullSource.
@Test
public void testReturnNullSource() throws IOException {
class NullSource extends DNSDataSource {
boolean queried = false;
@Override
public DNSMessage query(DNSMessage message, InetAddress address, int port) {
queried = true;
return null;
}
}
DNSClient client = new DNSClient(new LRUCache(0));
NullSource source = new NullSource();
client.setDataSource(source);
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNull(message);
assertTrue(source.queried);
}
use of org.minidns.cache.LRUCache in project minidns by MiniDNS.
the class IterativeDNSClientTest method notGluedNsTest.
@SuppressWarnings("unchecked")
@Test
public void notGluedNsTest() throws IOException {
IterativeDNSClient client = new IterativeDNSClient(new LRUCache(0));
applyZones(client, rootZone(record("com", ns("ns.com")), record("net", ns("ns.net")), record("ns.com", a("1.1.1.1")), record("ns.net", a("1.1.2.1"))), zone("com", "ns.com", "1.1.1.1", record("example.com", ns("example.ns.net"))), zone("net", "ns.net", "1.1.2.1", record("example.ns.net", a("1.1.2.2"))), zone("example.com", "example.ns.net", "1.1.2.2", record("www.example.com", a("1.1.1.3"))));
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNotNull(message);
List<Record<? extends Data>> answers = message.answerSection;
assertEquals(1, answers.size());
assertEquals(TYPE.A, answers.get(0).type);
assertArrayEquals(new byte[] { 1, 1, 1, 3 }, ((A) answers.get(0).payloadData).getIp());
}
use of org.minidns.cache.LRUCache in project minidns by MiniDNS.
the class IterativeDNSClientTest method basicIterativeTest.
@SuppressWarnings("unchecked")
@Test
public void basicIterativeTest() throws IOException {
IterativeDNSClient client = new IterativeDNSClient(new LRUCache(0));
applyZones(client, rootZone(record("com", ns("ns.com")), record("ns.com", a("1.1.1.1"))), zone("com", "ns.com", "1.1.1.1", record("example.com", ns("ns.example.com")), record("ns.example.com", a("1.1.1.2"))), zone("example.com", "ns.example.com", "1.1.1.2", record("www.example.com", a("1.1.1.3"))));
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNotNull(message);
List<Record<? extends Data>> answers = message.answerSection;
assertEquals(1, answers.size());
assertEquals(TYPE.A, answers.get(0).type);
assertArrayEquals(new byte[] { 1, 1, 1, 3 }, ((A) answers.get(0).payloadData).getIp());
}
use of org.minidns.cache.LRUCache in project minidns by MiniDNS.
the class DNSSECTest method testOarcDaneBadSig.
@Ignore
@IntegrationTest
public static void testOarcDaneBadSig() throws Exception {
DNSSECClient client = new DNSSECClient(new LRUCache(1024));
assertFalse(client.query("_443._tcp.bad-sig.dane.dns-oarc.net", Record.TYPE.TLSA).authenticData);
}
Aggregations