diff --git a/codecov.yml b/codecov.yml index 623fb22c..fe6a1cf9 100644 --- a/codecov.yml +++ b/codecov.yml @@ -16,3 +16,5 @@ comment: branches: null github_checks: annotations: false +ignore: + - 'src/XML/element.registry.php' diff --git a/composer.json b/composer.json index 3afaf109..5db1cf4a 100644 --- a/composer.json +++ b/composer.json @@ -42,18 +42,19 @@ "ext-pcre": "*", "ext-spl": "*", - "simplesamlphp/assert": "^1.1", - "simplesamlphp/xml-common": "^1.15" + "simplesamlphp/assert": "^1.3", + "simplesamlphp/xml-common": "^1.18" }, "require-dev": { - "simplesamlphp/simplesamlphp-test-framework": "^1.5" + "simplesamlphp/simplesamlphp-test-framework": "^1.7" }, "config": { "allow-plugins": { "composer/package-versions-deprecated": true, "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true, "simplesamlphp/composer-module-installer": true, - "phpstan/extension-installer": true + "simplesamlphp/composer-xmlprovider-installer": true } } } diff --git a/src/XML/EncryptableElementTrait.php b/src/XML/EncryptableElementTrait.php index 89021882..fdae4cd2 100644 --- a/src/XML/EncryptableElementTrait.php +++ b/src/XML/EncryptableElementTrait.php @@ -66,7 +66,9 @@ public function encrypt(EncryptionAlgorithmInterface $encryptor): EncryptedData $keyInfo = new KeyInfo([$encryptedKey]); - $factory = new EncryptionAlgorithmFactory($this->getBlacklistedAlgorithms() ?? EncryptionAlgorithmFactory::DEFAULT_BLACKLIST); + $factory = new EncryptionAlgorithmFactory( + $this->getBlacklistedAlgorithms() ?? EncryptionAlgorithmFactory::DEFAULT_BLACKLIST, + ); $encryptor = $factory->getAlgorithm($this->blockCipherAlgId, $sessionKey); $encryptor->setBackend($this->getEncryptionBackend()); } diff --git a/src/XML/EncryptedElementTrait.php b/src/XML/EncryptedElementTrait.php index 987f6d94..5c8c9548 100644 --- a/src/XML/EncryptedElementTrait.php +++ b/src/XML/EncryptedElementTrait.php @@ -131,7 +131,9 @@ protected function decryptData(EncryptionAlgorithmInterface $decryptor): string $encryptedKey = $this->getEncryptedKey(); $decryptionKey = $encryptedKey->decrypt($decryptor); - $factory = new EncryptionAlgorithmFactory($this->getBlacklistedAlgorithms() ?? EncryptionAlgorithmFactory::DEFAULT_BLACKLIST); + $factory = new EncryptionAlgorithmFactory( + $this->getBlacklistedAlgorithms() ?? EncryptionAlgorithmFactory::DEFAULT_BLACKLIST, + ); $decryptor = $factory->getAlgorithm($encMethod->getAlgorithm(), new SymmetricKey($decryptionKey)); $decryptor->setBackend($this->getEncryptionBackend()); } diff --git a/src/XML/SignedElementTrait.php b/src/XML/SignedElementTrait.php index 7572399e..10b7ccbe 100644 --- a/src/XML/SignedElementTrait.php +++ b/src/XML/SignedElementTrait.php @@ -198,7 +198,8 @@ private function verifyInternal(SignatureAlgorithmInterface $verifier): SignedEl if ( $verifier?->verify( $c14nSignedInfo, // the canonicalized ds:SignedInfo element (plaintext) - base64_decode($this->getSignature()->getSignatureValue()->getRawContent(), true), // the actual signature + // the actual signature + base64_decode($this->getSignature()->getSignatureValue()->getRawContent(), true), ) ) { /* diff --git a/src/XML/ds/DigestMethod.php b/src/XML/ds/DigestMethod.php index c4130df6..9ce95f54 100644 --- a/src/XML/ds/DigestMethod.php +++ b/src/XML/ds/DigestMethod.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\SchemaViolationException; use SimpleSAML\XML\ExtendableElementTrait; @@ -29,7 +28,7 @@ final class DigestMethod extends AbstractDsElement * Initialize a DigestMethod element. * * @param string $Algorithm - * @param \SimpleSAML\XML\Chunk[] $elements + * @param list<\SimpleSAML\XML\SerializableElementInterface> $elements */ public function __construct( protected string $Algorithm, @@ -73,15 +72,7 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->namespaceURI, DigestMethod::NS, InvalidDOMElementException::class); $Algorithm = DigestMethod::getAttribute($xml, 'Algorithm'); - - $elements = []; - foreach ($xml->childNodes as $elt) { - if (!($elt instanceof DOMElement)) { - continue; - } - - $elements[] = new Chunk($elt); - } + $elements = self::getChildElementsFromXML($xml); return new static($Algorithm, $elements); } diff --git a/src/XML/ds/DsObject.php b/src/XML/ds/DsObject.php index 44b73164..72f78f5a 100644 --- a/src/XML/ds/DsObject.php +++ b/src/XML/ds/DsObject.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; @@ -112,22 +111,7 @@ public static function fromXML(DOMElement $xml): static $Id = DsObject::getOptionalAttribute($xml, 'Id', null); $MimeType = DsObject::getOptionalAttribute($xml, 'MimeType', null); $Encoding = DsObject::getOptionalAttribute($xml, 'Encoding', null); - - $elements = []; - foreach ($xml->childNodes as $elt) { - if (!($elt instanceof DOMElement)) { - // @TODO: support mixed content - continue; - } elseif ($elt->namespaceURI === self::NS) { - $elements[] = match ($elt->localName) { - 'SignatureProperties' => SignatureProperties::fromXML($elt), - 'Manifest' => Manifest::fromXML($elt), - default => new Chunk($elt), - }; - } - - $elements[] = new Chunk($elt); - } + $elements = self::getChildElementsFromXML($xml); return new static($Id, $MimeType, $Encoding, $elements); } diff --git a/src/XML/ds/KeyInfo.php b/src/XML/ds/KeyInfo.php index 9b05d32f..0f5d8bd8 100644 --- a/src/XML/ds/KeyInfo.php +++ b/src/XML/ds/KeyInfo.php @@ -6,13 +6,12 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\SerializableElementInterface; +use SimpleSAML\XML\XsNamespace as NS; use SimpleSAML\XMLSecurity\Constants as C; use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException; -use SimpleSAML\XMLSecurity\XML\dsig11\KeyInfoReference; -use SimpleSAML\XMLSecurity\XML\xenc\EncryptedData; -use SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey; /** * Class representing a ds:KeyInfo element. @@ -21,11 +20,16 @@ */ final class KeyInfo extends AbstractDsElement { + use ExtendableElementTrait; + + /** @var \SimpleSAML\XML\XsNamespace */ + public const XS_ANY_ELT_NAMESPACE = NS::OTHER; + + /** * Initialize a KeyInfo element. * * @param ( - * \SimpleSAML\XML\SerializableElementInterface| * \SimpleSAML\XMLSecurity\XML\ds\KeyName| * \SimpleSAML\XMLSecurity\XML\ds\KeyValue| * \SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod| @@ -34,29 +38,26 @@ final class KeyInfo extends AbstractDsElement * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData| * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey * )[] $info + * @param \SimpleSAML\XML\SerializableElementInterface[] $children * @param string|null $Id */ public function __construct( protected array $info, + array $children = [], protected ?string $Id = null, ) { - Assert::notEmpty($info, 'ds:KeyInfo cannot be empty', InvalidArgumentException::class); - Assert::maxCount($info, C::UNBOUNDED_LIMIT); - Assert::allIsInstanceOfAny( - $info, - [ - Chunk::class, - KeyName::class, - KeyValue::class, - RetrievalMethod::class, - X509Data::class, - EncryptedData::class, - EncryptedKey::class, - ], - 'KeyInfo can only contain instances of KeyName, X509Data, EncryptedKey or Chunk.', + $combi = array_merge($info, $children); + + Assert::notEmpty($combi, 'ds:KeyInfo cannot be empty', InvalidArgumentException::class); + Assert::maxCount($combi, C::UNBOUNDED_LIMIT); + Assert::allIsInstanceOf( + $combi, + SerializableElementInterface::class, InvalidArgumentException::class, ); Assert::nullOrValidNCName($Id); + + $this->setElements($children); } @@ -74,20 +75,11 @@ public function getId(): ?string /** * Collect the value of the info-property * - * @return ( - * \SimpleSAML\XML\SerializableElementInterface| - * \SimpleSAML\XMLSecurity\XML\ds\KeyName| - * \SimpleSAML\XMLSecurity\XML\ds\KeyValue| - * \SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod| - * \SimpleSAML\XMLSecurity\XML\ds\X509Data| - * \SimpleSAML\XMLSecurity\XML\dsig11\KeyInfoReference| - * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData| - * \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey - * )[] + * @return list<\SimpleSAML\XML\SerializableElementInterface> */ public function getInfo(): array { - return $this->info; + return array_merge($this->info, $this->getElements()); } @@ -106,36 +98,27 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->namespaceURI, KeyInfo::NS, InvalidDOMElementException::class); $Id = self::getOptionalAttribute($xml, 'Id', null); - $info = []; - - foreach ($xml->childNodes as $n) { - if (!($n instanceof DOMElement)) { - continue; - } elseif ($n->namespaceURI === C::NS_XDSIG) { - $info[] = match ($n->localName) { - 'KeyName' => KeyName::fromXML($n), - 'KeyValue' => KeyValue::fromXML($n), - 'RetrievalMethod' => RetrievalMethod::fromXML($n), - 'X509Data' => X509Data::fromXML($n), - default => new Chunk($n), - }; - } elseif ($n->namespaceURI === C::NS_XDSIG11) { - $info[] = match ($n->localName) { - 'KeyInfoReference' => KeyInfoReference::fromXML($n), - default => new Chunk($n), - }; - } elseif ($n->namespaceURI === C::NS_XENC) { - $info[] = match ($n->localName) { - 'EncryptedData' => EncryptedData::fromXML($n), - 'EncryptedKey' => EncryptedKey::fromXML($n), - default => new Chunk($n), - }; - } else { - $info[] = new Chunk($n); - } - } - return new static($info, $Id); + $keyName = KeyName::getChildrenOfClass($xml); + $keyValue = KeyValue::getChildrenOfClass($xml); + $retrievalMethod = RetrievalMethod::getChildrenOfClass($xml); + $x509Data = X509Data::getChildrenOfClass($xml); + //$pgpData = PGPData::getChildrenOfClass($xml); + //$spkiData = SPKIData::getChildrenOfClass($xml); + //$mgmtData = MgmtData::getChildrenOfClass($xml); + + $info = array_merge( + $keyName, + $keyValue, + $retrievalMethod, + $x509Data, + //$pgpdata, + //$spkidata, + //$mgmtdata, + ); + + $children = self::getChildElementsFromXML($xml); + return new static($info, $children, $Id); } @@ -153,8 +136,8 @@ public function toXML(DOMElement $parent = null): DOMElement $e->setAttribute('Id', $this->getId()); } - foreach ($this->getInfo() as $n) { - $n->toXML($e); + foreach ($this->getInfo() as $elt) { + $elt->toXML($e); } return $e; diff --git a/src/XML/ds/KeyValue.php b/src/XML/ds/KeyValue.php index 32a7ce0e..b6f2d018 100644 --- a/src/XML/ds/KeyValue.php +++ b/src/XML/ds/KeyValue.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\ElementInterface; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\SchemaViolationException; @@ -83,14 +82,7 @@ public static function fromXML(DOMElement $xml): static TooManyElementsException::class, ); - $elements = []; - foreach ($xml->childNodes as $element) { - if (!($element instanceof DOMElement) || $element->namespaceURI === KeyValue::NS) { - continue; - } - - $elements[] = new Chunk($element); - } + $elements = self::getChildElementsFromXML($xml); Assert::maxCount( $elements, 1, diff --git a/src/XML/ds/SignatureProperty.php b/src/XML/ds/SignatureProperty.php index b39e8297..c8b312c6 100644 --- a/src/XML/ds/SignatureProperty.php +++ b/src/XML/ds/SignatureProperty.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\MissingElementException; use SimpleSAML\XML\Exception\SchemaViolationException; @@ -81,15 +80,7 @@ public static function fromXML(DOMElement $xml): static $Target = self::getAttribute($xml, 'Target'); $Id = self::getOptionalAttribute($xml, 'Id', null); - $children = []; - foreach ($xml->childNodes as $child) { - if (!($child instanceof DOMElement)) { - continue; - } - - $children[] = new Chunk($child); - } - + $children = self::getChildElementsFromXML($xml); Assert::minCount( $children, 1, diff --git a/src/XML/element.registry.php b/src/XML/element.registry.php new file mode 100644 index 00000000..d891e6f8 --- /dev/null +++ b/src/XML/element.registry.php @@ -0,0 +1,60 @@ + [ + 'CanonicalizationMethod' => '\SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod', + 'DigestMethod' => '\SimpleSAML\XMLSecurity\XML\ds\DigestMethod', + 'DigestValue' => '\SimpleSAML\XMLSecurity\XML\ds\DigestValue', + 'Exponent' => '\SimpleSAML\XMLSecurity\XML\ds\Exponent', + 'KeyInfo' => '\SimpleSAML\XMLSecurity\XML\ds\KeyInfo', + 'KeyName' => '\SimpleSAML\XMLSecurity\XML\ds\KeyName', + 'KeyValue' => '\SimpleSAML\XMLSecurity\XML\ds\KeyValue', + 'Manifest' => '\SimpleSAML\XMLSecurity\XML\ds\Manifest', + 'Modulus' => '\SimpleSAML\XMLSecurity\XML\ds\Modulus', + 'Object' => '\SimpleSAML\XMLSecurity\XML\ds\DsObject', + 'RSAKeyValue' => '\SimpleSAML\XMLSecurity\XML\ds\RSAKeyValue', + 'Reference' => '\SimpleSAML\XMLSecurity\XML\ds\Reference', + 'RetrievalMethod' => '\SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod', + 'Signature' => '\SimpleSAML\XMLSecurity\XML\ds\Signature', + 'SignatureMethod' => '\SimpleSAML\XMLSecurity\XML\ds\SignatureMethod', + 'SignatureProperties' => '\SimpleSAML\XMLSecurity\XML\ds\SignatureProperties', + 'SignatureProperty' => '\SimpleSAML\XMLSecurity\XML\ds\SignatureProperty', + 'SignatureValue' => '\SimpleSAML\XMLSecurity\XML\ds\SignatureValue', + 'SignedInfo' => '\SimpleSAML\XMLSecurity\XML\ds\SignedInfo', + 'Transform' => '\SimpleSAML\XMLSecurity\XML\ds\Transform', + 'Transforms' => '\SimpleSAML\XMLSecurity\XML\ds\Transforms', + 'X509Certificate' => '\SimpleSAML\XMLSecurity\XML\ds\X509Certificate', + 'X509Data' => '\SimpleSAML\XMLSecurity\XML\ds\X509Data', + 'X509IssuerName' => '\SimpleSAML\XMLSecurity\XML\ds\X509IssuerName', + 'X509IssuerSerial' => '\SimpleSAML\XMLSecurity\XML\ds\X509IssuerSerial', + 'X509SerialNumber' => '\SimpleSAML\XMLSecurity\XML\ds\X509SerialNumber', + 'X509SubjectName' => '\SimpleSAML\XMLSecurity\XML\ds\X509SubjectName', + 'XPath' => '\SimpleSAML\XMLSecurity\XML\ds\XPath', + ], + 'http://www.w3.org/2009/xmldsig11#' => [ + 'KeyInfoReference' => '\SimpleSAML\XMLSecurity\XML\dsig11\KeyInfoReference', + 'X509Digest' => '\SimpleSAML\XMLSecurity\XML\dsig11\X509Digest', + ], + 'http://www.w3.org/2001/10/xml-exc-c14n#' => [ + 'InclusiveNamespaces' => '\SimpleSAML\XMLSecurity\XML\ec\InclusiveNamespaces', + ], + 'http://www.w3.org/2001/04/xmlenc#' => [ + 'CarriedKeyName' => '\SimpleSAML\XMLSecurity\XML\xenc\CarriedKeyName', + 'CipherData' => '\SimpleSAML\XMLSecurity\XML\xenc\CipherData', + 'CipherReference' => '\SimpleSAML\XMLSecurity\XML\xenc\CipherReference', + 'CipherValue' => '\SimpleSAML\XMLSecurity\XML\xenc\CipherValue', + 'DataReference' => '\SimpleSAML\XMLSecurity\XML\xenc\DataReference', + 'EncryptedData' => '\SimpleSAML\XMLSecurity\XML\xenc\EncryptedData', + 'EncryptedKey' => '\SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey', + 'EncryptionMethod' => '\SimpleSAML\XMLSecurity\XML\xenc\EncryptionMethod', + 'EncryptionProperties' => '\SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperties', + 'EncryptionProperty' => '\SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperty', + 'KeyReference' => '\SimpleSAML\XMLSecurity\XML\xenc\KeyReference', + 'KeySize' => '\SimpleSAML\XMLSecurity\XML\xenc\KeySize', + 'OAEPparams' => '\SimpleSAML\XMLSecurity\XML\xenc\OAEPparams', + 'ReferenceList' => '\SimpleSAML\XMLSecurity\XML\xenc\ReferenceList', + 'Transforms' => '\SimpleSAML\XMLSecurity\XML\xenc\Transforms', + ], +]; diff --git a/src/XML/xenc/AbstractEncryptionMethod.php b/src/XML/xenc/AbstractEncryptionMethod.php index 8cb44c1f..bafc54fa 100644 --- a/src/XML/xenc/AbstractEncryptionMethod.php +++ b/src/XML/xenc/AbstractEncryptionMethod.php @@ -6,13 +6,11 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\SchemaViolationException; use SimpleSAML\XML\Exception\TooManyElementsException; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\XsNamespace as NS; -use SimpleSAML\XMLSecurity\Constants as C; use function array_pop; @@ -35,7 +33,7 @@ abstract class AbstractEncryptionMethod extends AbstractXencElement * @param string $algorithm * @param \SimpleSAML\XMLSecurity\XML\xenc\KeySize|null $keySize * @param \SimpleSAML\XMLSecurity\XML\xenc\OAEPparams|null $oaepParams - * @param \SimpleSAML\XML\Chunk[] $children + * @param list<\SimpleSAML\XML\SerializableElementInterface> $children */ final public function __construct( protected string $algorithm, @@ -108,20 +106,7 @@ public static function fromXML(DOMElement $xml): static $oaepParams = OAEPparams::getChildrenOfClass($xml); Assert::maxCount($oaepParams, 1, TooManyElementsException::class); - $children = []; - foreach ($xml->childNodes as $node) { - if (!$node instanceof DOMElement) { - continue; - } elseif ($node->namespaceURI === C::NS_XENC) { - if ($node->localName === 'KeySize') { - continue; - } elseif ($node->localName === 'OAEPparams') { - continue; - } - } - - $children[] = Chunk::fromXML($node); - } + $children = self::getChildElementsFromXML($xml); return new static($algorithm, array_pop($keySize), array_pop($oaepParams), $children); } diff --git a/src/XML/xenc/AbstractEncryptionPropertyType.php b/src/XML/xenc/AbstractEncryptionPropertyType.php index c299ab8f..9a56bc77 100644 --- a/src/XML/xenc/AbstractEncryptionPropertyType.php +++ b/src/XML/xenc/AbstractEncryptionPropertyType.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Constants as C; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\MissingElementException; @@ -88,17 +87,8 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); - $children = []; - foreach ($xml->childNodes as $child) { - if (!($child instanceof DOMElement)) { - continue; - } - - $children[] = new Chunk($child); - } - return new static( - $children, + self::getChildElementsFromXML($xml), self::getOptionalAttribute($xml, 'Target', null), self::getOptionalAttribute($xml, 'Id', null), self::getAttributesNSFromXML($xml), diff --git a/src/XML/xenc/AbstractReference.php b/src/XML/xenc/AbstractReference.php index a4d1d6d2..f67f6e1d 100644 --- a/src/XML/xenc/AbstractReference.php +++ b/src/XML/xenc/AbstractReference.php @@ -6,7 +6,6 @@ use DOMElement; use SimpleSAML\Assert\Assert; -use SimpleSAML\XML\Chunk; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\SchemaViolationException; use SimpleSAML\XML\ExtendableElementTrait; @@ -66,13 +65,7 @@ public static function fromXML(DOMElement $xml): static Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); $URI = self::getAttribute($xml, 'URI'); - - $elements = []; - foreach ($xml->childNodes as $element) { - if ($element instanceof DOMElement) { - $elements[] = new Chunk($element); - } - } + $elements = self::getChildElementsFromXML($xml); return new static($URI, $elements); } diff --git a/tests/XML/ds/KeyInfoTest.php b/tests/XML/ds/KeyInfoTest.php index e8e9f547..7c5b38d7 100644 --- a/tests/XML/ds/KeyInfoTest.php +++ b/tests/XML/ds/KeyInfoTest.php @@ -94,6 +94,8 @@ public function testMarshalling(): void new X509SubjectName(self::$certData['name']), ], ), + ], + [ new Chunk(DOMDocumentFactory::fromString( 'some', )->documentElement), diff --git a/tests/XML/ds/KeyValueTest.php b/tests/XML/ds/KeyValueTest.php index b6329157..0ca9f016 100644 --- a/tests/XML/ds/KeyValueTest.php +++ b/tests/XML/ds/KeyValueTest.php @@ -15,6 +15,7 @@ use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement; use SimpleSAML\XMLSecurity\XML\ds\KeyValue; use SimpleSAML\XMLSecurity\XML\ds\RSAKeyValue; +use SimpleSAML\XMLSecurity\XML\xenc\CipherValue; use function dirname; use function strval; @@ -134,8 +135,8 @@ public function testUnmarshallingWithOtherElement(): void $this->assertCount(1, $elements); $element = reset($elements); - $this->assertInstanceOf(Chunk::class, $element); - $this->assertEquals($element->getXML()->textContent, '/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); + $this->assertInstanceOf(CipherValue::class, $element); + $this->assertEquals($element->getContent(), '/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 28c24135..c66a4c65 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,3 +4,6 @@ $projectRoot = dirname(__DIR__); require_once($projectRoot . '/vendor/autoload.php'); + +$registry = \SimpleSAML\XML\Registry\ElementRegistry::getInstance(); +$registry->importFromFile(dirname(__FILE__, 2) . '/src/XML/element.registry.php');