Skip to content

Commit

Permalink
Add test coverage to DecryptionException thrown when tag is added man…
Browse files Browse the repository at this point in the history
…ually (#41553)
  • Loading branch information
Krisell committed Mar 18, 2022
1 parent 33b1b98 commit 126518b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Encryption/EncrypterTest.php
Expand Up @@ -160,6 +160,18 @@ public function testExceptionThrownWhenPayloadIsInvalid()
$e->decrypt($payload);
}

public function testDecryptionExceptionIsThrownWhenUnexpectedTagIsAdded()
{
$this->expectException(DecryptException::class);
$this->expectExceptionMessage('Unable to use tag because the cipher algorithm does not support AEAD.');

$e = new Encrypter(str_repeat('a', 16));
$payload = $e->encrypt('foo');
$decodedPayload = json_decode(base64_decode($payload));
$decodedPayload->tag = 'set-manually';
$e->decrypt(base64_encode(json_encode($decodedPayload)));
}

public function testExceptionThrownWithDifferentKey()
{
$this->expectException(DecryptException::class);
Expand Down

0 comments on commit 126518b

Please sign in to comment.