1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\xenc; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SimpleSAML\XML\Attribute as XMLAttribute; |
9
|
|
|
use SimpleSAML\XML\Chunk; |
10
|
|
|
use SimpleSAML\XML\Constants as C; |
11
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
12
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
13
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperty; |
15
|
|
|
|
16
|
|
|
use function dirname; |
17
|
|
|
use function strval; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\EncryptionPropertyTest |
21
|
|
|
* |
22
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement |
23
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractEncryptionPropertyType |
24
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\EncryptionProperty |
25
|
|
|
* |
26
|
|
|
* @package simplesamlphp/xml-security |
27
|
|
|
*/ |
28
|
|
|
final class EncryptionPropertyTest extends TestCase |
29
|
|
|
{ |
30
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
31
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
*/ |
35
|
|
|
public static function setUpBeforeClass(): void |
36
|
|
|
{ |
37
|
|
|
self::$testedClass = EncryptionProperty::class; |
38
|
|
|
|
39
|
|
|
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xenc-schema.xsd'; |
40
|
|
|
|
41
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
42
|
|
|
dirname(__FILE__, 3) . '/resources/xml/xenc_EncryptionProperty.xml', |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
// marshalling |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
*/ |
52
|
|
|
public function testMarshalling(): void |
53
|
|
|
{ |
54
|
|
|
$doc = DOMDocumentFactory::fromString( |
55
|
|
|
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>', |
56
|
|
|
); |
57
|
|
|
/** @var \DOMElement $elt */ |
58
|
|
|
$elt = $doc->documentElement; |
59
|
|
|
|
60
|
|
|
$attr = new XMLAttribute(C::NS_XML, 'xml', 'lang', 'en'); |
61
|
|
|
$encryptionProperty = new EncryptionProperty( |
62
|
|
|
[new Chunk($elt)], |
63
|
|
|
'urn:x-simplesamlphp:phpunit', |
64
|
|
|
'phpunit', |
65
|
|
|
[$attr], |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
$this->assertEquals( |
69
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
70
|
|
|
strval($encryptionProperty), |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|