Completed
Push — master ( 5d89d9...b6c216 )
by Robbie
15s queued 10s
created

McryptCryptoTest::testIntegrity()   A

Complexity

Conditions 2
Paths 6

Size

Total Lines 24

Duplication

Lines 5
Ratio 20.83 %

Importance

Changes 0
Metric Value
dl 5
loc 24
rs 9.536
c 0
b 0
f 0
cc 2
nc 6
nop 0
1
<?php
2
3
namespace SilverStripe\HybridSessions\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\HybridSessions\Crypto\McryptCrypto;
7
8
/**
9
 * @requires extension mcrypt
10
 * @skip
11
 */
12
class McryptCryptoTest extends SapphireTest
13
{
14
    public function testIntegrity()
15
    {
16
        $this->markTestSkipped(
17
            'McryptCrypto is losing zero bytes at the end of messages: ' .
18
            'https://github.com/silverstripe/silverstripe-hybridsessions/issues/53'
19
        );
20
21
        $error_reporting = ini_set('error_reporting', (int) ini_get('error_reporting') & ~E_DEPRECATED);
22
23
        try {
24
            $key = random_bytes(8);
25
            $salt = random_bytes(16);
26
27
            $handler = new McryptCrypto($key, $salt);
28
29 View Code Duplication
            for ($i = 0; $i < 1000; ++$i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
30
                $data = random_bytes(1024 * 4);
31
32
                $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
33
            }
34
        } finally {
35
            ini_set('error_reporting', $error_reporting);
36
        }
37
    }
38
}
39