From 43e661d2a48de37c34f183c34f18d8f7fb7a33ad Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sat, 30 Dec 2023 01:02:12 +0100 Subject: [PATCH] Raise coverage --- src/XML/sp/AbstractIssuedTokenType.php | 5 +- src/XML/sp/AbstractKeyValueTokenType.php | 1 + ...stractRequestSecurityTokenTemplateType.php | 1 + src/XML/sp/AbstractSerElementsType.php | 1 + src/XML/sp/AbstractTokenAssertionType.php | 1 + src/XML/sp/IncludeTokenOpenTypeTrait.php | 51 ------------------- src/XML/sp/IssuerName.php | 2 +- .../XML/sp/EncryptedElementsTest.php | 7 ++- tests/WSSecurity/XML/sp/HttpsTokenTest.php | 1 + tests/WSSecurity/XML/sp/IssuedTokenTest.php | 13 ++++- tests/WSSecurity/XML/sp/KerberosTokenTest.php | 1 + tests/WSSecurity/XML/sp/KeyValueTokenTest.php | 1 + tests/WSSecurity/XML/sp/RelTokenTest.php | 1 + .../sp/RequestSecurityTokenTemplateTest.php | 7 ++- .../XML/sp/RequiredElementsTest.php | 7 ++- tests/WSSecurity/XML/sp/SamlTokenTest.php | 1 + .../XML/sp/SecurityContextTokenTest.php | 1 + .../WSSecurity/XML/sp/SignedElementsTest.php | 7 ++- tests/WSSecurity/XML/sp/UsernameTokenTest.php | 1 + tests/WSSecurity/XML/sp/X509TokenTest.php | 1 + 20 files changed, 51 insertions(+), 60 deletions(-) delete mode 100644 src/XML/sp/IncludeTokenOpenTypeTrait.php diff --git a/src/XML/sp/AbstractIssuedTokenType.php b/src/XML/sp/AbstractIssuedTokenType.php index 22a85a18..e673aba0 100644 --- a/src/XML/sp/AbstractIssuedTokenType.php +++ b/src/XML/sp/AbstractIssuedTokenType.php @@ -63,9 +63,9 @@ final public function __construct( /** * Collect the value of the Issuer property. * - * @return \SimpleSAML\WSSecurity\XML\sp\Issuer|\SimpleSAML\WSSecurity\XML\sp\IssuerName + * @return \SimpleSAML\WSSecurity\XML\sp\Issuer|\SimpleSAML\WSSecurity\XML\sp\IssuerName|null */ - public function getIssuer(): Issuer|IssuerName + public function getIssuer(): Issuer|IssuerName|null { return $this->issuer; } @@ -173,6 +173,7 @@ public function toXML(DOMElement $parent = null): DOMElement $this->getRequestSecurityTokenTemplate()->toXML($e); foreach ($this->getElements() as $elt) { + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); } diff --git a/src/XML/sp/AbstractKeyValueTokenType.php b/src/XML/sp/AbstractKeyValueTokenType.php index 500bbf8d..4faa2d8f 100644 --- a/src/XML/sp/AbstractKeyValueTokenType.php +++ b/src/XML/sp/AbstractKeyValueTokenType.php @@ -144,6 +144,7 @@ public function toXML(DOMElement $parent = null): DOMElement } foreach ($this->getElements() as $elt) { + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); } diff --git a/src/XML/sp/AbstractRequestSecurityTokenTemplateType.php b/src/XML/sp/AbstractRequestSecurityTokenTemplateType.php index 78910483..09217385 100644 --- a/src/XML/sp/AbstractRequestSecurityTokenTemplateType.php +++ b/src/XML/sp/AbstractRequestSecurityTokenTemplateType.php @@ -142,6 +142,7 @@ public function toXML(DOMElement $parent = null): DOMElement } foreach ($this->getElements() as $elt) { + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); } diff --git a/src/XML/sp/AbstractSerElementsType.php b/src/XML/sp/AbstractSerElementsType.php index 918e4161..3db93451 100644 --- a/src/XML/sp/AbstractSerElementsType.php +++ b/src/XML/sp/AbstractSerElementsType.php @@ -146,6 +146,7 @@ public function toXML(DOMElement $parent = null): DOMElement } foreach ($this->getElements() as $elt) { + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); } diff --git a/src/XML/sp/AbstractTokenAssertionType.php b/src/XML/sp/AbstractTokenAssertionType.php index caea9707..eb9ed4b2 100644 --- a/src/XML/sp/AbstractTokenAssertionType.php +++ b/src/XML/sp/AbstractTokenAssertionType.php @@ -144,6 +144,7 @@ public function toXML(DOMElement $parent = null): DOMElement } foreach ($this->getElements() as $elt) { + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ $elt->toXML($e); } diff --git a/src/XML/sp/IncludeTokenOpenTypeTrait.php b/src/XML/sp/IncludeTokenOpenTypeTrait.php deleted file mode 100644 index 42663acb..00000000 --- a/src/XML/sp/IncludeTokenOpenTypeTrait.php +++ /dev/null @@ -1,51 +0,0 @@ -includeToken; - } - - - /** - * Set the value of the includeToken-property - * - * @param \SimpleSAML\WSSecurity\XML\sp\IncludeToken|string $includeToken - */ - protected function setIncludeToken(IncludeToken|string $includeToken): void - { - if (is_string($includeToken)) { - Assert::validURI($includeToken); - } - - $this->includeToken = $includeToken; - } -} diff --git a/src/XML/sp/IssuerName.php b/src/XML/sp/IssuerName.php index ac230827..da22541f 100644 --- a/src/XML/sp/IssuerName.php +++ b/src/XML/sp/IssuerName.php @@ -33,7 +33,7 @@ public function __construct( * Validate the content of the element. * * @param string $content The value to go in the XML textContent - * @throws \SimpleSAML\XML\Exception\SchemaViolationExcetion on failure + * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure * @return void */ protected function validateContent(string $content): void diff --git a/tests/WSSecurity/XML/sp/EncryptedElementsTest.php b/tests/WSSecurity/XML/sp/EncryptedElementsTest.php index 4d2c14e7..f841cc48 100644 --- a/tests/WSSecurity/XML/sp/EncryptedElementsTest.php +++ b/tests/WSSecurity/XML/sp/EncryptedElementsTest.php @@ -67,7 +67,12 @@ public function testMarshallingElementOrdering(): void // Test ordering of EncryptedElements contents /** @psalm-var \DOMElement[] $EncryptedElementsElements */ - $EncryptedElementsElements = XMLXPath::xpQuery($EncryptedElementsElement, './sp:XPath/following-sibling::*', $xpCache); + $EncryptedElementsElements = XMLXPath::xpQuery( + $EncryptedElementsElement, + './sp:XPath/following-sibling::*', + $xpCache, + ); + $this->assertCount(1, $EncryptedElementsElements); $this->assertEquals('ssp:Chunk', $EncryptedElementsElements[0]->tagName); } diff --git a/tests/WSSecurity/XML/sp/HttpsTokenTest.php b/tests/WSSecurity/XML/sp/HttpsTokenTest.php index a5d11ddd..0160ce9c 100644 --- a/tests/WSSecurity/XML/sp/HttpsTokenTest.php +++ b/tests/WSSecurity/XML/sp/HttpsTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\HttpsTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\HttpsToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/IssuedTokenTest.php b/tests/WSSecurity/XML/sp/IssuedTokenTest.php index 2668811c..1549115a 100644 --- a/tests/WSSecurity/XML/sp/IssuedTokenTest.php +++ b/tests/WSSecurity/XML/sp/IssuedTokenTest.php @@ -24,6 +24,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\IssuedTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\IssuedToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractIssuedTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * @@ -58,7 +59,11 @@ public function testMarshallingElementOrdering(): void $chunk = new Chunk(DOMDocumentFactory::fromString( 'some' )->documentElement); - $requestSecurityTokenTemplate = new RequestSecurityTokenTemplate('urn:x-simplesamlphp:version', [$chunk], [$attr]); + $requestSecurityTokenTemplate = new RequestSecurityTokenTemplate( + 'urn:x-simplesamlphp:version', + [$chunk], + [$attr], + ); $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, IncludeToken::Always, [$chunk], [$attr]); $issuedTokenElement = $issuedToken->toXML(); @@ -91,7 +96,11 @@ public function testMarshalling(): void )->documentElement); $issuer = new IssuerName('urn:x-simplesamlphp:issuer'); - $requestSecurityTokenTemplate = new RequestSecurityTokenTemplate('urn:x-simplesamlphp:version', [$chunk], [$attr]); + $requestSecurityTokenTemplate = new RequestSecurityTokenTemplate( + 'urn:x-simplesamlphp:version', + [$chunk], + [$attr], + ); $issuedToken = new IssuedToken($requestSecurityTokenTemplate, $issuer, IncludeToken::Always, [$chunk], [$attr]); $this->assertEquals( diff --git a/tests/WSSecurity/XML/sp/KerberosTokenTest.php b/tests/WSSecurity/XML/sp/KerberosTokenTest.php index ccb6ef8c..918522c3 100644 --- a/tests/WSSecurity/XML/sp/KerberosTokenTest.php +++ b/tests/WSSecurity/XML/sp/KerberosTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\KerberosTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\KerberosToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/KeyValueTokenTest.php b/tests/WSSecurity/XML/sp/KeyValueTokenTest.php index cc77b209..25ae2a67 100644 --- a/tests/WSSecurity/XML/sp/KeyValueTokenTest.php +++ b/tests/WSSecurity/XML/sp/KeyValueTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\KeyValueTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\KeyValueToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractKeyValueTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/RelTokenTest.php b/tests/WSSecurity/XML/sp/RelTokenTest.php index 74eb4d3e..20621a22 100644 --- a/tests/WSSecurity/XML/sp/RelTokenTest.php +++ b/tests/WSSecurity/XML/sp/RelTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\RelTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\RelToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/RequestSecurityTokenTemplateTest.php b/tests/WSSecurity/XML/sp/RequestSecurityTokenTemplateTest.php index 04ea5c17..93dae9e3 100644 --- a/tests/WSSecurity/XML/sp/RequestSecurityTokenTemplateTest.php +++ b/tests/WSSecurity/XML/sp/RequestSecurityTokenTemplateTest.php @@ -54,7 +54,12 @@ public function testMarshalling(): void 'some' )->documentElement); - $RequestSecurityTokenTemplateElements = new RequestSecurityTokenTemplate('urn:x-simplesamlphp:version', [$chunk], [$attr]); + $RequestSecurityTokenTemplateElements = new RequestSecurityTokenTemplate( + 'urn:x-simplesamlphp:version', + [$chunk], + [$attr], + ); + $this->assertEquals( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($RequestSecurityTokenTemplateElements), diff --git a/tests/WSSecurity/XML/sp/RequiredElementsTest.php b/tests/WSSecurity/XML/sp/RequiredElementsTest.php index 7734f795..071c4b74 100644 --- a/tests/WSSecurity/XML/sp/RequiredElementsTest.php +++ b/tests/WSSecurity/XML/sp/RequiredElementsTest.php @@ -67,7 +67,12 @@ public function testMarshallingElementOrdering(): void // Test ordering of RequiredElements contents /** @psalm-var \DOMElement[] $requiredElementsElements */ - $requiredElementsElements = XMLXPath::xpQuery($requiredElementsElement, './sp:XPath/following-sibling::*', $xpCache); + $requiredElementsElements = XMLXPath::xpQuery( + $requiredElementsElement, + './sp:XPath/following-sibling::*', + $xpCache, + ); + $this->assertCount(1, $requiredElementsElements); $this->assertEquals('ssp:Chunk', $requiredElementsElements[0]->tagName); } diff --git a/tests/WSSecurity/XML/sp/SamlTokenTest.php b/tests/WSSecurity/XML/sp/SamlTokenTest.php index b24529f1..6fa12d17 100644 --- a/tests/WSSecurity/XML/sp/SamlTokenTest.php +++ b/tests/WSSecurity/XML/sp/SamlTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\SamlTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\SamlToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/SecurityContextTokenTest.php b/tests/WSSecurity/XML/sp/SecurityContextTokenTest.php index e888b408..9e712be9 100644 --- a/tests/WSSecurity/XML/sp/SecurityContextTokenTest.php +++ b/tests/WSSecurity/XML/sp/SecurityContextTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\SecurityContextTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\SecurityContextToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/SignedElementsTest.php b/tests/WSSecurity/XML/sp/SignedElementsTest.php index e8c7d7a1..e25af2c6 100644 --- a/tests/WSSecurity/XML/sp/SignedElementsTest.php +++ b/tests/WSSecurity/XML/sp/SignedElementsTest.php @@ -67,7 +67,12 @@ public function testMarshallingElementOrdering(): void // Test ordering of SignedElements contents /** @psalm-var \DOMElement[] $SignedElementsElements */ - $SignedElementsElements = XMLXPath::xpQuery($SignedElementsElement, './sp:XPath/following-sibling::*', $xpCache); + $SignedElementsElements = XMLXPath::xpQuery( + $SignedElementsElement, + './sp:XPath/following-sibling::*', + $xpCache, + ); + $this->assertCount(1, $SignedElementsElements); $this->assertEquals('ssp:Chunk', $SignedElementsElements[0]->tagName); } diff --git a/tests/WSSecurity/XML/sp/UsernameTokenTest.php b/tests/WSSecurity/XML/sp/UsernameTokenTest.php index 26e09ae0..19cebc73 100644 --- a/tests/WSSecurity/XML/sp/UsernameTokenTest.php +++ b/tests/WSSecurity/XML/sp/UsernameTokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\UsernameTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\UsernameToken + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement * diff --git a/tests/WSSecurity/XML/sp/X509TokenTest.php b/tests/WSSecurity/XML/sp/X509TokenTest.php index 2b88ca0d..c3e2a85a 100644 --- a/tests/WSSecurity/XML/sp/X509TokenTest.php +++ b/tests/WSSecurity/XML/sp/X509TokenTest.php @@ -22,6 +22,7 @@ * Class \SimpleSAML\WSSecurity\XML\sp\X509lTokenTest * * @covers \SimpleSAML\WSSecurity\XML\sp\X509Token + * @covers \SimpleSAML\WSSecurity\XML\sp\IncludeTokenTypeTrait * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractAssertionTokenType * @covers \SimpleSAML\WSSecurity\XML\sp\AbstractSpElement *