samuelwilliams /
PHP-DNS-SERVER
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of PHP DNS Server. |
||
| 5 | * |
||
| 6 | * (c) Yif Swery <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace yswery\DNS\Tests\Resolver; |
||
| 13 | |||
| 14 | use yswery\DNS\RecordTypeEnum; |
||
| 15 | use yswery\DNS\Resolver\JsonResolver; |
||
| 16 | use yswery\DNS\ResourceRecord; |
||
| 17 | |||
| 18 | class JsonResolverTest extends AbstractResolverTest |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @throws \yswery\DNS\UnsupportedTypeException |
||
| 22 | */ |
||
| 23 | public function setUp() |
||
| 24 | { |
||
| 25 | $files = [ |
||
| 26 | __DIR__.'/../Resources/example.com.json', |
||
| 27 | __DIR__.'/../Resources/test_records.json', |
||
| 28 | ]; |
||
| 29 | $this->resolver = new JsonResolver($files, 300); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function testResolveLegacyRecord() |
||
| 33 | { |
||
| 34 | $question[] = (new ResourceRecord()) |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 35 | ->setName('test.com.') |
||
| 36 | ->setType(RecordTypeEnum::TYPE_A) |
||
| 37 | ->setQuestion(true); |
||
| 38 | |||
| 39 | $expectation[] = (new ResourceRecord()) |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 40 | ->setName('test.com.') |
||
| 41 | ->setType(RecordTypeEnum::TYPE_A) |
||
| 42 | ->setTtl(300) |
||
| 43 | ->setRdata('111.111.111.111'); |
||
| 44 | |||
| 45 | $this->assertEquals($expectation, $this->resolver->getAnswer($question)); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @throws \yswery\DNS\UnsupportedTypeException |
||
| 50 | */ |
||
| 51 | public function testIsWildcardDomain() |
||
| 52 | { |
||
| 53 | $input1 = '*.example.com.'; |
||
| 54 | $input2 = '*.sub.domain.com.'; |
||
| 55 | $input3 = '*'; |
||
| 56 | $input4 = 'www.test.com.au.'; |
||
| 57 | |||
| 58 | $resolver = new JsonResolver([]); |
||
| 59 | |||
| 60 | $this->assertTrue($resolver->isWildcardDomain($input1)); |
||
| 61 | $this->assertTrue($resolver->isWildcardDomain($input2)); |
||
| 62 | $this->assertTrue($resolver->isWildcardDomain($input3)); |
||
| 63 | $this->assertFalse($resolver->isWildcardDomain($input4)); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |