1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\xenc; |
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, StringValue}; |
12
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\{Transform, Transforms, XPath}; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\{AbstractXencElement, DataReference, KeyReference, ReferenceList}; |
15
|
|
|
|
16
|
|
|
use function dirname; |
17
|
|
|
use function strval; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\ReferenceListTest |
21
|
|
|
* |
22
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement |
23
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\ReferenceList |
24
|
|
|
* |
25
|
|
|
* @package simplesamlphp/xml-security |
26
|
|
|
*/ |
27
|
|
|
#[Group('xenc')] |
28
|
|
|
#[CoversClass(AbstractXencElement::class)] |
29
|
|
|
#[CoversClass(ReferenceList::class)] |
30
|
|
|
final class ReferenceListTest extends TestCase |
31
|
|
|
{ |
32
|
|
|
use SchemaValidationTestTrait; |
33
|
|
|
use SerializableElementTestTrait; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
*/ |
37
|
|
|
public static function setUpBeforeClass(): void |
38
|
|
|
{ |
39
|
|
|
self::$testedClass = ReferenceList::class; |
40
|
|
|
|
41
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
42
|
|
|
dirname(__FILE__, 3) . '/resources/xml/xenc_ReferenceList.xml', |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
// marshalling |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
*/ |
52
|
|
|
public function testMarshalling(): void |
53
|
|
|
{ |
54
|
|
|
$transformData = new Transform( |
55
|
|
|
AnyURIValue::fromString(C::XPATH10_URI), |
56
|
|
|
new XPath( |
57
|
|
|
StringValue::fromString('self::xenc:EncryptedData[@Id="example1"]'), |
58
|
|
|
), |
59
|
|
|
); |
60
|
|
|
$transformKey = new Transform( |
61
|
|
|
AnyURIValue::fromString(C::XPATH10_URI), |
62
|
|
|
new XPath( |
63
|
|
|
StringValue::fromString('self::xenc:EncryptedKey[@Id="example1"]'), |
64
|
|
|
), |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$referenceList = new ReferenceList( |
68
|
|
|
[ |
69
|
|
|
new DataReference( |
70
|
|
|
AnyURIValue::fromString('#Encrypted_DATA_ID'), |
71
|
|
|
[new Transforms([$transformData])], |
72
|
|
|
), |
73
|
|
|
], |
74
|
|
|
[ |
75
|
|
|
new KeyReference( |
76
|
|
|
AnyURIValue::fromString('#Encrypted_KEY_ID'), |
77
|
|
|
[new Transforms([$transformKey])], |
78
|
|
|
), |
79
|
|
|
], |
80
|
|
|
); |
81
|
|
|
|
82
|
|
|
$this->assertEquals( |
83
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
84
|
|
|
strval($referenceList), |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|