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

tests/Http/SignatureTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
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