@@ 21-64 (lines=44) @@ | ||
18 | use Badcow\DNS\Rdata\Factory; |
|
19 | use PHPUnit\Framework\TestCase; |
|
20 | ||
21 | class CdsTest extends TestCase |
|
22 | { |
|
23 | private static $digest = '2BB183AF5F22588179A53B0A98631FAD1A292118'; |
|
24 | ||
25 | public function testFactory(): void |
|
26 | { |
|
27 | $keyTag = 60485; |
|
28 | $ds = Factory::CDS($keyTag, Algorithms::RSASHA1, hex2bin(self::$digest), CDS::DIGEST_SHA1); |
|
29 | ||
30 | $this->assertEquals($keyTag, $ds->getKeyTag()); |
|
31 | $this->assertEquals(Algorithms::RSASHA1, $ds->getAlgorithm()); |
|
32 | $this->assertEquals(hex2bin(self::$digest), $ds->getDigest()); |
|
33 | $this->assertEquals(CDS::DIGEST_SHA1, $ds->getDigestType()); |
|
34 | } |
|
35 | ||
36 | public function testFromText(): void |
|
37 | { |
|
38 | $expectation = new CDS(); |
|
39 | $expectation->setKeyTag(60485); |
|
40 | $expectation->setAlgorithm(Algorithms::RSASHA1); |
|
41 | $expectation->setDigestType(CDS::DIGEST_SHA1); |
|
42 | $expectation->setDigest(hex2bin(self::$digest)); |
|
43 | ||
44 | $cds = new CDS(); |
|
45 | $cds->fromText('60485 5 1 '.self::$digest); |
|
46 | $this->assertInstanceOf(CDS::class, $cds); |
|
47 | $this->assertEquals($expectation, $cds); |
|
48 | } |
|
49 | ||
50 | public function testWire(): void |
|
51 | { |
|
52 | $cds = new CDS(); |
|
53 | $cds->setKeyTag(60485); |
|
54 | $cds->setAlgorithm(Algorithms::RSASHA1); |
|
55 | $cds->setDigestType(CDS::DIGEST_SHA1); |
|
56 | $cds->setDigest(hex2bin(self::$digest)); |
|
57 | $wireFormat = $cds->toWire(); |
|
58 | $fromWire = new CDS(); |
|
59 | $fromWire->fromWire($wireFormat); |
|
60 | ||
61 | $this->assertInstanceOf(CDS::class, $fromWire); |
|
62 | $this->assertEquals($cds, $fromWire); |
|
63 | } |
|
64 | } |
|
65 |
@@ 21-64 (lines=44) @@ | ||
18 | use Badcow\DNS\Rdata\Factory; |
|
19 | use PHPUnit\Framework\TestCase; |
|
20 | ||
21 | class DlvTest extends TestCase |
|
22 | { |
|
23 | private static $digest = '2BB183AF5F22588179A53B0A98631FAD1A292118'; |
|
24 | ||
25 | public function testFactory(): void |
|
26 | { |
|
27 | $keyTag = 60485; |
|
28 | $ds = Factory::DLV($keyTag, Algorithms::RSASHA1, hex2bin(self::$digest), DLV::DIGEST_SHA1); |
|
29 | ||
30 | $this->assertEquals($keyTag, $ds->getKeyTag()); |
|
31 | $this->assertEquals(Algorithms::RSASHA1, $ds->getAlgorithm()); |
|
32 | $this->assertEquals(hex2bin(self::$digest), $ds->getDigest()); |
|
33 | $this->assertEquals(DLV::DIGEST_SHA1, $ds->getDigestType()); |
|
34 | } |
|
35 | ||
36 | public function testFromText(): void |
|
37 | { |
|
38 | $expectation = new DLV(); |
|
39 | $expectation->setKeyTag(60485); |
|
40 | $expectation->setAlgorithm(Algorithms::RSASHA1); |
|
41 | $expectation->setDigestType(DLV::DIGEST_SHA1); |
|
42 | $expectation->setDigest(hex2bin(self::$digest)); |
|
43 | ||
44 | $dlv = new DLV(); |
|
45 | $dlv->fromText('60485 5 1 '.self::$digest); |
|
46 | $this->assertInstanceOf(DLV::class, $dlv); |
|
47 | $this->assertEquals($expectation, $dlv); |
|
48 | } |
|
49 | ||
50 | public function testWire(): void |
|
51 | { |
|
52 | $dlv = new DLV(); |
|
53 | $dlv->setKeyTag(60485); |
|
54 | $dlv->setAlgorithm(Algorithms::RSASHA1); |
|
55 | $dlv->setDigestType(DLV::DIGEST_SHA1); |
|
56 | $dlv->setDigest(hex2bin(self::$digest)); |
|
57 | $wireFormat = $dlv->toWire(); |
|
58 | $fromWire = new DLV(); |
|
59 | $fromWire->fromWire($wireFormat); |
|
60 | ||
61 | $this->assertInstanceOf(DLV::class, $fromWire); |
|
62 | $this->assertEquals($dlv, $fromWire); |
|
63 | } |
|
64 | } |
|
65 |