1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\Test\XML\ds; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SimpleSAML\XML\Chunk; |
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\DigestMethod; |
14
|
|
|
|
15
|
|
|
use function dirname; |
16
|
|
|
use function strval; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class \SimpleSAML\XMLSecurity\XML\Test\ds\DigestMethodTest |
20
|
|
|
* |
21
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement |
22
|
|
|
* @covers \SimpleSAML\XMLSecurity\XML\ds\DigestMethod |
23
|
|
|
* |
24
|
|
|
* @package simplesamlphp/xml-security |
25
|
|
|
*/ |
26
|
|
|
final class DigestMethodTest extends TestCase |
27
|
|
|
{ |
28
|
|
|
use SchemaValidationTestTrait; |
|
|
|
|
29
|
|
|
use SerializableElementTestTrait; |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
*/ |
33
|
|
|
public static function setUpBeforeClass(): void |
34
|
|
|
{ |
35
|
|
|
self::$testedClass = DigestMethod::class; |
36
|
|
|
|
37
|
|
|
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd'; |
38
|
|
|
|
39
|
|
|
self::$xmlRepresentation = DOMDocumentFactory::fromFile( |
40
|
|
|
dirname(__FILE__, 3) . '/resources/xml/ds_DigestMethod.xml', |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
*/ |
47
|
|
|
public function testMarshalling(): void |
48
|
|
|
{ |
49
|
|
|
$digestMethod = new DigestMethod( |
50
|
|
|
C::DIGEST_SHA256, |
51
|
|
|
[ |
52
|
|
|
new Chunk(DOMDocumentFactory::fromString( |
53
|
|
|
'<some:Chunk xmlns:some="urn:test:some">Random</some:Chunk>' |
54
|
|
|
)->documentElement) |
55
|
|
|
], |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
$this->assertEquals( |
59
|
|
|
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
60
|
|
|
strval($digestMethod), |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|