diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-06-13 14:31:31 +0400 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-06-13 14:31:31 +0400 |
commit | 2b179ccff00913722a7ded8c58f18bacb62d0713 (patch) | |
tree | fa9119e9e8295c173834b47b6381b4ad551c5bc6 /apps/files_encryption/tests | |
parent | a178de8501f4ff83490fab1f3484fc6e13e3c5b2 (diff) | |
parent | 6394fedb3309dc163ed37081809f80f90157e096 (diff) |
Merge pull request #3668 from owncloud/encryption_migrate_only_once
make sure that only one process can enter the migration mode
Diffstat (limited to 'apps/files_encryption/tests')
-rwxr-xr-x | apps/files_encryption/tests/util.php | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index 6d6c8bca3dd..14caf1105de 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -182,8 +182,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $params['uid'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; $params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; - $util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); - $util->setMigrationStatus(0); + $this->setMigrationStatus(0, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); $this->assertTrue(OCA\Encryption\Hooks::login($params)); @@ -285,7 +284,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER; $util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); - $util->setMigrationStatus(0); + $this->setMigrationStatus(0, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER); $this->assertTrue(OCA\Encryption\Hooks::login($params)); @@ -330,4 +329,28 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $params['password'] = $password; OCA\Encryption\Hooks::login($params); } + + /** + * helper function to set migration status to the right value + * to be able to test the migration path + * + * @param $status needed migration status for test + * @param $user for which user the status should be set + * @return boolean + */ + private function setMigrationStatus($status, $user) { + $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?'; + $args = array( + $status, + $user + ); + + $query = \OCP\DB::prepare($sql); + if ($query->execute($args)) { + return true; + } else { + return false; + } + } + } |