Skip to content

Commit

Permalink
Add missing elements X509CRL and X509SKI
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 17, 2025
1 parent ae601fb commit feb95e1
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/XML/ds/X509CRL.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\XML\ds;

use SimpleSAML\XML\Base64ElementTrait;

/**
* Class representing a ds:X509CRL element.
*
* @package simplesaml/xml-security
*/
final class X509CRL extends AbstractDsElement
{
use Base64ElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
26 changes: 26 additions & 0 deletions src/XML/ds/X509SKI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\XML\ds;

use SimpleSAML\XML\Base64ElementTrait;

/**
* Class representing a ds:X509SKI element.
*
* @package simplesaml/xml-security
*/
final class X509SKI extends AbstractDsElement
{
use Base64ElementTrait;


/**
* @param string $content
*/
public function __construct(string $content)
{
$this->setContent($content);
}
}
62 changes: 62 additions & 0 deletions tests/XML/ds/X509CRLTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\Test\XML\ds;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\X509CRL;

use function dirname;
use function strval;

/**
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\X509CRLTest
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractDsElement::class)]
#[CoversClass(X509CRL::class)]
final class X509CRLTest extends TestCase
{
use SerializableElementTestTrait;

/**
*/
public static function setUpBeforeClass(): void
{
self::$testedClass = X509CRL::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 3) . '/resources/xml/ds_X509CRL.xml',
);
}


/**
*/
public function testMarshalling(): void
{
$X509CRL = new X509CRL('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');

$this->assertEquals(
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
strval($X509CRL),
);
}


/**
*/
public function testMarshallingNotBase64(): void
{
$this->expectException(AssertionFailedException::class);
new X509CRL('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
}
}
62 changes: 62 additions & 0 deletions tests/XML/ds/X509SKITest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\XMLSecurity\Test\XML\ds;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\X509SKI;

use function dirname;
use function strval;

/**
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\X509SKITest
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractDsElement::class)]
#[CoversClass(X509SKI::class)]
final class X509SKITest extends TestCase
{
use SerializableElementTestTrait;

/**
*/
public static function setUpBeforeClass(): void
{
self::$testedClass = X509SKI::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 3) . '/resources/xml/ds_X509SKI.xml',
);
}


/**
*/
public function testMarshalling(): void
{
$X509SKI = new X509SKI('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');

$this->assertEquals(
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
strval($X509SKI),
);
}


/**
*/
public function testMarshallingNotBase64(): void
{
$this->expectException(AssertionFailedException::class);
new X509SKI('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
}
}
1 change: 1 addition & 0 deletions tests/resources/xml/ds_X509CRL.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds:X509CRL xmlns:ds="http://www.w3.org/2000/09/xmldsig#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</ds:X509CRL>
1 change: 1 addition & 0 deletions tests/resources/xml/ds_X509SKI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds:X509SKI xmlns:ds="http://www.w3.org/2000/09/xmldsig#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</ds:X509SKI>

0 comments on commit feb95e1

Please sign in to comment.