Test Failed
Push — master ( ebd18c...f86896 )
by Dani
17:51
created

SignatureTest::testVerifyToleranceError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Postpay\Tests\Http;
4
5
use PHPUnit\Framework\TestCase;
6
use Postpay\Http\Signature;
7
8
class SignatureTest extends TestCase
9
{
10 View Code Duplication
    public function testVerify()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
    {
12
        $timestamp = time();
13
        $signature = hash_hmac('sha256', "{$timestamp}:", 'secret');
14
15
        $result = Signature::verify('', "{$timestamp}:{$signature}", 'secret');
16
        self::assertTrue($result);
17
    }
18
19
    public function testVerifyHeaderError()
20
    {
21
        $result = Signature::verify('', ':', 'secret');
22
        self::assertFalse($result);
23
    }
24
25 View Code Duplication
    public function testVerifyToleranceError()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $timestamp = time() - Signature::DEFAULT_TOLERANCE - 1;
28
        $signature = hash_hmac('sha256', "{$timestamp}:", 'secret');
29
30
        $result = Signature::verify('', "{$timestamp}:{$signature}", 'secret');
31
        self::assertFalse($result);
32
    }
33
}
34