|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Badcow DNS Library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Samuel Williams <[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 Badcow\DNS\Tests\Rdata; |
|
13
|
|
|
|
|
14
|
|
|
use Badcow\DNS\Rdata\APL; |
|
15
|
|
|
use Badcow\DNS\Rdata\Factory; |
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
17
|
|
|
|
|
18
|
|
|
class AplTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
public function testOutput() |
|
21
|
|
|
{ |
|
22
|
|
|
$includedRanges = [ |
|
23
|
|
|
\IPBlock::create('192.168.0.0/23'), |
|
24
|
|
|
\IPBlock::create('2001:acad:1::/112'), |
|
25
|
|
|
]; |
|
26
|
|
|
|
|
27
|
|
|
$excludedRanges = [ |
|
28
|
|
|
\IPBlock::create('192.168.1.64/28'), |
|
29
|
|
|
\IPBlock::create('2001:acad:1::8/128'), |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
$apl = Factory::Apl($includedRanges, $excludedRanges); |
|
33
|
|
|
|
|
34
|
|
|
$expectation = '1:192.168.0.0/23 2:2001:acad:1::/112 !1:192.168.1.64/28 !2:2001:acad:1::8/128'; |
|
35
|
|
|
$this->assertEquals($expectation, $apl->output()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testGetters() |
|
39
|
|
|
{ |
|
40
|
|
|
$includedRanges = [ |
|
41
|
|
|
\IPBlock::create('192.168.0.0/23'), |
|
42
|
|
|
\IPBlock::create('2001:acad:1::/112'), |
|
43
|
|
|
]; |
|
44
|
|
|
|
|
45
|
|
|
$excludedRanges = [ |
|
46
|
|
|
\IPBlock::create('192.168.1.64/28'), |
|
47
|
|
|
\IPBlock::create('2001:acad:1::8/128'), |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
$apl = Factory::Apl($includedRanges, $excludedRanges); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals($includedRanges, $apl->getIncludedAddressRanges()); |
|
53
|
|
|
$this->assertEquals($excludedRanges, $apl->getExcludedAddressRanges()); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|