|
@@ 11-24 (lines=14) @@
|
| 8 |
|
|
| 9 |
|
class SignedRequest extends atoum\test |
| 10 |
|
{ |
| 11 |
|
public function test_authenticate_invalid_signature_lead_to_exception() |
| 12 |
|
{ |
| 13 |
|
$this |
| 14 |
|
->given( |
| 15 |
|
$mockSignatureConfig = new \mock\Rezzza\SecurityBundle\Security\Firewall\SignatureConfig(true, 'sha1', 's3cr3t'), |
| 16 |
|
$mockReplayProtection = new \mock\Rezzza\SecurityBundle\Security\Firewall\ReplayProtection(true, 100), |
| 17 |
|
$sut = new SUT('GET', 'localhost', '/url', 'content', 123) |
| 18 |
|
) |
| 19 |
|
->exception(function () use ($sut, $mockSignatureConfig, $mockReplayProtection) { |
| 20 |
|
$sut->authenticateSignature('LALALALAAL', $mockSignatureConfig, $mockReplayProtection); |
| 21 |
|
}) |
| 22 |
|
->isInstanceOf('Rezzza\SecurityBundle\Security\Firewall\InvalidSignatureException') |
| 23 |
|
; |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
public function test_replay_protected_denied_lead_to_exception() |
| 27 |
|
{ |
|
@@ 26-40 (lines=15) @@
|
| 23 |
|
; |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
public function test_replay_protected_denied_lead_to_exception() |
| 27 |
|
{ |
| 28 |
|
$this |
| 29 |
|
->given( |
| 30 |
|
$mockSignatureConfig = new \mock\Rezzza\SecurityBundle\Security\Firewall\SignatureConfig(true, 'sha1', 's3cr3t'), |
| 31 |
|
$mockReplayProtection = new \mock\Rezzza\SecurityBundle\Security\Firewall\ReplayProtection(true, 100), |
| 32 |
|
$mockReplayProtection->getMockController()->accept = false, |
| 33 |
|
$sut = new SUT('GET', 'localhost', '/url', 'content', 123) |
| 34 |
|
) |
| 35 |
|
->exception(function () use ($sut, $mockSignatureConfig, $mockReplayProtection) { |
| 36 |
|
$sut->authenticateSignature('68a9f810beed3c8bbbf98096a60d36ade5f81d42', $mockSignatureConfig, $mockReplayProtection); |
| 37 |
|
}) |
| 38 |
|
->isInstanceOf('Rezzza\SecurityBundle\Security\Firewall\ExpiredSignatureException') |
| 39 |
|
; |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
public function test_it_should_authenticated_valid_signature_not_expired() |
| 43 |
|
{ |
|
@@ 59-73 (lines=15) @@
|
| 56 |
|
; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public function test_signature_generated_with_replay_protection_should_not_be_the_same_without() |
| 60 |
|
{ |
| 61 |
|
$this |
| 62 |
|
->given( |
| 63 |
|
$mockSignatureConfig = new \mock\Rezzza\SecurityBundle\Security\Firewall\SignatureConfig(false, 'sha1', 's3cr3t'), |
| 64 |
|
$mockReplayProtection = new \mock\Rezzza\SecurityBundle\Security\Firewall\ReplayProtection(true, 100), |
| 65 |
|
$mockReplayProtection->getMockController()->accept = true, |
| 66 |
|
$sut = new SUT('GET', 'localhost', '/url', 'content', 123) |
| 67 |
|
) |
| 68 |
|
->exception(function () use ($sut, $mockSignatureConfig, $mockReplayProtection) { |
| 69 |
|
$sut->authenticateSignature('68a9f810beed3c8bbbf98096a60d36ade5f81d42', $mockSignatureConfig, $mockReplayProtection); |
| 70 |
|
}) |
| 71 |
|
->isInstanceOf('Rezzza\SecurityBundle\Security\Firewall\InvalidSignatureException') |
| 72 |
|
; |
| 73 |
|
} |
| 74 |
|
} |
| 75 |
|
|