From 7a5c4fd092e445a6e8d08994f810d0aa472f6879 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Mon, 3 Jun 2013 17:34:43 +0200 Subject: [PATCH] added test for decryptPrivateKey() --- apps/files_encryption/tests/crypt.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index e153a49a2c7..ccf3c52fa97 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -226,6 +226,24 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + function testDecryptPrivateKey() { + + $keypair = Encryption\Crypt::createKeypair(); + + // test successful decrypt + $crypted = Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], 'hat'); + + $decrypted = Encryption\Crypt::decryptPrivateKey($crypted, 'hat'); + + $this->assertEquals($keypair['privateKey'], $decrypted); + + //test private key decrypt with wrong password + $wrongPasswd = Encryption\Crypt::decryptPrivateKey($crypted, 'hat2'); + + $this->assertEquals(false, $wrongPasswd); + + } + function testSymmetricEncryptFileContent() { # TODO: search in keyfile for actual content as IV will ensure this test always passes -- 2.39.5