Skip to content

Commit a5407fd

Browse files
committed
Add ds:MgmtData element
1 parent 9fe7dcd commit a5407fd

File tree

4 files changed

+83
-1
lines changed

4 files changed

+83
-1
lines changed

src/XML/ds/MgmtData.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\StringElementTrait;
8+
9+
/**
10+
* Class representing a ds:MgmtData element.
11+
*
12+
* @package simplesamlphp/xml-security
13+
*/
14+
final class MgmtData extends AbstractDsElement
15+
{
16+
use StringElementTrait;
17+
18+
19+
/**
20+
* @param string $content
21+
*/
22+
public function __construct(string $content)
23+
{
24+
$this->setContent($content);
25+
}
26+
}

src/XML/element.registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'KeyName' => '\SimpleSAML\XMLSecurity\XML\ds\KeyName',
1313
'KeyValue' => '\SimpleSAML\XMLSecurity\XML\ds\KeyValue',
1414
'Manifest' => '\SimpleSAML\XMLSecurity\XML\ds\Manifest',
15-
// 'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData',
15+
'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData',
1616
'Object' => '\SimpleSAML\XMLSecurity\XML\ds\DsObject',
1717
// 'PGPData' => '\SimpleSAML\XMLSecurity\XML\ds\PGPData',
1818
'Reference' => '\SimpleSAML\XMLSecurity\XML\ds\Reference',

tests/XML/ds/MgmtDataTest.php

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

0 commit comments

Comments
 (0)