Passed
Branch master (c86cc6)
by Tim
03:54
created

SecurityTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCompareStrings() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\Utils;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XMLSecurity\Utils\Security;
9
10
/**
11
 * A class to test SimpleSAML\XMLSecurity\Utils\Security.
12
 *
13
 * @package SimpleSAML\XMLSecurity\Utils
14
 */
15
final class SecurityTest extends TestCase
16
{
17
    /**
18
     * Test the constant-time comparison function.
19
     */
20
    public function testCompareStrings(): void
21
    {
22
        // test that two equal strings compare successfully
23
        $this->assertTrue(Security::compareStrings('random string', 'random string'));
24
25
        // test that two different, equal-length strings fail to compare
26
        $this->assertFalse(Security::compareStrings('random string', 'string random'));
27
28
        // test that two different-length strings fail to compare
29
        $this->assertFalse(Security::compareStrings('one string', 'one string      '));
30
    }
31
}
32