aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/EncryptedStorageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/EncryptedStorageTest.php')
-rw-r--r--apps/encryption/tests/EncryptedStorageTest.php54
1 files changed, 20 insertions, 34 deletions
diff --git a/apps/encryption/tests/EncryptedStorageTest.php b/apps/encryption/tests/EncryptedStorageTest.php
index 3219707d48b..59f419a7f7a 100644
--- a/apps/encryption/tests/EncryptedStorageTest.php
+++ b/apps/encryption/tests/EncryptedStorageTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\encryption\tests;
@@ -28,6 +13,7 @@ use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IDisableEncryptionStorage;
+use OCP\Server;
use Test\TestCase;
use Test\Traits\EncryptionTrait;
use Test\Traits\MountProviderTrait;
@@ -45,24 +31,24 @@ class EncryptedStorageTest extends TestCase {
use EncryptionTrait;
use UserTrait;
- public function testMoveFromEncrypted() {
- $this->createUser("test1", "test2");
- $this->setupForUser("test1", 'test2');
+ public function testMoveFromEncrypted(): void {
+ $this->createUser('test1', 'test2');
+ $this->setupForUser('test1', 'test2');
$unwrapped = new Temporary();
- $this->registerMount("test1", new TemporaryNoEncrypted(), "/test1/files/unenc");
- $this->registerMount("test1", $unwrapped, "/test1/files/enc");
+ $this->registerMount('test1', new TemporaryNoEncrypted(), '/test1/files/unenc');
+ $this->registerMount('test1', $unwrapped, '/test1/files/enc');
- $this->loginWithEncryption("test1");
+ $this->loginWithEncryption('test1');
- $view = new View("/test1/files");
+ $view = new View('/test1/files');
/** @var IMountManager $mountManager */
- $mountManager = \OC::$server->get(IMountManager::class);
+ $mountManager = Server::get(IMountManager::class);
- $encryptedMount = $mountManager->find("/test1/files/enc");
- $unencryptedMount = $mountManager->find("/test1/files/unenc");
+ $encryptedMount = $mountManager->find('/test1/files/enc');
+ $unencryptedMount = $mountManager->find('/test1/files/unenc');
$encryptedStorage = $encryptedMount->getStorage();
$unencryptedStorage = $unencryptedMount->getStorage();
$encryptedCache = $encryptedStorage->getCache();
@@ -71,15 +57,15 @@ class EncryptedStorageTest extends TestCase {
$this->assertTrue($encryptedStorage->instanceOfStorage(Encryption::class));
$this->assertFalse($unencryptedStorage->instanceOfStorage(Encryption::class));
- $encryptedStorage->file_put_contents("foo.txt", "bar");
- $this->assertEquals("bar", $encryptedStorage->file_get_contents("foo.txt"));
- $this->assertStringStartsWith("HBEGIN:oc_encryption_module:", $unwrapped->file_get_contents("foo.txt"));
+ $encryptedStorage->file_put_contents('foo.txt', 'bar');
+ $this->assertEquals('bar', $encryptedStorage->file_get_contents('foo.txt'));
+ $this->assertStringStartsWith('HBEGIN:oc_encryption_module:', $unwrapped->file_get_contents('foo.txt'));
- $this->assertTrue($encryptedCache->get("foo.txt")->isEncrypted());
+ $this->assertTrue($encryptedCache->get('foo.txt')->isEncrypted());
- $view->rename("enc/foo.txt", "unenc/foo.txt");
+ $view->rename('enc/foo.txt', 'unenc/foo.txt');
- $this->assertEquals("bar", $unencryptedStorage->file_get_contents("foo.txt"));
- $this->assertFalse($unencryptedCache->get("foo.txt")->isEncrypted());
+ $this->assertEquals('bar', $unencryptedStorage->file_get_contents('foo.txt'));
+ $this->assertFalse($unencryptedCache->get('foo.txt')->isEncrypted());
}
}