Skip to content

Commit

Permalink
Raise coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Nov 30, 2024
1 parent 55defa2 commit e2b2b0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/XML/ds/X509Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/XML/ds/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function testMarshalling(): void
'#_1e280ee704fb1d8d9dec4bd6c1889ec96942921153',
);

$this->assertFalse($reference->isXPointer());
$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($reference),
Expand Down

0 comments on commit e2b2b0c

Please sign in to comment.