1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\xenc; |
6
|
|
|
|
7
|
|
|
use DOMDocument; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use SimpleSAML\Assert\AssertionFailedException; |
10
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
11
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
12
|
|
|
use SimpleSAML\XMLSecurity\Test\XML\XMLDumper; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\xenc\CipherValue; |
14
|
|
|
|
15
|
|
|
use function dirname; |
16
|
|
|
use function strval; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\xenc\CipherValueTest |
20
|
|
|
* |
21
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\AbstractXencElement |
22
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\xenc\CipherValue |
23
|
|
|
* |
24
|
|
|
* @package simplesamlphp/xml-security |
25
|
|
|
*/ |
26
|
|
|
final class CipherValueTest extends TestCase |
27
|
|
|
{ |
28
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
*/ |
32
|
|
|
public static function setUpBeforeClass(): void |
33
|
|
|
{ |
34
|
|
|
self::$testedClass = CipherValue::class; |
35
|
|
|
|
36
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
37
|
|
|
dirname(__FILE__, 3) . '/resources/xml/xenc_CipherValue.xml', |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
*/ |
44
|
|
|
public function testMarshalling(): void |
45
|
|
|
{ |
46
|
|
|
$cipherValue = new CipherValue('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
47
|
|
|
|
48
|
|
|
$this->assertEquals( |
49
|
|
|
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation), |
50
|
|
|
strval($cipherValue), |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
*/ |
57
|
|
|
public function testMarshallingNotBase64(): void |
58
|
|
|
{ |
59
|
|
|
$this->expectException(AssertionFailedException::class); |
60
|
|
|
new CipherValue('/CTj3d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
*/ |
66
|
|
|
public function testUnmarshalling(): void |
67
|
|
|
{ |
68
|
|
|
$cipherValue = CipherValue::fromXML(self::$xmlRepresentation->documentElement); |
69
|
|
|
|
70
|
|
|
$this->assertEquals( |
71
|
|
|
XMLDumper::dumpDOMDocumentXMLWithBase64Content(self::$xmlRepresentation), |
72
|
|
|
strval($cipherValue), |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|