aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/Crypto/DecryptAllTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/Crypto/DecryptAllTest.php')
-rw-r--r--apps/encryption/tests/Crypto/DecryptAllTest.php59
1 files changed, 18 insertions, 41 deletions
diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php
index 68b49307f31..82e6100bce5 100644
--- a/apps/encryption/tests/Crypto/DecryptAllTest.php
+++ b/apps/encryption/tests/Crypto/DecryptAllTest.php
@@ -1,26 +1,11 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Encryption\Tests\Crypto;
@@ -29,28 +14,19 @@ use OCA\Encryption\Crypto\DecryptAll;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Helper\QuestionHelper;
use Test\TestCase;
class DecryptAllTest extends TestCase {
- /** @var DecryptAll */
- protected $instance;
-
- /** @var Util | \PHPUnit\Framework\MockObject\MockObject */
- protected $util;
-
- /** @var KeyManager | \PHPUnit\Framework\MockObject\MockObject */
- protected $keyManager;
-
- /** @var Crypt | \PHPUnit\Framework\MockObject\MockObject */
- protected $crypt;
-
- /** @var Session | \PHPUnit\Framework\MockObject\MockObject */
- protected $session;
+ protected DecryptAll $instance;
- /** @var QuestionHelper | \PHPUnit\Framework\MockObject\MockObject */
- protected $questionHelper;
+ protected Util&MockObject $util;
+ protected KeyManager&MockObject $keyManager;
+ protected Crypt&MockObject $crypt;
+ protected Session&MockObject $session;
+ protected QuestionHelper&MockObject $questionHelper;
protected function setUp(): void {
parent::setUp();
@@ -75,7 +51,7 @@ class DecryptAllTest extends TestCase {
);
}
- public function testUpdateSession() {
+ public function testUpdateSession(): void {
$this->session->expects($this->once())->method('prepareDecryptAll')
->with('user1', 'key1');
@@ -83,15 +59,16 @@ class DecryptAllTest extends TestCase {
}
/**
- * @dataProvider dataTestGetPrivateKey
*
* @param string $user
* @param string $recoveryKeyId
*/
- public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetPrivateKey')]
+ public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId): void {
$password = 'passwd';
$recoveryKey = 'recoveryKey';
$userKey = 'userKey';
+ $masterKey = 'userKey';
$unencryptedKey = 'unencryptedKey';
$this->keyManager->expects($this->any())->method('getRecoveryKeyId')
@@ -122,7 +99,7 @@ class DecryptAllTest extends TestCase {
);
}
- public function dataTestGetPrivateKey() {
+ public static function dataTestGetPrivateKey() {
return [
['user1', 'recoveryKey', 'masterKeyId'],
['recoveryKeyId', 'recoveryKeyId', 'masterKeyId'],