Passed
Push — master ( be09b3...67068d )
by Tim
13:28
created

SignatureValueTest::testUnmarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
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\Assert\AssertionFailedException;
9
use SimpleSAML\XML\DOMDocumentFactory;
10
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
11
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12
use SimpleSAML\XMLSecurity\XML\ds\SignatureValue;
13
14
use function dirname;
15
use function strval;
16
17
/**
18
 * Class \SimpleSAML\XMLSecurity\Test\XML\ds\SignatureValueTest
19
 *
20
 * @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
21
 * @covers \SimpleSAML\XMLSecurity\XML\ds\SignatureValue
22
 *
23
 * @package simplesamlphp/xml-security
24
 */
25
final class SignatureValueTest extends TestCase
26
{
27
    use SchemaValidationTestTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TestUtils\SchemaValidationTestTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\T...L\ds\SignatureValueTest: $documentElement, $ownerDocument, $message, $line
Loading history...
28
    use SerializableElementTestTrait;
0 ignored issues
show
Bug introduced by
The trait SimpleSAML\XML\TestUtils...lizableElementTestTrait requires the property $documentElement which is not provided by SimpleSAML\XMLSecurity\T...L\ds\SignatureValueTest.
Loading history...
29
30
    /**
31
     * Set up the test.
32
     */
33
    public static function setUpBeforeClass(): void
34
    {
35
        self::$testedClass = SignatureValue::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_SignatureValue.xml',
41
        );
42
    }
43
44
45
    /**
46
     * Test creating a SignatureValue from scratch.
47
     */
48
    public function testMarshalling(): void
49
    {
50
        $this->assertEquals(
51
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
52
            strval(new SignatureValue(
53
                'j14G9v6AnsOiEJYgkTg864DG3e/KLqoGpuybPGSGblVTn7ST6M/BsvP7YiVZjLqJEuEvWmf2mW4DPb+pbArzzDcsLWEtNveMrw+F' .
54
                'kWehDUQV9oe20iepo+W46wmj7zB/eWL+Z8MrGvlycoTndJU6CVwHTLsB+dq2FDa7JV4pAPjMY32JZTbiwKhzqw3nEi/eVrujJE4Y' .
55
                'RrlW28D+rXhITfoUAGGvsqPzcwGzp02lnMe2SmXADY1u9lbVjOhUrJpgvWfn9YuiCR+wjvaGMwIwzfJxChLJZOBV+1ad1CyNTiu6' .
56
                'qAblxZ4F8cWlMWJ7f0KkWvtw66HOf2VNR6Qan2Ra7Q==',
57
                'abc123',
58
            )),
59
        );
60
    }
61
62
63
    /**
64
     */
65
    public function testMarshallingNotBase64(): void
66
    {
67
        $this->expectException(AssertionFailedException::class);
68
        $digestValue = new SignatureValue(
0 ignored issues
show
Unused Code introduced by
The assignment to $digestValue is dead and can be removed.
Loading history...
69
            'j14G9v6AnsOiEJYgkTg864DG3e/KLqoGpuybPGSGblVTn7ST6M/BsvP7YiVZjLqJEuEvWmf2mW4DPb+pbArzzDcsLWEtNveMrw+F' .
70
            'kWehDUQV9oe20iepo+W46wmj7zB/eWL+Z8MrGvlycoTndJU6CVwHTLsB+dq2FDa7JV4pAPjMY32JZTbiwKhzqw3nEi/eVrujJE4Y' .
71
            'RrlW28D+rXhITfoUAGGvsqPzcwGzp02lnMe2SmXADY1u9lbVjOhUrJpgvWfn9YuiCR+wjvaGMwIwzfJxChLJZOBV+1ad1CyNTiu6' .
72
            'qblxZ4F8cWlMWJ7f0KkWvtw66HOf2VNR6Qan2Ra7Q==',
73
            'abc123',
74
        );
75
    }
76
}
77