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