Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
 public void LookupSync_AAAA()
 {
     using (var client = new DoHClient())
     {
         IEnumerable <DNSAnswer> results = client.LookupSync(TestName, ResourceRecordType.AAAA).ToArray();
         Assert.IsTrue(results.Any(r => r.RecordType == ResourceRecordType.AAAA && r.Data == TestExpectedIPv6));
         Assert.IsFalse(results.Any(r => r.RecordType != ResourceRecordType.AAAA));
     }
 }
Ejemplo n.º 3
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));
     }
 }
Ejemplo n.º 4
0
 public void LookupSync_PTR()
 {
     using (var client = new DoHClient())
     {
         client.RequireDNSSEC = false;
         String ipLookup = String.Join(".", TestExpectedIPv4.Split(".", StringSplitOptions.RemoveEmptyEntries)) + ".in-addr.arpa";
         IEnumerable <DNSAnswer> results = client.LookupSync(ipLookup, ResourceRecordType.PTR).ToArray();
         Assert.IsTrue(results.Any(r => r.Data.Contains("34-216-184-93"))); //Badly need a better test
         Assert.IsFalse(results.Any(r => r.TTL < 0));
         Assert.IsFalse(results.Any(r => r.RecordType != ResourceRecordType.PTR));
     }
 }
Ejemplo n.º 5
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));
     }
 }
Ejemplo n.º 6
0
 public void LookupAsync()
 {
     using (var client = new DoHClient())
     {
         Task <IEnumerable <DNSAnswer>[]> resultsBag =
             Task.WhenAll(new[] { 1, 2, 3 }.Select(i => client.LookupAsync(TestName, ResourceRecordType.A)));
         foreach (DNSAnswer[] results in resultsBag.Result.Select(r => r.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));
         }
     }
 }
Ejemplo n.º 7
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");
     }
 }