2019-11-24 23:45:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Cijber\OpenSSL\Tests;
|
|
|
|
|
|
|
|
use Cijber\OpenSSL\PKCS7;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-11-25 22:05:11 +00:00
|
|
|
use RuntimeException;
|
2019-11-24 23:45:19 +00:00
|
|
|
|
|
|
|
class PKCS7Test extends TestCase
|
|
|
|
{
|
|
|
|
public function testCreationAndDestruction()
|
|
|
|
{
|
|
|
|
$this->expectNotToPerformAssertions();
|
|
|
|
$pkcs7 = PKCS7::new();
|
|
|
|
unset($pkcs7);
|
|
|
|
}
|
|
|
|
|
2019-11-25 22:05:11 +00:00
|
|
|
public function testLoadDER()
|
|
|
|
{
|
2019-11-24 23:45:19 +00:00
|
|
|
$der = file_get_contents(__DIR__ . "/data/pkcs7/1.RSA");
|
|
|
|
$pkcs7 = PKCS7::loadFromDER($der);
|
2019-11-25 22:05:11 +00:00
|
|
|
$newDer = $pkcs7->toDER();
|
|
|
|
$this->assertEquals($der, $newDer);
|
2019-11-24 23:45:19 +00:00
|
|
|
$this->assertEquals(PKCS7::NID_SIGNED, $pkcs7->getType());
|
|
|
|
}
|
2019-11-25 22:05:11 +00:00
|
|
|
|
|
|
|
public function testLoadingGarbageDER()
|
|
|
|
{
|
|
|
|
$this->expectException(RuntimeException::class);
|
|
|
|
$this->expectExceptionMessage("Failed loading DER");
|
|
|
|
|
|
|
|
PKCS7::loadFromDER("blaat");
|
|
|
|
}
|
2019-11-24 23:45:19 +00:00
|
|
|
}
|