Search in sources :

Example 11 with DnssecClient

use of org.minidns.dnssec.DnssecClient in project Smack by igniterealtime.

the class DnsOverXmppMiniDnsResolverTest method dnsOverXmppMiniDnsResolverTest.

@Test
public void dnsOverXmppMiniDnsResolverTest() throws IOException {
    TestDnsDataSource dnsSource = new TestDnsDataSource();
    TestDnsDataSource dnssecSource = new TestDnsDataSource();
    DnsClient dnsClient = new DnsClient(NoopDnsCache.INSTANCE);
    dnsClient.setDataSource(dnsSource);
    DnssecClient dnssecClient = new DnssecClient(NoopDnsCache.INSTANCE);
    dnssecClient.setDataSource(dnssecSource);
    DnsOverXmppMiniDnsResolver doxResolver = new DnsOverXmppMiniDnsResolver(dnsClient, dnssecClient);
    Question question = new Question("example.org", TYPE.A);
    {
        DnsMessage nondnssecQuery = question.asQueryMessage();
        doxResolver.resolve(nondnssecQuery);
        assertTrue(dnsSource.getAndResetWasQueried());
        assertFalse(dnssecSource.getAndResetWasQueried());
    }
    {
        DnsMessage.Builder dnssecQueryBuilder = question.asMessageBuilder();
        dnssecQueryBuilder.getEdnsBuilder().setDnssecOk();
        DnsMessage dnssecQuery = dnssecQueryBuilder.build();
        DnssecValidationFailedException dnssecValidationFailedException = null;
        try {
            doxResolver.resolve(dnssecQuery);
        } catch (DnssecValidationFailedException e) {
            dnssecValidationFailedException = e;
        }
        // This exception is expected since we don't have a realy DNS source.
        assertNotNull(dnssecValidationFailedException);
        assertFalse(dnsSource.getAndResetWasQueried());
        assertTrue(dnssecSource.getAndResetWasQueried());
    }
}
Also used : DnssecClient(org.minidns.dnssec.DnssecClient) DnssecValidationFailedException(org.minidns.dnssec.DnssecValidationFailedException) DnsClient(org.minidns.DnsClient) Question(org.minidns.dnsmessage.Question) DnsMessage(org.minidns.dnsmessage.DnsMessage) Test(org.junit.jupiter.api.Test)

Aggregations

DNSSECClient (org.minidns.dnssec.DNSSECClient)10 LRUCache (org.minidns.cache.LRUCache)5 DNSSECMessage (org.minidns.dnssec.DNSSECMessage)3 ExtendedLRUCache (org.minidns.cache.ExtendedLRUCache)2 NetworkDataSourceWithAccounting (org.minidns.source.NetworkDataSourceWithAccounting)2 Ignore (org.junit.Ignore)1 Test (org.junit.jupiter.api.Test)1 DNSCache (org.minidns.DNSCache)1 DnsClient (org.minidns.DnsClient)1 FullLRUCache (org.minidns.cache.FullLRUCache)1 DnsMessage (org.minidns.dnsmessage.DnsMessage)1 Question (org.minidns.dnsmessage.Question)1 DnssecClient (org.minidns.dnssec.DnssecClient)1 DnssecValidationFailedException (org.minidns.dnssec.DnssecValidationFailedException)1 UnverifiedReason (org.minidns.dnssec.UnverifiedReason)1