From e2b2b0cf464b7f98f7121b71b0071595241b7063 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sat, 30 Nov 2024 19:12:32 +0100 Subject: [PATCH] Raise coverage --- src/XML/ds/X509Data.php | 24 ++++++++++++++---------- tests/XML/ds/ReferenceTest.php | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/XML/ds/X509Data.php b/src/XML/ds/X509Data.php index b9c68947..6d7a8e74 100644 --- a/src/XML/ds/X509Data.php +++ b/src/XML/ds/X509Data.php @@ -7,8 +7,8 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\XML\Chunk; -use SimpleSAML\XML\Constants as C; use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XMLSecurity\Constants as C; use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException; use SimpleSAML\XMLSecurity\XML\dsig11\X509Digest; @@ -74,18 +74,22 @@ public static function fromXML(DOMElement $xml): static for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) { if (!($n instanceof DOMElement)) { continue; - } elseif ($n->namespaceURI !== self::NS) { + } elseif ($n->namespaceURI === self::NS) { + $data[] = match ($n->localName) { + 'X509Certificate' => X509Certificate::fromXML($n), + 'X509IssuerSerial' => X509IssuerSerial::fromXML($n), + 'X509SubjectName' => X509SubjectName::fromXML($n), + default => new Chunk($n), + }; + } elseif ($n->namespaceURI === C::NS_XDSIG11) { + $data[] = match ($n->localName) { + 'X509Digest' => X509Digest::fromXML($n), + default => new Chunk($n), + }; + } else { $data[] = new Chunk($n); continue; } - - $data[] = match ($n->localName) { - 'X509Certificate' => X509Certificate::fromXML($n), - 'X509IssuerSerial' => X509IssuerSerial::fromXML($n), - 'X509SubjectName' => X509SubjectName::fromXML($n), - 'X509Digest' => X509Digest::fromXML($n), - default => new Chunk($n), - }; } return new static($data); diff --git a/tests/XML/ds/ReferenceTest.php b/tests/XML/ds/ReferenceTest.php index 610890ab..fe4b51ff 100644 --- a/tests/XML/ds/ReferenceTest.php +++ b/tests/XML/ds/ReferenceTest.php @@ -64,6 +64,7 @@ public function testMarshalling(): void '#_1e280ee704fb1d8d9dec4bd6c1889ec96942921153', ); + $this->assertFalse($reference->isXPointer()); $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($reference),