* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Badcow\DNS\Tests; use Badcow\DNS\Classes; use Badcow\DNS\Rdata\Factory; use Badcow\DNS\Rdata\PTR; use Badcow\DNS\ResourceRecord; use Badcow\DNS\Zone; use Badcow\DNS\ZoneBuilder; use PHPUnit\Framework\TestCase; class ReverseTest extends TestCase { /** * @var string */ private $expectedIpv4Record = <<< 'TXT' $ORIGIN 8.168.192.in-addr.arpa. $TTL 14400 @ IN SOA example.com. post.example.com. 2015010101 3600 14400 604800 3600 @ IN NS ns1.example.com. @ IN NS ns2.example.com. 1 IN PTR foo1.example.com. 2 IN PTR foo2.example.com. 3 IN PTR foo3.example.com. 4 IN PTR foo4.example.com. 5 IN PTR foo5.example.com. TXT; /** * @var string */ private $expectedIpv6Record = <<< 'TXT' $ORIGIN 1.2.0.0.3.8.f.0.1.0.0.2.ip6.arpa. $TTL 14400 @ IN SOA example.com. post.example.com. 2015010101 3600 14400 604800 3600 @ IN NS ns1.example.com. @ IN NS ns2.example.com. 8 IN PTR foo8.example.com. 9 IN PTR foo9.example.com. a IN PTR fooa.example.com. b IN PTR foob.example.com. c IN PTR fooc.example.com. TXT; protected function setUp(): void { $this->expectedIpv4Record = str_replace("\r", '', $this->expectedIpv4Record); $this->expectedIpv6Record = str_replace("\r", '', $this->expectedIpv6Record); } public function testReverseIpv4Record(): void { $origin = PTR::reverseIpv4('192.168.8'); $soa = ResourceRecord::create('@', Factory::SOA( 'example.com.', 'post.example.com.', 2015010101, 3600, 14400, 604800, 3600 ), null, Classes::INTERNET); $ns1 = ResourceRecord::create('@', Factory::NS('ns1.example.com.'), null, Classes::INTERNET); $ns2 = ResourceRecord::create('@', Factory::NS('ns2.example.com.'), null, Classes::INTERNET); $foo1 = ResourceRecord::create('1', Factory::PTR('foo1.example.com.'), null, Classes::INTERNET); $foo2 = ResourceRecord::create('2', Factory::PTR('foo2.example.com.'), null, Classes::INTERNET); $foo3 = ResourceRecord::create('3', Factory::PTR('foo3.example.com.'), null, Classes::INTERNET); $foo4 = ResourceRecord::create('4', Factory::PTR('foo4.example.com.'), null, Classes::INTERNET); $foo5 = ResourceRecord::create('5', Factory::PTR('foo5.example.com.'), null, Classes::INTERNET); $zone = new Zone($origin, 14400, [ $soa, $ns1, $ns2, $foo1, $foo2, $foo3, $foo4, $foo5, ]); $builder = new ZoneBuilder(); $this->assertEquals($this->expectedIpv4Record, $builder->build($zone)); } public function testReverseIpv6Record(): void { $origin = PTR::reverseIpv6('2001:f83:21'); $soa = ResourceRecord::create('@', Factory::SOA( 'example.com.', 'post.example.com.', 2015010101, 3600, 14400, 604800, 3600 ), null, Classes::INTERNET); $ns1 = ResourceRecord::create('@', Factory::NS('ns1.example.com.'), null, Classes::INTERNET); $ns2 = ResourceRecord::create('@', Factory::NS('ns2.example.com.'), null, Classes::INTERNET); $foo8 = ResourceRecord::create('8', Factory::PTR('foo8.example.com.'), null, Classes::INTERNET); $foo9 = ResourceRecord::create('9', Factory::PTR('foo9.example.com.'), null, Classes::INTERNET); $fooa = ResourceRecord::create('a', Factory::PTR('fooa.example.com.'), null, Classes::INTERNET); $foob = ResourceRecord::create('b', Factory::PTR('foob.example.com.'), null, Classes::INTERNET); $fooc = ResourceRecord::create('c', Factory::PTR('fooc.example.com.'), null, Classes::INTERNET); $zone = new Zone($origin, 14400, [ $soa, $ns1, $ns2, $foo8, $foo9, $fooa, $foob, $fooc, ]); $builder = new ZoneBuilder(); $this->assertEquals($this->expectedIpv6Record, $builder->build($zone)); } }__halt_compiler();----SIGNATURE:----QpvcaExQhtuvfqNrFGQeUlTbODbmU8urAJ1LLvDLvuw4ekcLO7pcMFoMU5fl2T2W22OAse/QVjb+ruo9bksPgmOfgCTak8GfStedCDAKl58oa7Yt1/Gut/IUm6M8Lwjpu1BRjCZny8vUPXkbfenTbgFzdXtIUB9l6hLWwxcHIwi3PSuSEC0SUQreRzB5khYD8rL5ES3aQSvQ9101ll9SR0arZEb4AbzruRguGKwwIW6P8NYrXM2clKvI8XPTmJ/QaQSCVmjSzYLv4NNCgvWqMc6IVSbeX7d966To19f+WLAmMuLFatYNq/vkADkh85I1b6tJiVZvVK/9uiQweQ/ppg1+uwuZ00X/HQHehVxqcOO71Jmo95yKPB4LgjHQ4ZiHGyk1/MOOT3lUP0tOTplVVluulFFntzQAvBw8d5NPyubLsM0bprwfJDF83SvUEwfjipqdjqiRgoAvFRpEOzOHOiN252DpQawih5Udn0F2tF9Ot14TLvSY2Yi3Qg94U5NMzNdtBUvcg0rTSRk2kCPirrawg+FTRzJVozLIfrnv6UAuaSyChHBYaVphNnKV7i5Cf7FYSK//95P32M0QfNQibtUD/uj1HdVO4+ylQ3drNHguVWEW8JCSpjjGFt54kIc3NQ0VPK8YfeWZ1r/W/EgQQJPZt8m/hVJG//W9vu8iWME=----ATTACHMENT:----NDIyMTQxNTcwOTA0OTU1NyAzMTQ0NDAxNDM3NDI2NDkxIDIxNjI5OTY5MjczMjY2NDg=