|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\ds; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Attributes\CoversClass; |
|
|
|
|
|
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
use SimpleSAML\XML\Chunk; |
|
10
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
|
11
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
|
12
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
|
13
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
|
14
|
|
|
use SimpleSAML\XMLSecurity\Utils\XPath; |
|
15
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement; |
|
16
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\HMACOutputLength; |
|
17
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\SignatureMethod; |
|
18
|
|
|
|
|
19
|
|
|
use function dirname; |
|
20
|
|
|
use function strval; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\SignatureMethodTest |
|
24
|
|
|
* |
|
25
|
|
|
* @package simplesamlphp/xml-security |
|
26
|
|
|
*/ |
|
27
|
|
|
#[CoversClass(AbstractDsElement::class)] |
|
28
|
|
|
#[CoversClass(SignatureMethod::class)] |
|
29
|
|
|
final class SignatureMethodTest extends TestCase |
|
30
|
|
|
{ |
|
31
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
|
|
32
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function setUpBeforeClass(): void |
|
37
|
|
|
{ |
|
38
|
|
|
self::$testedClass = SignatureMethod::class; |
|
39
|
|
|
|
|
40
|
|
|
self::$schemaFile = dirname(__FILE__, 3) . '/resources/schemas/simplesamlphp.xsd'; |
|
41
|
|
|
|
|
42
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
|
43
|
|
|
dirname(__FILE__, 3) . '/resources/xml/ds_SignatureMethod.xml', |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testMarshalling(): void |
|
51
|
|
|
{ |
|
52
|
|
|
$hmacOutputLength = new HMACOutputLength('1234'); |
|
53
|
|
|
|
|
54
|
|
|
$chunk = new Chunk(DOMDocumentFactory::fromString( |
|
55
|
|
|
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>', |
|
56
|
|
|
)->documentElement); |
|
57
|
|
|
|
|
58
|
|
|
$signatureMethod = new SignatureMethod(C::SIG_RSA_SHA256, $hmacOutputLength, [$chunk]); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertEquals( |
|
61
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
|
62
|
|
|
strval($signatureMethod), |
|
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
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths