diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-06-11 15:19:02 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-06-11 15:19:02 +0200 |
commit | 20ddd6e1c77224d18d5be74101b80144b7187475 (patch) | |
tree | 1320acdc30a977f9294dc0ae2f6c36667982da31 /apps/files_encryption/tests | |
parent | 64593e4b84fdd6881a43530461c50464303cc42e (diff) | |
parent | db6080c5c682a2bbdc420399276b81311c17802c (diff) | |
download | nextcloud-server-20ddd6e1c77224d18d5be74101b80144b7187475.tar.gz nextcloud-server-20ddd6e1c77224d18d5be74101b80144b7187475.zip |
Merge branch 'master' into files_encryption_check_private_key
Conflicts:
apps/files_encryption/tests/crypt.php
Diffstat (limited to 'apps/files_encryption/tests')
-rwxr-xr-x | apps/files_encryption/tests/crypt.php | 68 | ||||
-rw-r--r-- | apps/files_encryption/tests/keymanager.php | 18 | ||||
-rwxr-xr-x | apps/files_encryption/tests/share.php | 16 | ||||
-rw-r--r-- | apps/files_encryption/tests/stream.php | 3 | ||||
-rwxr-xr-x | apps/files_encryption/tests/trashbin.php | 3 | ||||
-rwxr-xr-x | apps/files_encryption/tests/util.php | 16 |
6 files changed, 124 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index d856e5d59b5..e6ea3bcd6b3 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -102,6 +102,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 @@ -113,6 +116,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @large * @return String */ function testGenerateIv() { @@ -126,6 +130,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @large * @depends testGenerateIv */ function testConcatIv($iv) { @@ -158,6 +163,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @depends testConcatIv */ function testSplitIv($testConcatIv) { @@ -174,6 +180,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @return string padded */ function testAddPadding() { @@ -189,6 +196,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @depends testAddPadding */ function testRemovePadding($padded) { @@ -199,6 +207,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testEncrypt() { $random = openssl_random_pseudo_bytes(13); @@ -211,6 +222,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testDecrypt() { $random = openssl_random_pseudo_bytes(13); @@ -241,6 +255,10 @@ 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 @@ -256,6 +274,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testSymmetricStreamEncryptShortFileContent() { $filename = 'tmp-' . time() . '.test'; @@ -306,6 +327,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 @@ -392,6 +414,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief Test that data that is read by the crypto stream wrapper */ function testSymmetricStreamDecryptShortFileContent() { @@ -421,6 +444,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $this->view->unlink($this->userId . '/files/' . $filename); } + /** + * @medium + */ function testSymmetricStreamDecryptLongFileContent() { $filename = 'tmp-' . time(); @@ -440,6 +466,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 @@ -455,6 +484,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testIsEncryptedContent() { $this->assertFalse(Encryption\Crypt::isCatfileContent($this->dataUrl)); @@ -467,6 +499,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 @@ -491,6 +526,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testKeyEncrypt() { // Generate keypair @@ -509,6 +547,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test encryption using legacy blowfish method */ function testLegacyEncryptShort() { @@ -525,6 +564,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptShort */ @@ -537,6 +577,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test encryption using legacy blowfish method */ function testLegacyEncryptLong() { @@ -553,6 +594,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptLong */ @@ -566,6 +608,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test generation of legacy encryption key * @depends testLegacyDecryptShort */ @@ -585,6 +628,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } /** + * @medium * @brief test decryption using legacy blowfish method * @depends testLegacyEncryptLong */ @@ -601,6 +645,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { } + /** + * @medium + */ function testRenameFile() { $filename = 'tmp-' . time(); @@ -629,6 +676,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $view->unlink($newFilename); } + /** + * @medium + */ function testMoveFileIntoFolder() { $filename = 'tmp-' . time(); @@ -659,6 +709,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $view->unlink($newFolder); } + /** + * @medium + */ function testMoveFolder() { $view = new \OC\Files\View('/' . $this->userId . '/files'); @@ -694,6 +747,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $view->unlink('/newfolder'); } + /** + * @medium + */ function testChangePassphrase() { $filename = 'tmp-' . time(); @@ -728,6 +784,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { $view->unlink($filename); } + /** + * @medium + */ function testViewFilePutAndGetContents() { $filename = '/tmp-' . time(); @@ -759,6 +818,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'); @@ -780,6 +842,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'); @@ -801,6 +866,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 ae006c17940..6b530315859 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -128,6 +128,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { } /** + * @medium * @param bool $withTeardown */ function testShareFile($withTeardown = true) { @@ -204,6 +205,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { } /** + * @medium * @param bool $withTeardown */ function testReShareFile($withTeardown = true) { @@ -274,6 +276,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { } /** + * @medium * @param bool $withTeardown * @return array */ @@ -362,6 +365,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { } /** + * @medium * @param bool $withTeardown */ function testReShareFolder($withTeardown = true) { @@ -563,6 +567,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); @@ -638,6 +645,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); @@ -737,6 +747,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); @@ -830,6 +843,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 0dc452a41c8..6d6c8bca3dd 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); |