1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Chris Hilsdon <[email protected]> |
4
|
|
|
* @package ComodoDecodeCSR |
5
|
|
|
* @copyright 2016 Xigen |
6
|
|
|
* @license GNU General Public License v3 |
7
|
|
|
* @link https://github.com/XigenChris/ComodoDecodeCSR |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Xigen\Tests; |
11
|
|
|
|
12
|
|
|
use Xigen\ComodoDecodeCSR; |
13
|
|
|
|
14
|
|
|
class DiffrentTextfileCSRTest extends XigenUnit |
15
|
|
|
{ |
16
|
|
|
protected $ComodoDecodeCSR; |
17
|
|
|
protected $Hashes; |
18
|
|
|
|
19
|
5 |
|
public function setUp() |
20
|
|
|
{ |
21
|
5 |
|
$this->ComodoDecodeCSR = new ComodoDecodeCSR(); |
22
|
5 |
|
$this->ComodoDecodeCSR->setCSR($this->loadTestCSR()); |
23
|
5 |
|
$this->Hashes = $this->ComodoDecodeCSR->fetchHashes(); |
24
|
5 |
|
} |
25
|
|
|
|
26
|
5 |
|
private function checkresponse($response) |
27
|
|
|
{ |
28
|
5 |
|
return $this->ComodoDecodeCSR->checkDVC($response); |
29
|
|
|
} |
30
|
|
|
|
31
|
1 |
|
public function testWithEmptyresponse() |
32
|
|
|
{ |
33
|
1 |
|
$response = ""; |
34
|
1 |
|
$test = $this->checkresponse($response); |
35
|
1 |
|
$this->assertFalse($test); |
36
|
1 |
|
} |
37
|
|
|
|
38
|
1 |
|
public function testWithTrailingReturn() |
39
|
|
|
{ |
40
|
1 |
|
$response = "\n"; |
41
|
1 |
|
$test = $this->checkresponse($response); |
42
|
1 |
|
$this->assertFalse($test); |
43
|
1 |
|
} |
44
|
|
|
|
45
|
1 |
|
public function testWithJustSH1() |
46
|
|
|
{ |
47
|
1 |
|
$response = $this->validSHA1 . "\n"; |
48
|
1 |
|
$test = $this->checkresponse($response); |
49
|
1 |
|
$this->assertFalse($test); |
50
|
1 |
|
} |
51
|
|
|
|
52
|
1 |
View Code Duplication |
public function testWithSH1AndComdoText() |
|
|
|
|
53
|
|
|
{ |
54
|
1 |
|
$response = $this->validSHA1 . "\n"; |
55
|
1 |
|
$response .= "comodoca.com\n"; |
56
|
1 |
|
$test = $this->checkresponse($response); |
57
|
1 |
|
$this->assertTrue($test); |
58
|
1 |
|
} |
59
|
|
|
|
60
|
1 |
View Code Duplication |
public function testWithSH1AndComdoTextNoTrailingReturn() |
|
|
|
|
61
|
|
|
{ |
62
|
1 |
|
$response = $this->validSHA1 . "\n"; |
63
|
1 |
|
$response .= "comodoca.com"; |
64
|
1 |
|
$test = $this->checkresponse($response); |
65
|
1 |
|
$this->assertTrue($test); |
66
|
1 |
|
} |
67
|
|
|
} |
68
|
|
|
|
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.