1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\xenc; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\Attributes\CoversClass; |
|
|
|
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
10
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
11
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
12
|
|
|
use SimpleSAML\XMLSecurity\Utils\XPath; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\AbstractDHKeyValueType; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement; |
15
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\DHKeyValue; |
16
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\Generator; |
17
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\P; |
18
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\PgenCounter; |
19
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\Q; |
20
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\Seed; |
21
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\XencPublic; |
22
|
|
|
|
23
|
|
|
use function dirname; |
24
|
|
|
use function strval; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\DHKeyValueTest |
28
|
|
|
* |
29
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement |
30
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractDHKeyValueType |
31
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\DHKeyValue |
32
|
|
|
* |
33
|
|
|
* @package simplesamlphp/xml-security |
34
|
|
|
*/ |
35
|
|
|
#[CoversClass(AbstractXencElement::class)] |
36
|
|
|
#[CoversClass(AbstractDHKeyValueType::class)] |
37
|
|
|
#[CoversClass(DHKeyValue::class)] |
38
|
|
|
final class DHKeyValueTest extends TestCase |
39
|
|
|
{ |
40
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
41
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
*/ |
45
|
|
|
public static function setUpBeforeClass(): void |
46
|
|
|
{ |
47
|
|
|
self::$testedClass = DHKeyValue::class; |
48
|
|
|
|
49
|
|
|
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xenc-schema.xsd'; |
50
|
|
|
|
51
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
52
|
|
|
dirname(__FILE__, 3) . '/resources/xml/xenc_DHKeyValue.xml', |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
*/ |
59
|
|
|
public function testMarshalling(): void |
60
|
|
|
{ |
61
|
|
|
$xencPublic = new XencPublic('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
62
|
|
|
$p = new P('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
63
|
|
|
$q = new Q('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
64
|
|
|
$generator = new Generator('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
65
|
|
|
$seed = new Seed('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
66
|
|
|
$pgenCounter = new PgenCounter('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
67
|
|
|
|
68
|
|
|
$dhKeyValue = new DHKeyValue($xencPublic, $p, $q, $generator, $seed, $pgenCounter); |
69
|
|
|
|
70
|
|
|
$this->assertEquals( |
71
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
72
|
|
|
strval($dhKeyValue), |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
/** |
76
|
|
|
*/ |
77
|
|
|
public function testMarshallingElementOrder(): void |
78
|
|
|
{ |
79
|
|
|
$xencPublic = new XencPublic('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
80
|
|
|
$p = new P('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
81
|
|
|
$q = new Q('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
82
|
|
|
$generator = new Generator('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
83
|
|
|
$seed = new Seed('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
84
|
|
|
$pgenCounter = new PgenCounter('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
85
|
|
|
|
86
|
|
|
$dhKeyValue = new DHKeyValue($xencPublic, $p, $q, $generator, $seed, $pgenCounter); |
87
|
|
|
|
88
|
|
|
// Marshall it to a \DOMElement |
89
|
|
|
$dhKeyValueElement = $dhKeyValue->toXML(); |
90
|
|
|
|
91
|
|
|
$xpCache = XPath::getXPath($dhKeyValueElement); |
92
|
|
|
|
93
|
|
|
// Test for an P |
94
|
|
|
/** @var \DOMElement[] $pElements */ |
95
|
|
|
$pElements = XPath::xpQuery($dhKeyValueElement, './xenc:P', $xpCache); |
96
|
|
|
$this->assertCount(1, $pElements); |
97
|
|
|
|
98
|
|
|
// Test ordering of DHKeyValue contents |
99
|
|
|
/** @var \DOMElement[] $dhKeyValueElements */ |
100
|
|
|
$dhKeyValueElements = XPath::xpQuery( |
101
|
|
|
$dhKeyValueElement, |
102
|
|
|
'./xenc:P/following-sibling::*', |
103
|
|
|
$xpCache, |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
$this->assertCount(5, $dhKeyValueElements); |
107
|
|
|
$this->assertEquals('xenc:Q', $dhKeyValueElements[0]->tagName); |
108
|
|
|
$this->assertEquals('xenc:Generator', $dhKeyValueElements[1]->tagName); |
109
|
|
|
$this->assertEquals('xenc:Public', $dhKeyValueElements[2]->tagName); |
110
|
|
|
$this->assertEquals('xenc:seed', $dhKeyValueElements[3]->tagName); |
111
|
|
|
$this->assertEquals('xenc:pgenCounter', $dhKeyValueElements[4]->tagName); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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