aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests/crypt.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/tests/crypt.php')
-rwxr-xr-xapps/files_encryption/tests/crypt.php67
1 files changed, 43 insertions, 24 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index 09347dd578a..f72f15ca236 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -21,6 +21,10 @@ require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
use OCA\Encryption;
+// This has to go here because otherwise session errors arise, and the private
+// encryption key needs to be saved in the session
+\OC_User::login( 'admin', 'admin' );
+
class Test_Crypt extends \PHPUnit_Framework_TestCase {
function setUp() {
@@ -41,8 +45,6 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
$this->userId = 'admin';
$this->pass = 'admin';
-
- \OC_User::setUserId( $this->userId );
}
@@ -434,6 +436,7 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
}
+ // What is the point of this test? It doesn't use keyEncryptKeyfile()
function testKeyEncryptKeyfile() {
# TODO: Don't repeat encryption from previous tests, use PHPUnit test interdependency instead
@@ -456,6 +459,22 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals( $this->dataUrl, $decryptData );
}
+
+ /**
+ * @brief test functionality of keyEncryptKeyfile() and
+ * keyDecryptKeyfile()
+ */
+ function testKeyDecryptKeyfile() {
+
+ $encrypted = Encryption\Crypt::keyEncryptKeyfile( $this->dataShort, $this->genPublicKey );
+
+ $this->assertNotEquals( $encrypted['data'], $this->dataShort );
+
+ $decrypted = Encryption\Crypt::keyDecryptKeyfile( $encrypted['data'], $encrypted['key'], $this->genPrivateKey );
+
+ $this->assertEquals( $decrypted, $this->dataShort );
+
+ }
/**
@@ -474,17 +493,17 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
}
- /**
- * @brief test decryption using legacy blowfish method
- * @depends testLegacyEncryptShort
- */
- function testLegacyDecryptShort( $crypted ) {
-
- $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
-
- $this->assertEquals( $this->dataShort, $decrypted );
-
- }
+// /**
+// * @brief test decryption using legacy blowfish method
+// * @depends testLegacyEncryptShort
+// */
+// function testLegacyDecryptShort( $crypted ) {
+//
+// $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
+//
+// $this->assertEquals( $this->dataShort, $decrypted );
+//
+// }
/**
* @brief test encryption using legacy blowfish method
@@ -502,17 +521,17 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
}
- /**
- * @brief test decryption using legacy blowfish method
- * @depends testLegacyEncryptLong
- */
- function testLegacyDecryptLong( $crypted ) {
-
- $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
-
- $this->assertEquals( $this->dataLong, $decrypted );
-
- }
+// /**
+// * @brief test decryption using legacy blowfish method
+// * @depends testLegacyEncryptLong
+// */
+// function testLegacyDecryptLong( $crypted ) {
+//
+// $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
+//
+// $this->assertEquals( $this->dataLong, $decrypted );
+//
+// }
/**
* @brief test generation of legacy encryption key