Passed
Push — master ( 2d3781...f48916 )
by Tim
11:07 queued 06:44
created

PBKDF2paramsTest::testMarshalling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 23
rs 9.7998
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\SAML2\XML\xenc11;
6
7
use PHPUnit\Framework\Attributes\CoversClass;
1 ignored issue
show
Bug introduced by
The type PHPUnit\Framework\Attributes\CoversClass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\XML\Attribute as XMLAttribute;
10
use SimpleSAML\XML\Chunk;
11
use SimpleSAML\XML\DOMDocumentFactory;
12
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
13
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
14
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractPBKDF2ParameterType;
15
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractXenc11Element;
16
use SimpleSAML\XMLSecurity\XML\xenc11\IterationCount;
17
use SimpleSAML\XMLSecurity\XML\xenc11\KeyLength;
18
use SimpleSAML\XMLSecurity\XML\xenc11\OtherSource;
19
use SimpleSAML\XMLSecurity\XML\xenc11\Parameters;
20
use SimpleSAML\XMLSecurity\XML\xenc11\PBKDF2params;
21
use SimpleSAML\XMLSecurity\XML\xenc11\PRF;
22
use SimpleSAML\XMLSecurity\XML\xenc11\Salt;
23
24
use function dirname;
25
use function strval;
26
27
/**
28
 * Class \SimpleSAML\XMLSecurity\XML\xenc11\PBKDF2paramsTest
29
 *
30
 * @package simplesamlphp/xml-security
31
 */
32
#[CoversClass(PBKDF2params::class)]
33
#[CoversClass(AbstractPBKDF2ParameterType::class)]
34
#[CoversClass(AbstractXenc11Element::class)]
35
final class PBKDF2paramsTest extends TestCase
36
{
37
    use SchemaValidationTestTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TestUtils\SchemaValidationTestTrait requires some properties which are not provided by SimpleSAML\Test\SAML2\XML\xenc11\PBKDF2paramsTest: $documentElement, $ownerDocument, $message, $line
Loading history...
38
    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\Test\SAML2\XML\xenc11\PBKDF2paramsTest.
Loading history...
39
40
    /**
41
     */
42
    public static function setUpBeforeClass(): void
43
    {
44
        self::$testedClass = PBKDF2params::class;
45
46
        self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xenc-schema-11.xsd';
47
48
        self::$xmlRepresentation = DOMDocumentFactory::fromFile(
49
            dirname(__FILE__, 3) . '/resources/xml/xenc11_PBKDF2-params.xml',
50
        );
51
    }
52
53
54
    // marshalling
55
56
57
    /**
58
     */
59
    public function testMarshalling(): void
60
    {
61
        $someDoc = DOMDocumentFactory::fromString(
62
            '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">Some</ssp:Chunk>',
63
        );
64
65
        $parameters = new Parameters(
66
            [new Chunk($someDoc->documentElement)],
67
            [new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1')],
68
        );
69
70
        $otherSource = new OtherSource('urn:x-simplesamlphp:algorithm', $parameters);
71
72
        $salt = new Salt($otherSource);
73
        $iterationCount = new IterationCount(3);
74
        $keyLength = new KeyLength(4096);
75
        $prf = new PRF('urn:x-simplesamlphp:algorithm');
76
77
        $PBKDF2params = new PBKDF2params($salt, $iterationCount, $keyLength, $prf);
78
79
        $this->assertEquals(
80
            self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
81
            strval($PBKDF2params),
82
        );
83
    }
84
}
85