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\DOMDocumentFactory; |
10
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
11
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
12
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\AbstractPGPDataType; |
15
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\PGPData; |
16
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\PGPKeyID; |
17
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\PGPKeyPacket; |
18
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\P; |
19
|
|
|
|
20
|
|
|
use function dirname; |
21
|
|
|
use function strval; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\PGPDataTest |
25
|
|
|
* |
26
|
|
|
* @package simplesamlphp/xml-security |
27
|
|
|
*/ |
28
|
|
|
#[CoversClass(AbstractDsElement::class)] |
29
|
|
|
#[CoversClass(AbstractPGPDataType::class)] |
30
|
|
|
#[CoversClass(PGPData::class)] |
31
|
|
|
final class PGPDataTest extends TestCase |
32
|
|
|
{ |
33
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
34
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
*/ |
38
|
|
|
public static function setUpBeforeClass(): void |
39
|
|
|
{ |
40
|
|
|
self::$testedClass = PGPData::class; |
41
|
|
|
|
42
|
|
|
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd'; |
43
|
|
|
|
44
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
45
|
|
|
dirname(__FILE__, 3) . '/resources/xml/ds_PGPData.xml', |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
*/ |
52
|
|
|
public function testMarshalling(): void |
53
|
|
|
{ |
54
|
|
|
$pgpKeyId = new PGPKeyID('GpM7'); |
55
|
|
|
$pgpKeyPacket = new PGPKeyPacket('GpM8'); |
56
|
|
|
$p = new P('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
57
|
|
|
|
58
|
|
|
$pgpData = new PGPData($pgpKeyId, $pgpKeyPacket, [$p]); |
59
|
|
|
|
60
|
|
|
$this->assertEquals( |
61
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
62
|
|
|
strval($pgpData), |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
*/ |
69
|
|
|
public function testMarshallingBothIdAndPacketNullThrowsException(): void |
70
|
|
|
{ |
71
|
|
|
$this->expectException(SchemaViolationException::class); |
72
|
|
|
|
73
|
|
|
new PGPData(null, null, []); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
*/ |
79
|
|
|
public function testMarshallingReferenceElementOrdering(): void |
80
|
|
|
{ |
81
|
|
|
$pgpKeyId = new PGPKeyID('GpM7'); |
82
|
|
|
$pgpKeyPacket = new PGPKeyPacket('GpM8'); |
83
|
|
|
$p = new P('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
84
|
|
|
|
85
|
|
|
$pgpData = new PGPData($pgpKeyId, $pgpKeyPacket, [$p]); |
86
|
|
|
|
87
|
|
|
$pgpDataElement = $pgpData->toXML(); |
88
|
|
|
/** @var \DOMElement[] $children */ |
89
|
|
|
$children = $pgpDataElement->childNodes; |
90
|
|
|
|
91
|
|
|
$this->assertEquals('ds:PGPKeyID', $children[0]->tagName); |
92
|
|
|
$this->assertEquals('ds:PGPKeyPacket', $children[1]->tagName); |
93
|
|
|
$this->assertEquals('xenc:P', $children[2]->tagName); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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