aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-05-06 19:20:49 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-05 16:54:04 +0200
commiteb29b2984cf81f25df42d59ce1d5c9a9b307763c (patch)
tree7277d43f58f92aa3fd58bb863bf4bbf344f4a71b /apps/files_encryption/tests
parent2d83424a29e4dbaeb16856c87378a753b10cdb90 (diff)
downloadnextcloud-server-eb29b2984cf81f25df42d59ce1d5c9a9b307763c.tar.gz
nextcloud-server-eb29b2984cf81f25df42d59ce1d5c9a9b307763c.zip
use oc_preferences instead of oc_encryption to store encyption settings
Diffstat (limited to 'apps/files_encryption/tests')
-rw-r--r--apps/files_encryption/tests/hooks.php23
-rwxr-xr-xapps/files_encryption/tests/util.php23
2 files changed, 28 insertions, 18 deletions
diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php
index 43703472618..95f5996bb8e 100644
--- a/apps/files_encryption/tests/hooks.php
+++ b/apps/files_encryption/tests/hooks.php
@@ -100,6 +100,29 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
\OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
}
+ function testDisableHook() {
+ // encryption is enabled and running so we should have some user specific
+ // settings in oc_preferences
+ $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
+ $result = $query->execute(array('files_encryption'));
+ $row = $result->fetchRow();
+ $this->assertTrue(is_array($row));
+
+ // disabling the app should delete all user specific settings
+ \OCA\Encryption\Hooks::preDisable(array('app' => 'files_encryption'));
+
+ // check if user specific settings for the encryption app are really gone
+ $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
+ $result = $query->execute(array('files_encryption'));
+ $row = $result->fetchRow();
+ $this->assertFalse($row);
+
+ // relogin user to initialize the encryption again
+ $user = \OCP\User::getUser();
+ \Test_Encryption_Util::loginHelper($user);
+
+ }
+
function testDeleteHooks() {
// remember files_trashbin state
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 2b873bb308d..cf2aa5f516f 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -236,16 +236,14 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// Record the value so we can return it to it's original state later
$enabled = $util->recoveryEnabledForUser();
- $this->assertTrue($util->setRecoveryForUser(1));
+ $this->assertTrue($util->setRecoveryForUser(!$enabled));
- $this->assertEquals(1, $util->recoveryEnabledForUser());
+ $this->assertEquals(!$enabled, $util->recoveryEnabledForUser());
- $this->assertTrue($util->setRecoveryForUser(0));
+ $this->assertTrue($util->setRecoveryForUser($enabled));
- $this->assertEquals(0, $util->recoveryEnabledForUser());
+ $this->assertEquals($enabled, $util->recoveryEnabledForUser());
- // Return the setting to it's previous state
- $this->assertTrue($util->setRecoveryForUser($enabled));
}
@@ -587,18 +585,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
* @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;
- }
+ return \OC_Preferences::setValue($user, 'files_encryption', 'migration_status', (string)$status);
}
}