From: Björn Schießle Date: Mon, 3 Jun 2013 15:34:43 +0000 (+0200) Subject: added test for decryptPrivateKey() X-Git-Tag: v6.0.0alpha2~641^2~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35c91ff9010f84aa204030f4bb60f36dca1cb664;p=nextcloud-server.git added test for decryptPrivateKey() --- diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index 32156eea272..74f91e9b037 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