Skip to content

Commit feb95e1

Browse files
committed
Add missing elements X509CRL and X509SKI
1 parent ae601fb commit feb95e1

File tree

6 files changed

+178
-0
lines changed

6 files changed

+178
-0
lines changed

src/XML/ds/X509CRL.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\XML\ds;
6+
7+
use SimpleSAML\XML\Base64ElementTrait;
8+
9+
/**
10+
* Class representing a ds:X509CRL element.
11+
*
12+
* @package simplesaml/xml-security
13+
*/
14+
final class X509CRL extends AbstractDsElement
15+
{
16+
use Base64ElementTrait;
17+
18+
19+
/**
20+
* @param string $content
21+
*/
22+
public function __construct(string $content)
23+
{
24+
$this->setContent($content);
25+
}
26+
}

src/XML/ds/X509SKI.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\XML\ds;
6+
7+
use SimpleSAML\XML\Base64ElementTrait;
8+
9+
/**
10+
* Class representing a ds:X509SKI element.
11+
*
12+
* @package simplesaml/xml-security
13+
*/
14+
final class X509SKI extends AbstractDsElement
15+
{
16+
use Base64ElementTrait;
17+
18+
19+
/**
20+
* @param string $content
21+
*/
22+
public function __construct(string $content)
23+
{
24+
$this->setContent($content);
25+
}
26+
}

tests/XML/ds/X509CRLTest.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\Assert\AssertionFailedException;
10+
use SimpleSAML\XML\DOMDocumentFactory;
11+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12+
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
13+
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
14+
use SimpleSAML\XMLSecurity\XML\ds\X509CRL;
15+
16+
use function dirname;
17+
use function strval;
18+
19+
/**
20+
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\X509CRLTest
21+
*
22+
* @package simplesamlphp/xml-security
23+
*/
24+
#[CoversClass(AbstractDsElement::class)]
25+
#[CoversClass(X509CRL::class)]
26+
final class X509CRLTest extends TestCase
27+
{
28+
use SerializableElementTestTrait;
29+
30+
/**
31+
*/
32+
public static function setUpBeforeClass(): void
33+
{
34+
self::$testedClass = X509CRL::class;
35+
36+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
37+
dirname(__FILE__, 3) . '/resources/xml/ds_X509CRL.xml',
38+
);
39+
}
40+
41+
42+
/**
43+
*/
44+
public function testMarshalling(): void
45+
{
46+
$X509CRL = new X509CRL('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
47+
48+
$this->assertEquals(
49+
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
50+
strval($X509CRL),
51+
);
52+
}
53+
54+
55+
/**
56+
*/
57+
public function testMarshallingNotBase64(): void
58+
{
59+
$this->expectException(AssertionFailedException::class);
60+
new X509CRL('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
61+
}
62+
}

tests/XML/ds/X509SKITest.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\Assert\AssertionFailedException;
10+
use SimpleSAML\XML\DOMDocumentFactory;
11+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12+
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper;
13+
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
14+
use SimpleSAML\XMLSecurity\XML\ds\X509SKI;
15+
16+
use function dirname;
17+
use function strval;
18+
19+
/**
20+
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\X509SKITest
21+
*
22+
* @package simplesamlphp/xml-security
23+
*/
24+
#[CoversClass(AbstractDsElement::class)]
25+
#[CoversClass(X509SKI::class)]
26+
final class X509SKITest extends TestCase
27+
{
28+
use SerializableElementTestTrait;
29+
30+
/**
31+
*/
32+
public static function setUpBeforeClass(): void
33+
{
34+
self::$testedClass = X509SKI::class;
35+
36+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
37+
dirname(__FILE__, 3) . '/resources/xml/ds_X509SKI.xml',
38+
);
39+
}
40+
41+
42+
/**
43+
*/
44+
public function testMarshalling(): void
45+
{
46+
$X509SKI = new X509SKI('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
47+
48+
$this->assertEquals(
49+
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation),
50+
strval($X509SKI),
51+
);
52+
}
53+
54+
55+
/**
56+
*/
57+
public function testMarshallingNotBase64(): void
58+
{
59+
$this->expectException(AssertionFailedException::class);
60+
new X509SKI('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=');
61+
}
62+
}

tests/resources/xml/ds_X509CRL.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds:X509CRL xmlns:ds="http://www.w3.org/2000/09/xmldsig#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</ds:X509CRL>

tests/resources/xml/ds_X509SKI.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds:X509SKI xmlns:ds="http://www.w3.org/2000/09/xmldsig#">/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI=</ds:X509SKI>

0 commit comments

Comments
 (0)