|
11 | 11 | use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
12 | 12 | use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
13 | 13 | use SimpleSAML\XMLSecurity\Constants as C; |
| 14 | +use SimpleSAML\XMLSecurity\Utils\XPath; |
14 | 15 | use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement; |
15 | 16 | use SimpleSAML\XMLSecurity\XML\ds\HMACOutputLength; |
16 | 17 | use SimpleSAML\XMLSecurity\XML\ds\SignatureMethod; |
@@ -61,4 +62,36 @@ public function testMarshalling(): void |
61 | 62 | strval($signatureMethod), |
62 | 63 | ); |
63 | 64 | } |
| 65 | + |
| 66 | + |
| 67 | + /** |
| 68 | + */ |
| 69 | + public function testMarshallingElementOrder(): void |
| 70 | + { |
| 71 | + $hmacOutputLength = new HMACOutputLength('1234'); |
| 72 | + |
| 73 | + $chunk = new Chunk(DOMDocumentFactory::fromString( |
| 74 | + '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>', |
| 75 | + )->documentElement); |
| 76 | + |
| 77 | + $signatureMethod = new SignatureMethod(C::SIG_RSA_SHA256, $hmacOutputLength, [$chunk]); |
| 78 | + |
| 79 | + $signatureMethodElement = $signatureMethod->toXML(); |
| 80 | + |
| 81 | + $xpCache = XPath::getXPath($signatureMethodElement); |
| 82 | + |
| 83 | + $hmacOutputLength = XPath::xpQuery($signatureMethodElement, './ds:HMACOutputLength', $xpCache); |
| 84 | + $this->assertCount(1, $hmacOutputLength); |
| 85 | + |
| 86 | + /** @var \DOMElement[] $signatureMethodElements */ |
| 87 | + $signatureMethodElements = XPath::xpQuery( |
| 88 | + $signatureMethodElement, |
| 89 | + './ds:HMACOutputLength/following-sibling::*', |
| 90 | + $xpCache, |
| 91 | + ); |
| 92 | + |
| 93 | + // Test ordering of SignatureMethod contents |
| 94 | + $this->assertCount(1, $signatureMethodElements); |
| 95 | + $this->assertEquals('ssp:Chunk', $signatureMethodElements[0]->tagName); |
| 96 | + } |
64 | 97 | } |
0 commit comments