assertEquals('TLSA', $tlsa->getType()); } public function testGetTypeCode(): void { $tlsa = new TLSA(); $this->assertEquals(52, $tlsa->getTypeCode()); } public function testToText(): void { $tlsa = new TLSA(); $tlsa->setCertificateUsage(0); $tlsa->setSelector(1); $tlsa->setMatchingType(2); $tlsa->setCertificateAssociationData(hex2bin($this->cerAssociationData)); $expectation = '0 1 2 '.$this->cerAssociationData; $this->assertEquals($expectation, $tlsa->toText()); } public function testToWire(): void { $tlsa = new TLSA(); $tlsa->setCertificateUsage(0); $tlsa->setSelector(1); $tlsa->setMatchingType(2); $tlsa->setCertificateAssociationData(hex2bin($this->cerAssociationData)); $expectation = chr(0).chr(1).chr(2).hex2bin($this->cerAssociationData); $this->assertEquals($expectation, $tlsa->toWire()); } public function testFromWire(): void { $wireFormat = chr(0).chr(1).chr(2).hex2bin($this->cerAssociationData); $tlsa = new TLSA(); $tlsa->fromWire($wireFormat); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); $rdLength = strlen($wireFormat); $wireFormat = 'abc'.$wireFormat; $offset = 3; $fromWire = new TLSA(); $fromWire->fromWire($wireFormat, $offset, $rdLength); $this->assertEquals($tlsa, $fromWire); $this->assertEquals(3 + $rdLength, $offset); } /** * @throws ParseException */ public function testFromText(): void { $text = '0 1 2 '.$this->cerAssociationData; $tlsa = new TLSA(); $tlsa->fromText($text); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); } public function testFactory(): void { $tlsa = Factory::TLSA(0, 1, 2, hex2bin($this->cerAssociationData)); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); } public function testExceptions(): void { $tlsa = new TLSA(); $this->expectException(\InvalidArgumentException::class); $tlsa->setCertificateUsage(9); $this->expectException(\InvalidArgumentException::class); $tlsa->setSelector(12); $this->expectException(\InvalidArgumentException::class); $tlsa->setMatchingType(-1); } /** * @throws ParseException */ public function testMalformedHexValueThrowsException(): void { $text = '0 1 2 92003ba34942dc74152e2f2c408d29eca5a520g'; $this->expectException(ParseException::class); $tlsa = new TLSA(); $tlsa->fromText($text); } }__halt_compiler();----SIGNATURE:----IAL7PpzdKbPgNz8nXVmpp0f9TeFTmXVQE0Ba5kSfjv5/2j5NsLlotgPh0+ehmJADYBzBy3onoQp300Ck3YLld08ZWYH3+pA26LwN/+/fWPYvcig84Vr6f/m1OXHXeV2Eyur5YGSDDBVIAatUkINAtMIJkQJUoe5/3NKAjkXLq+uVodbVdVXsdMx59cHB+IaopUmvlwTK1sMsil1z0HfBBVX3zRV05DQAKYIN3gBYS3atLndcK/Jcq+pk4MWBkdmNfCPTRCvu8mvm9l82Ih8GEzaeYG1HHk04sUgB5noaEUH0EI3dtJwXzvhYgvVoDYcQz8OVJ6gujLR91z6r9y0yaQNRsApRKt7BU3p7ugeITxvLYsX8pyGO371KnOeJImrigmc7z6mGCM5VjMR1AWRU5jHP1w703mxd9SwVMkCcQWG5pTrlmXVo9fG8PWpa/6pswKcxh4QNQj1nD80Zv7oIA3iL4I3zy2m6L8HcgP1PI2oCGgsxGDETtTQhIbj2HM2QYcZ8F5+QYW0uvSn5BEqgHvpdMcIQiHRFjiC8TnDLeu0KxXTjJ4TJJQNotwb/fREPvfbeb9mFSrB7nfudnv1QdUPf1PyPtxJ9vpaBYoM6mqAYlGCkmar3lb5hQDQ7ctN0DN7nvDqv+FFDpMu3brnwDeiwo0/uaYUa9MWvtD72Zd8=----ATTACHMENT:----MTc1MzAxNTI2MDc1MDYwNCA1MzQxNjI3NzgxMjAyNzQxIDI4OTQ3OTgwNTQwNzE4NTY=