dns-over-https/test/HttpsSocketTest.php

32 lines
822 B
PHP
Raw Normal View History

2019-06-11 19:07:51 +02:00
<?php
namespace Amp\DoH\Test;
use Amp\Artax\DefaultClient;
use Amp\Dns;
2019-06-11 20:07:46 +02:00
use Amp\DoH;
use Amp\DoH\Internal\Socket;
2019-06-11 19:07:51 +02:00
use Amp\DoH\Nameserver;
use LibDNS\Records\QuestionFactory;
2019-06-11 20:07:46 +02:00
use function Amp\Promise\wait;
2019-06-11 19:07:51 +02:00
class HttpsSocketTest extends SocketTest
{
protected function connect(Nameserver $nameserver): Socket
{
return DoH\Internal\HttpsSocket::connect(new DefaultClient(), $nameserver);
}
public function testTimeout()
{
$this->expectException(Dns\TimeoutException::class);
/** @var DoH\Internal\HttpsSocket $socket */
$socket = self::connect(new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'));
$question = (new QuestionFactory)->create(Dns\Record::A);
$question->setName("google.com");
wait($socket->ask($question, 0));
}
}