|
@@ 106-137 (lines=32) @@
|
| 103 |
|
* @expectedException \Emarref\Jwt\Exception\InvalidSignatureException |
| 104 |
|
* @expectedExceptionMessage Signature is invalid. |
| 105 |
|
*/ |
| 106 |
|
public function testInvalidSignature() |
| 107 |
|
{ |
| 108 |
|
$algorithmParameter = $this->getMockBuilder('Emarref\Jwt\HeaderParameter\Algorithm')->getMock(); |
| 109 |
|
|
| 110 |
|
$algorithmParameter->expects($this->once()) |
| 111 |
|
->method('getValue') |
| 112 |
|
->will($this->returnValue('foo')); |
| 113 |
|
|
| 114 |
|
$this->header->expects($this->once()) |
| 115 |
|
->method('findParameterByName') |
| 116 |
|
->with(HeaderParameter\Algorithm::NAME) |
| 117 |
|
->will($this->returnValue($algorithmParameter)); |
| 118 |
|
|
| 119 |
|
$this->encryption->expects($this->once()) |
| 120 |
|
->method('getAlgorithmName') |
| 121 |
|
->will($this->returnValue('foo')); |
| 122 |
|
|
| 123 |
|
$this->encryption->expects($this->once()) |
| 124 |
|
->method('verify') |
| 125 |
|
->will($this->returnValue(false)); |
| 126 |
|
|
| 127 |
|
$this->signer->expects($this->once()) |
| 128 |
|
->method('getUnsignedValue') |
| 129 |
|
->will($this->returnValue('foo')); |
| 130 |
|
|
| 131 |
|
$this->token->expects($this->once()) |
| 132 |
|
->method('getSignature') |
| 133 |
|
->will($this->returnValue('bar')); |
| 134 |
|
|
| 135 |
|
$verifier = new EncryptionVerifierStub($this->encryption, $this->encoder, $this->signer); |
| 136 |
|
$verifier->verify($this->token); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
public function testValidSignature() |
| 140 |
|
{ |
|
@@ 139-170 (lines=32) @@
|
| 136 |
|
$verifier->verify($this->token); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
public function testValidSignature() |
| 140 |
|
{ |
| 141 |
|
$algorithmParameter = $this->getMockBuilder('Emarref\Jwt\HeaderParameter\Algorithm')->getMock(); |
| 142 |
|
|
| 143 |
|
$algorithmParameter->expects($this->once()) |
| 144 |
|
->method('getValue') |
| 145 |
|
->will($this->returnValue('foo')); |
| 146 |
|
|
| 147 |
|
$this->header->expects($this->once()) |
| 148 |
|
->method('findParameterByName') |
| 149 |
|
->with(HeaderParameter\Algorithm::NAME) |
| 150 |
|
->will($this->returnValue($algorithmParameter)); |
| 151 |
|
|
| 152 |
|
$this->encryption->expects($this->once()) |
| 153 |
|
->method('getAlgorithmName') |
| 154 |
|
->will($this->returnValue('foo')); |
| 155 |
|
|
| 156 |
|
$this->encryption->expects($this->once()) |
| 157 |
|
->method('verify') |
| 158 |
|
->will($this->returnValue(true)); |
| 159 |
|
|
| 160 |
|
$this->signer->expects($this->once()) |
| 161 |
|
->method('getUnsignedValue') |
| 162 |
|
->will($this->returnValue('bar')); |
| 163 |
|
|
| 164 |
|
$this->token->expects($this->once()) |
| 165 |
|
->method('getSignature') |
| 166 |
|
->will($this->returnValue('bar')); |
| 167 |
|
|
| 168 |
|
$verifier = new EncryptionVerifierStub($this->encryption, $this->encoder, $this->signer); |
| 169 |
|
$verifier->verify($this->token); |
| 170 |
|
} |
| 171 |
|
} |
| 172 |
|
|