Throw more helpful exception when already decrypted

This commit is contained in:
Stephen Paul Weber
2018-07-25 09:56:57 -05:00
parent a9fc3f9322
commit 413741fa84
2 changed files with 10 additions and 0 deletions

View File

@@ -114,6 +114,13 @@ class Decryption extends PHPUnit_Framework_TestCase {
$skey = OpenPGP_Crypt_Symmetric::decryptSecretKey("hello", $key[0]);
$this->assertSame(!!$skey, true);
}
public function testAlreadyDecryptedSecretKey() {
$this->expectException(Exception::class);
$this->expectExceptionMessage("Data is already unencrypted");
$key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/helloKey.gpg'));
OpenPGP_Crypt_Symmetric::decryptSecretKey("hello", $key[0]);
}
}
class Encryption extends PHPUnit_Framework_TestCase {