2017-06-23 18:21:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Dns\Test;
|
|
|
|
|
2019-01-04 18:20:52 +01:00
|
|
|
use Amp\Dns\DnsException;
|
|
|
|
use Amp\Dns\InvalidNameException;
|
2017-06-23 18:21:56 +02:00
|
|
|
use Amp\Dns\Record;
|
2019-03-13 17:43:10 +01:00
|
|
|
use Amp\Dns\Rfc1035StubResolver;
|
2017-06-23 18:21:56 +02:00
|
|
|
use Amp\Loop;
|
|
|
|
use Amp\PHPUnit\TestCase;
|
|
|
|
|
2019-03-13 17:43:10 +01:00
|
|
|
class Rfc1035StubResolverTest extends TestCase
|
2019-01-25 02:27:47 +01:00
|
|
|
{
|
|
|
|
public function testResolveSecondParameterAcceptedValues()
|
|
|
|
{
|
2017-06-23 18:21:56 +02:00
|
|
|
Loop::run(function () {
|
|
|
|
$this->expectException(\Error::class);
|
2019-03-13 17:24:25 +01:00
|
|
|
(new Rfc1035StubResolver)->resolve("abc.de", Record::TXT);
|
2017-06-23 18:21:56 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-25 02:27:47 +01:00
|
|
|
public function testIpAsArgumentWithIPv4Restriction()
|
|
|
|
{
|
2017-06-23 18:21:56 +02:00
|
|
|
Loop::run(function () {
|
2019-01-04 18:20:52 +01:00
|
|
|
$this->expectException(DnsException::class);
|
2019-03-13 17:24:25 +01:00
|
|
|
yield (new Rfc1035StubResolver)->resolve("::1", Record::A);
|
2017-06-23 18:21:56 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-25 02:27:47 +01:00
|
|
|
public function testIpAsArgumentWithIPv6Restriction()
|
|
|
|
{
|
2017-06-23 18:21:56 +02:00
|
|
|
Loop::run(function () {
|
2019-01-04 18:20:52 +01:00
|
|
|
$this->expectException(DnsException::class);
|
2019-03-13 17:24:25 +01:00
|
|
|
yield (new Rfc1035StubResolver)->resolve("127.0.0.1", Record::AAAA);
|
2017-06-23 18:21:56 +02:00
|
|
|
});
|
|
|
|
}
|
2019-01-04 18:20:52 +01:00
|
|
|
|
2019-01-25 02:27:47 +01:00
|
|
|
public function testInvalidName()
|
|
|
|
{
|
2019-01-04 18:20:52 +01:00
|
|
|
Loop::run(function () {
|
|
|
|
$this->expectException(InvalidNameException::class);
|
2019-03-13 17:24:25 +01:00
|
|
|
yield (new Rfc1035StubResolver)->resolve("go@gle.com", Record::A);
|
2019-01-04 18:20:52 +01:00
|
|
|
});
|
|
|
|
}
|
2017-06-23 18:21:56 +02:00
|
|
|
}
|