Skip to content

Commit 47ff576

Browse files
committed
Add ds:SPKISexp element
1 parent e2b2b0c commit 47ff576

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

src/XML/ds/SPKISexp.php

Lines changed: 26 additions & 0 deletions
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:SPKISexp element.
11+
*
12+
* @package simplesaml/xml-security
13+
*/
14+
final class SPKISexp 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/SPKISexpTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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\XML\DOMDocumentFactory;
10+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
11+
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
12+
use SimpleSAML\XMLSecurity\XML\ds\SPKISexp;
13+
14+
use function dirname;
15+
use function strval;
16+
17+
/**
18+
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\SPKISexpTest
19+
*
20+
* @package simplesamlphp/xml-security
21+
*/
22+
#[CoversClass(AbstractDsElement::class)]
23+
#[CoversClass(SPKISexp::class)]
24+
final class SPKISexpTest extends TestCase
25+
{
26+
use SerializableElementTestTrait;
27+
28+
/**
29+
*/
30+
public static function setUpBeforeClass(): void
31+
{
32+
self::$testedClass = SPKISexp::class;
33+
34+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
35+
dirname(__FILE__, 3) . '/resources/xml/ds_SPKISexp.xml',
36+
);
37+
}
38+
39+
40+
/**
41+
*/
42+
public function testMarshalling(): void
43+
{
44+
$SPKISexp = new SPKISexp('GpM6');
45+
46+
$this->assertEquals(
47+
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
48+
strval($SPKISexp),
49+
);
50+
}
51+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds:SPKISexp xmlns:ds="http://www.w3.org/2000/09/xmldsig#">GpM6</ds:SPKISexp>

0 commit comments

Comments
 (0)