Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-06-12 22:53:45 +0400
committerBjörn Schießle <schiessle@owncloud.com>2013-06-12 22:53:45 +0400
commit27fcdb3af5d1b1012695a09e04c0a654a1dde710 (patch)
tree6de492454c862852de3f51bd8834e2012139b5ac /apps/files_encryption/tests
parent46e5e9bd73a68f7b50bb79f883a8bc6efacaca97 (diff)
parent3584d48d65900b15dc3ef6831926f4a52e508625 (diff)
Merge branch 'master' into files_encryption_upgrade_fix
Conflicts: apps/files_encryption/tests/crypt.php
Diffstat (limited to 'apps/files_encryption/tests')
-rwxr-xr-xapps/files_encryption/tests/crypt.php84
-rw-r--r--apps/files_encryption/tests/keymanager.php18
-rwxr-xr-xapps/files_encryption/tests/share.php18
-rw-r--r--apps/files_encryption/tests/stream.php3
-rwxr-xr-xapps/files_encryption/tests/trashbin.php3
-rwxr-xr-xapps/files_encryption/tests/util.php16
6 files changed, 141 insertions, 1 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index e153a49a2c7..341904b1189 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -103,6 +103,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
\OC_User::deleteUser(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1);
}
+ /**
+ * @medium
+ */
function testGenerateKey() {
# TODO: use more accurate (larger) string length for test confirmation
@@ -114,6 +117,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @large
* @return String
*/
function testGenerateIv() {
@@ -127,6 +131,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @large
* @depends testGenerateIv
*/
function testConcatIv($iv) {
@@ -159,6 +164,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @depends testConcatIv
*/
function testSplitIv($testConcatIv) {
@@ -175,6 +181,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @return string padded
*/
function testAddPadding() {
@@ -190,6 +197,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @depends testAddPadding
*/
function testRemovePadding($padded) {
@@ -200,6 +208,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testEncrypt() {
$random = openssl_random_pseudo_bytes(13);
@@ -212,6 +223,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testDecrypt() {
$random = openssl_random_pseudo_bytes(13);
@@ -226,6 +240,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testSymmetricEncryptFileContent() {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
@@ -241,6 +258,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testSymmetricStreamEncryptShortFileContent() {
$filename = 'tmp-' . time() . '.test';
@@ -291,6 +311,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief Test that data that is written by the crypto stream wrapper
* @note Encrypted data is manually prepared and decrypted here to avoid dependency on success of stream_read
* @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual
@@ -377,6 +398,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief Test that data that is read by the crypto stream wrapper
*/
function testSymmetricStreamDecryptShortFileContent() {
@@ -406,6 +428,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->view->unlink($this->userId . '/files/' . $filename);
}
+ /**
+ * @medium
+ */
function testSymmetricStreamDecryptLongFileContent() {
$filename = 'tmp-' . time();
@@ -425,6 +450,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->view->unlink($this->userId . '/files/' . $filename);
}
+ /**
+ * @medium
+ */
function testSymmetricEncryptFileContentKeyfile() {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
@@ -440,6 +468,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testIsEncryptedContent() {
$this->assertFalse(Encryption\Crypt::isCatfileContent($this->dataUrl));
@@ -452,6 +483,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @large
+ */
function testMultiKeyEncrypt() {
# TODO: search in keyfile for actual content as IV will ensure this test always passes
@@ -476,6 +510,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testKeyEncrypt() {
// Generate keypair
@@ -494,6 +531,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test encryption using legacy blowfish method
*/
function testLegacyEncryptShort() {
@@ -510,6 +548,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test decryption using legacy blowfish method
* @depends testLegacyEncryptShort
*/
@@ -522,6 +561,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test encryption using legacy blowfish method
*/
function testLegacyEncryptLong() {
@@ -538,6 +578,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test decryption using legacy blowfish method
* @depends testLegacyEncryptLong
*/
@@ -551,6 +592,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test generation of legacy encryption key
* @depends testLegacyDecryptShort
*/
@@ -569,6 +611,27 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ * @brief test decryption using legacy blowfish method
+ * @depends testLegacyEncryptLong
+ */
+ function testLegacyKeyRecryptKeyfileEncrypt($crypted) {
+
+ $recrypted = Encryption\Crypt::LegacyKeyRecryptKeyfile($crypted, $this->pass, array($this->genPublicKey));
+
+ $this->assertNotEquals($this->dataLong, $recrypted['data']);
+
+ return $recrypted;
+
+ # TODO: search inencrypted text for actual content to ensure it
+ # genuine transformation
+
+ }
+
+ /**
+ * @medium
+ */
function testRenameFile() {
$filename = 'tmp-' . time();
@@ -597,6 +660,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($newFilename);
}
+ /**
+ * @medium
+ */
function testMoveFileIntoFolder() {
$filename = 'tmp-' . time();
@@ -627,6 +693,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($newFolder);
}
+ /**
+ * @medium
+ */
function testMoveFolder() {
$view = new \OC\Files\View('/' . $this->userId . '/files');
@@ -662,6 +731,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink('/newfolder');
}
+ /**
+ * @medium
+ */
function testChangePassphrase() {
$filename = 'tmp-' . time();
@@ -696,6 +768,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($filename);
}
+ /**
+ * @medium
+ */
function testViewFilePutAndGetContents() {
$filename = '/tmp-' . time();
@@ -727,6 +802,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($filename);
}
+ /**
+ * @large
+ */
function testTouchExistingFile() {
$filename = '/tmp-' . time();
$view = new \OC\Files\View('/' . $this->userId . '/files');
@@ -748,6 +826,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($filename);
}
+ /**
+ * @medium
+ */
function testTouchFile() {
$filename = '/tmp-' . time();
$view = new \OC\Files\View('/' . $this->userId . '/files');
@@ -769,6 +850,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view->unlink($filename);
}
+ /**
+ * @medium
+ */
function testFopenFile() {
$filename = '/tmp-' . time();
$view = new \OC\Files\View('/' . $this->userId . '/files');
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php
index 40ae1659a55..19ba9a8117f 100644
--- a/apps/files_encryption/tests/keymanager.php
+++ b/apps/files_encryption/tests/keymanager.php
@@ -103,6 +103,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
\OC_FileProxy::$enabled = true;
}
+ /**
+ * @medium
+ */
function testGetPrivateKey() {
$key = Encryption\Keymanager::getPrivateKey($this->view, $this->userId);
@@ -119,6 +122,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testGetPublicKey() {
$publiceKey = Encryption\Keymanager::getPublicKey($this->view, $this->userId);
@@ -132,6 +138,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$this->assertArrayHasKey('key', $sslInfo);
}
+ /**
+ * @medium
+ */
function testSetFileKey() {
# NOTE: This cannot be tested until we are able to break out
@@ -165,6 +174,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testGetUserKeys() {
$keys = Encryption\Keymanager::getUserKeys($this->view, $this->userId);
@@ -188,6 +200,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$this->assertArrayHasKey('key', $sslInfoPrivate);
}
+ /**
+ * @medium
+ */
function testFixPartialFilePath() {
$partFilename = 'testfile.txt.part';
@@ -202,6 +217,9 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$this->assertEquals('testfile.txt', Encryption\Keymanager::fixPartialFilePath($filename));
}
+ /**
+ * @medium
+ */
function testRecursiveDelShareKeys() {
// generate filename
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index 6d92881ceb0..15dd5058ebb 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -129,6 +129,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @param bool $withTeardown
*/
function testShareFile($withTeardown = true) {
@@ -205,6 +206,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @param bool $withTeardown
*/
function testReShareFile($withTeardown = true) {
@@ -275,6 +277,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @param bool $withTeardown
* @return array
*/
@@ -363,6 +366,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @param bool $withTeardown
*/
function testReShareFolder($withTeardown = true) {
@@ -534,7 +538,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// some hacking to simulate public link
$GLOBALS['app'] = 'files_sharing';
$GLOBALS['fileOwner'] = \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1;
- \OC_User::setUserId('');
+ \OC_User::setUserId(false);
// get file contents
$retrievedCryptedFile = file_get_contents('crypt://' . $this->filename);
@@ -564,6 +568,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
. $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey'));
}
+ /**
+ * @medium
+ */
function testShareFileWithGroup() {
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
@@ -639,6 +646,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @large
+ */
function testRecoveryFile() {
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
@@ -741,6 +751,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
$this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled'));
}
+ /**
+ * @large
+ */
function testRecoveryForUser() {
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
@@ -837,6 +850,9 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
$this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled'));
}
+ /**
+ * @medium
+ */
function testFailShareFile() {
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php
index 3d978767542..50ac41e4536 100644
--- a/apps/files_encryption/tests/stream.php
+++ b/apps/files_encryption/tests/stream.php
@@ -140,6 +140,9 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
$view->unlink($filename);
}
+ /**
+ * @medium
+ */
function testStreamSetTimeout() {
$filename = '/tmp-' . time();
$view = new \OC\Files\View('/' . $this->userId . '/files');
diff --git a/apps/files_encryption/tests/trashbin.php b/apps/files_encryption/tests/trashbin.php
index 29f8fb5a396..ade968fbece 100755
--- a/apps/files_encryption/tests/trashbin.php
+++ b/apps/files_encryption/tests/trashbin.php
@@ -113,6 +113,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test delete file
*/
function testDeleteFile() {
@@ -184,6 +185,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test restore file
*
* @depends testDeleteFile
@@ -215,6 +217,7 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test delete file forever
*/
function testPermanentDeleteFile() {
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index b36d7e41172..b945fb4c0f3 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -118,6 +118,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test that paths set during User construction are correct
*/
function testKeyPaths() {
@@ -132,6 +133,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test setup of encryption directories
*/
function testSetupServerSide() {
@@ -139,6 +141,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
/**
+ * @medium
* @brief test checking whether account is ready for encryption,
*/
function testUserIsReady() {
@@ -159,6 +162,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// }
/**
+ * @medium
* @brief test checking whether account is not ready for encryption,
*/
function testIsLegacyUser() {
@@ -186,6 +190,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->legacyKey, \OC::$session->get('legacyKey'));
}
+ /**
+ * @medium
+ */
function testRecoveryEnabledForUser() {
$util = new Encryption\Util($this->view, $this->userId);
@@ -206,6 +213,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * @medium
+ */
function testGetUidAndFilename() {
\OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
@@ -232,6 +242,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$this->view->unlink($this->userId . '/files/' . $filename);
}
+ /**
+ * @medium
+ */
function testIsSharedPath() {
$sharedPath = '/user1/files/Shared/test';
$path = '/user1/files/test';
@@ -241,6 +254,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->util->isSharedPath($path));
}
+ /**
+ * @large
+ */
function testEncryptLegacyFiles() {
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);