Skip to content

Commit 126518b

Browse files
authored
Add test coverage to DecryptionException thrown when tag is added manually (#41553)
1 parent 33b1b98 commit 126518b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/Encryption/EncrypterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ public function testExceptionThrownWhenPayloadIsInvalid()
160160
$e->decrypt($payload);
161161
}
162162

163+
public function testDecryptionExceptionIsThrownWhenUnexpectedTagIsAdded()
164+
{
165+
$this->expectException(DecryptException::class);
166+
$this->expectExceptionMessage('Unable to use tag because the cipher algorithm does not support AEAD.');
167+
168+
$e = new Encrypter(str_repeat('a', 16));
169+
$payload = $e->encrypt('foo');
170+
$decodedPayload = json_decode(base64_decode($payload));
171+
$decodedPayload->tag = 'set-manually';
172+
$e->decrypt(base64_encode(json_encode($decodedPayload)));
173+
}
174+
163175
public function testExceptionThrownWithDifferentKey()
164176
{
165177
$this->expectException(DecryptException::class);

0 commit comments

Comments
 (0)