Exemple #1
0
 public void LookupSync_IllegalRR_Google()
 {
     using (var client = new DoHClient())
     {
         client.SetEndpoints(new[] { DoHClient.GoogleURI });
         IEnumerable <DNSAnswer> results = client.LookupSync(TestName, (ResourceRecordType)999);
         Assert.IsFalse(results.Any());
     }
 }
Exemple #2
0
 public void LookupSync_Google()
 {
     using (var client = new DoHClient())
     {
         client.SetEndpoints(new[] { DoHClient.GoogleURI });
         IEnumerable <DNSAnswer> results = client.LookupSync(TestName, ResourceRecordType.A).ToArray();
         Assert.IsTrue(results.Any(r => r.RecordType == ResourceRecordType.A && r.Data == TestExpectedIPv4));
         Assert.IsFalse(results.Any(r => r.RecordType != ResourceRecordType.A));
     }
 }
Exemple #3
0
 public void LookupSync_RequestNoGeolocation_Off()
 {
     using (var client = new DoHClient {
         RequestNoGeolocation = false
     })
     {
         client.SetEndpoints(new[] { DoHClient.GoogleURI });
         IEnumerable <DNSAnswer> results = client.LookupSync(TestName, ResourceRecordType.A).ToArray();
         Assert.IsTrue(results.Any(r => r.Data == TestExpectedIPv4));
         Assert.IsFalse(results.Any(r => r.TTL < 0));
         Assert.IsFalse(results.Any(r => r.RecordType != ResourceRecordType.A));
     }
 }
Exemple #4
0
 public void LookupSync_ALL_Cloudflare()
 {
     using (var client = new DoHClient())
     {
         client.SetEndpoints(new[] { DoHClient.CloudflareURI });
         try
         {
             client.LookupSync(TestName, ResourceRecordType.ALL);
         }
         catch (AggregateException ex)
         {
             Assert.IsTrue(ex.InnerException.GetType() == typeof(DNSLookupException));
             Assert.IsTrue(((DNSLookupException)ex.InnerException).InnerExceptions.First().Message == "Received DNS RCode 4 when performing lookup: Not Implemented");
             return;
         }
         catch (DNSLookupException ex)
         {
             Assert.IsTrue(ex.InnerException.Message == "Received DNS RCode 4 when performing lookup: Not Implemented");
             return;
         }
         Assert.Fail("Expected exception to occur");
     }
 }