1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\ds; |
6
|
|
|
|
7
|
|
|
use DOMDocument; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use SimpleSAML\XML\DOMDocumentFactory; |
10
|
|
|
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; |
11
|
|
|
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; |
12
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
13
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod; |
14
|
|
|
|
15
|
|
|
use function dirname; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\CanonicalizationMethodTest |
19
|
|
|
* |
20
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement |
21
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod |
22
|
|
|
* |
23
|
|
|
* @package simplesamlphp/xml-security |
24
|
|
|
*/ |
25
|
|
|
final class CanonicalizationMethodTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
28
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
*/ |
32
|
|
|
public static function setUpBeforeClass(): void |
33
|
|
|
{ |
34
|
|
|
self::$testedClass = CanonicalizationMethod::class; |
35
|
|
|
|
36
|
|
|
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd'; |
37
|
|
|
|
38
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
39
|
|
|
dirname(__FILE__, 3) . '/resources/xml/ds_CanonicalizationMethod.xml', |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
*/ |
46
|
|
|
public function testMarshalling(): void |
47
|
|
|
{ |
48
|
|
|
$canonicalizationMethod = new CanonicalizationMethod(C::C14N_EXCLUSIVE_WITHOUT_COMMENTS); |
49
|
|
|
|
50
|
|
|
$this->assertEquals( |
51
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
52
|
|
|
strval($canonicalizationMethod), |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
*/ |
59
|
|
|
public function testUnmarshalling(): void |
60
|
|
|
{ |
61
|
|
|
$canonicalizationMethod = CanonicalizationMethod::fromXML(self::$xmlRepresentation->documentElement); |
62
|
|
|
|
63
|
|
|
$this->assertEquals(C::C14N_EXCLUSIVE_WITHOUT_COMMENTS, $canonicalizationMethod->getAlgorithm()); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|