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, StringValue}; |
12
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\{AbstractDsElement, RetrievalMethod}; |
14
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\{Transform, Transforms, XPath}; |
15
|
|
|
|
16
|
|
|
use function dirname; |
17
|
|
|
use function strval; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\RetrievalMethodTest |
21
|
|
|
* |
22
|
|
|
* @package simplesamlphp/saml2 |
23
|
|
|
*/ |
24
|
|
|
#[Group('ds')] |
25
|
|
|
#[CoversClass(AbstractDsElement::class)] |
26
|
|
|
#[CoversClass(RetrievalMethod::class)] |
27
|
|
|
final class RetrievalMethodTest extends TestCase |
28
|
|
|
{ |
29
|
|
|
use SchemaValidationTestTrait; |
30
|
|
|
use SerializableElementTestTrait; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
*/ |
35
|
|
|
public static function setUpBeforeClass(): void |
36
|
|
|
{ |
37
|
|
|
self::$testedClass = RetrievalMethod::class; |
38
|
|
|
|
39
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
40
|
|
|
dirname(__FILE__, 3) . '/resources/xml/ds_RetrievalMethod.xml', |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
*/ |
47
|
|
|
public function testMarshalling(): void |
48
|
|
|
{ |
49
|
|
|
$transforms = new Transforms([ |
50
|
|
|
new Transform( |
51
|
|
|
AnyURIValue::fromString(C::XPATH10_URI), |
52
|
|
|
new XPath( |
53
|
|
|
StringValue::fromString('self::xenc:CipherValue[@Id="example1"]'), |
54
|
|
|
), |
55
|
|
|
), |
56
|
|
|
]); |
57
|
|
|
|
58
|
|
|
$retrievalMethod = new RetrievalMethod( |
59
|
|
|
$transforms, |
60
|
|
|
AnyURIValue::fromString('#Encrypted_KEY_ID'), |
61
|
|
|
AnyURIValue::fromString(C::XMLENC_ENCRYPTEDKEY), |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$this->assertEquals( |
65
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
66
|
|
|
strval($retrievalMethod), |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|