]> source.dussan.org Git - nextcloud-server.git/commitdiff
make tests compatible with hook based skeleton generation
authorJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 10 Oct 2014 13:34:19 +0000 (15:34 +0200)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 16 Oct 2014 12:10:28 +0000 (14:10 +0200)
12 files changed:
apps/files_encryption/lib/helper.php
apps/files_encryption/tests/crypt.php
apps/files_encryption/tests/helper.php
apps/files_encryption/tests/hooks.php
apps/files_encryption/tests/keymanager.php
apps/files_encryption/tests/proxy.php
apps/files_encryption/tests/share.php
apps/files_encryption/tests/stream.php
apps/files_encryption/tests/trashbin.php
apps/files_encryption/tests/util.php
apps/files_encryption/tests/webdav.php
apps/files_sharing/tests/base.php

index ab19938d6331e7b9e8c757e9b40c32a44491e5ed..6f4eb4aaf3befb87be669a89c9d9a58a3332f520 100755 (executable)
@@ -461,7 +461,7 @@ class Helper {
                        } else {
                                \OC_Log::write(
                                        'Encryption library',
-                                       'No share key found for user "' . $user . '" for file "' . $pathOld . '"',
+                                       'No share key found for user "' . $user . '" for file "' . $fileName . '"',
                                        \OC_Log::WARN
                                );
                        }
index 0a39bc227b058b4b2908afbb6cee332920d4b56b..5adab9bc920019b6c3cc1047b86ed457e64943d7 100755 (executable)
@@ -103,6 +103,14 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
        public static function tearDownAfterClass() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
index b94fdeb4d6cf2e13b75464c7705931d7140d17b9..df7ff8cdb113050f7fe3b19645760da5b7e1d9c8 100644 (file)
@@ -20,18 +20,27 @@ class Test_Encryption_Helper extends \PHPUnit_Framework_TestCase {
        const TEST_ENCRYPTION_HELPER_USER1 = "test-helper-user1";
        const TEST_ENCRYPTION_HELPER_USER2 = "test-helper-user2";
 
-       public static function setUpBeforeClass() {
+       public function setUp() {
                // create test user
                \Test_Encryption_Util::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2, true);
                \Test_Encryption_Util::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1, true);
        }
 
-       public static function tearDownAfterClass() {
+       public function tearDown() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
                \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2);
+       }
+
+       public static function tearDownAfterClass() {
+
                \OC_Hook::clear();
                \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
@@ -157,11 +166,6 @@ class Test_Encryption_Helper extends \PHPUnit_Framework_TestCase {
                                $result
                        );
                }
-
-               // clean up
-               $rootView->unlink($baseDir);
-               \Test_Encryption_Util::logoutHelper();
-               \OC_User::deleteUser($userName);
        }
 
 }
index 14d44fe5bb3cbc1de5b745dd44e340557f1456cc..c7353deee22fb72132d54f7f4e892ee849dae838 100644 (file)
@@ -117,6 +117,14 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
                \OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        function testDisableHook() {
index e8a9d7dda531a12bd0b89db5b50995547c0acb57..ad7d2cfcd45f2e6b1a541829ced12f63888f89cc 100644 (file)
@@ -98,6 +98,14 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
                if (self::$stateFilesTrashbin) {
                        OC_App::enable('files_trashbin');
                }
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
index a9eddd1a810cca0e3b590524baef7897043f762f..732fe0fc31ee8dc778d22c916116c9a166d6fe10 100644 (file)
@@ -87,6 +87,14 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
        public static function tearDownAfterClass() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
index dcf0eda153e74befaacda28d2083af12090dcc18..f426ecdf6e97297ed0cd93d65a4576fed4534e35 100755 (executable)
@@ -125,6 +125,14 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
                \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
                \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3);
                \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
 
index 254c5e87ed19697e5c0241a147615b57d6073891..b8c18fbe0490ff9263c8acb287d03734b1f4097f 100644 (file)
@@ -96,6 +96,14 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
        public static function tearDownAfterClass() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        function testStreamOptions() {
index ae0974431be088778faa89dc6156e620ab96711a..5890292cd7bc26ae69365e99ee06a543748aed2b 100755 (executable)
@@ -110,6 +110,14 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
        public static function tearDownAfterClass() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
index bdd4a2f6ef0870c2a69be173b8df10358e0a88f3..83d2c6b0f92d36ae89fbc672ebbc6ce6f324ca56 100755 (executable)
@@ -124,9 +124,18 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
                \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
                \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2);
                \OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
+
                //cleanup groups
                \OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
                \OC_Group::deleteGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        public static function setupHooks() {
index c46d3bf089947251881586175200c937743d8194..cc0cff9aa5ca5f142189975db915794b14d301b5 100755 (executable)
@@ -108,6 +108,14 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
        public static function tearDownAfterClass() {
                // cleanup test user
                \OC_User::deleteUser(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
+
+               \OC_Hook::clear();
+               \OC_FileProxy::clearProxies();
+
+               // Delete keys in /data/
+               $view = new \OC\Files\View('/');
+               $view->rmdir('public-keys');
+               $view->rmdir('owncloud_private_key');
        }
 
        /**
index 84de6006fdb5f3446fdfee1f3bf2175eab64e906..6bc02ec2008b309f5c7d8c65381aa188a37e0cb7 100644 (file)
@@ -37,7 +37,7 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
 
        const TEST_FILES_SHARING_API_GROUP1 = "test-share-group1";
 
-       public $stateFilesEncryption;
+       public static $stateFilesEncryption;
        public $filename;
        public $data;
        /**
@@ -48,6 +48,13 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
        public $subfolder;
 
        public static function setUpBeforeClass() {
+
+               // remember files_encryption state
+               self::$stateFilesEncryption = \OC_App::isEnabled('files_encryption');
+
+               //we don't want to tests with app files_encryption enabled
+               \OC_App::disable('files_encryption');
+
                // reset backend
                \OC_User::clearBackends();
                \OC_User::useBackend('database');
@@ -70,29 +77,16 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
 
        function setUp() {
 
+               $this->assertFalse(\OC_App::isEnabled('files_encryption'));
+
                //login as user1
                self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
 
                $this->data = 'foobar';
                $this->view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
-               // remember files_encryption state
-               $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
-
-                //we don't want to tests with app files_encryption enabled
-               \OC_App::disable('files_encryption');
-
-
-               $this->assertTrue(!\OC_App::isEnabled('files_encryption'));
        }
 
        function tearDown() {
-               // reset app files_encryption
-               if ($this->stateFilesEncryption) {
-                       \OC_App::enable('files_encryption');
-               } else {
-                       \OC_App::disable('files_encryption');
-               }
-
                $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share`');
                $query->execute();
        }
@@ -106,6 +100,13 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
 
                // delete group
                \OC_Group::deleteGroup(self::TEST_FILES_SHARING_API_GROUP1);
+
+               // reset app files_encryption
+               if (self::$stateFilesEncryption) {
+                       \OC_App::enable('files_encryption');
+               } else {
+                       \OC_App::disable('files_encryption');
+               }
        }
 
        /**