1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\ds; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
9
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
10
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
11
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
12
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\DigestMethod; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\DigestValue; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Manifest; |
15
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Reference; |
16
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Transform; |
17
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Transforms; |
18
|
|
|
|
19
|
|
|
use function dirname; |
20
|
|
|
use function strval; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\ManifestTest |
24
|
|
|
* |
25
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\Manifest |
26
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement |
27
|
|
|
* |
28
|
|
|
* @package simplesamlphp/saml2 |
29
|
|
|
*/ |
30
|
|
|
final class ManifestTest extends TestCase |
31
|
|
|
{ |
32
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
33
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
*/ |
38
|
|
|
public static function setUpBeforeClass(): void |
39
|
|
|
{ |
40
|
|
|
self::$testedClass = Manifest::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_Manifest.xml', |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
*/ |
52
|
|
|
public function testMarshalling(): void |
53
|
|
|
{ |
54
|
|
|
$reference = new Reference( |
55
|
|
|
new DigestMethod(C::DIGEST_SHA256), |
56
|
|
|
new DigestValue('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='), |
57
|
|
|
new Transforms( |
58
|
|
|
[ |
59
|
|
|
new Transform(C::XMLDSIG_ENVELOPED), |
60
|
|
|
new Transform(C::C14N_EXCLUSIVE_WITHOUT_COMMENTS), |
61
|
|
|
], |
62
|
|
|
), |
63
|
|
|
'abc123', |
64
|
|
|
C::XMLDSIG_MANIFEST, |
65
|
|
|
'#_1e280ee704fb1d8d9dec4bd6c1889ec96942921153', |
66
|
|
|
); |
67
|
|
|
$manifest = new Manifest([$reference], 'abc123'); |
68
|
|
|
|
69
|
|
|
$this->assertEquals( |
70
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
71
|
|
|
strval($manifest), |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
*/ |
78
|
|
|
public function testUnmarshalling(): void |
79
|
|
|
{ |
80
|
|
|
$manifest = Manifest::fromXML(self::$xmlRepresentation->documentElement); |
81
|
|
|
|
82
|
|
|
$this->assertEquals( |
83
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
84
|
|
|
strval($manifest), |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|