SigTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFactory() 0 27 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Tests\Rdata;
15
16
use Badcow\DNS\Algorithms;
17
use Badcow\DNS\Rdata\A;
18
use Badcow\DNS\Rdata\Factory;
19
use PHPUnit\Framework\TestCase;
20
21
class SigTest extends TestCase
22
{
23
    public function testFactory(): void
24
    {
25
        $signature = base64_decode('oJB1W6WNGv+ldvQ3WDG0MQkg5IEhjRip8WTrPYGv07h108dUKGMeDPKijVCHX3DDKdfb+v6oB9wfuh3DTJXUA'.
26
            'fI/M0zmO/zz8bW0Rznl8O3tGNazPwQKkRN20XPXV6nwwfoXmJQbsLNrLfkGJ5D6fwFm8nN+6pBzeDQfsS3Ap3o=');
27
28
        $sig = Factory::SIG(
29
            A::TYPE,
30
            Algorithms::RSASHA1,
31
            3,
32
            86400,
33
            \DateTime::createFromFormat('Ymd H:i:s', '20220101 00:00:00'),
0 ignored issues
show
Security Bug introduced by
It seems like \DateTime::createFromFor...', '20220101 00:00:00') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\Factory::SIG() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
34
            \DateTime::createFromFormat('Ymd H:i:s', '20180101 00:00:00'),
0 ignored issues
show
Security Bug introduced by
It seems like \DateTime::createFromFor...', '20180101 00:00:00') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\Factory::SIG() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
35
            2642,
36
            'example.com.',
37
            $signature
38
        );
39
40
        $this->assertEquals(A::TYPE, $sig->getTypeCovered());
41
        $this->assertEquals(Algorithms::RSASHA1, $sig->getAlgorithm());
42
        $this->assertEquals(3, $sig->getLabels());
43
        $this->assertEquals(86400, $sig->getOriginalTtl());
44
        $this->assertEquals(\DateTime::createFromFormat('Ymd H:i:s', '20220101 00:00:00'), $sig->getSignatureExpiration());
45
        $this->assertEquals(\DateTime::createFromFormat('Ymd H:i:s', '20180101 00:00:00'), $sig->getSignatureInception());
46
        $this->assertEquals(2642, $sig->getKeyTag());
47
        $this->assertEquals('example.com.', $sig->getSignersName());
48
        $this->assertEquals($signature, $sig->getSignature());
49
    }
50
}
51