aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-06-30 16:56:59 +0200
committerRobin Appelman <robin@icewind.nl>2025-07-01 22:45:52 +0200
commitaa15f9d16d5b46d04763c7deedb129990e819364 (patch)
tree758e0aebcac34a545f9a21806120a9fcb96f4cb6 /apps/encryption
parent1620a0c0510a42b1da0a66488838f1ce3ba1210d (diff)
downloadnextcloud-server-rector-phpunit10.tar.gz
nextcloud-server-rector-phpunit10.zip
chore: run rectorrector-phpunit10
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/encryption')
-rw-r--r--apps/encryption/tests/Command/TestEnableMasterKey.php4
-rw-r--r--apps/encryption/tests/Controller/RecoveryControllerTest.php6
-rw-r--r--apps/encryption/tests/Controller/StatusControllerTest.php2
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php26
-rw-r--r--apps/encryption/tests/Crypto/DecryptAllTest.php2
-rw-r--r--apps/encryption/tests/Crypto/EncryptAllTest.php6
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php13
-rw-r--r--apps/encryption/tests/KeyManagerTest.php16
-rw-r--r--apps/encryption/tests/SessionTest.php2
-rw-r--r--apps/encryption/tests/Settings/AdminTest.php4
-rw-r--r--apps/encryption/tests/Users/SetupTest.php2
-rw-r--r--apps/encryption/tests/UtilTest.php6
12 files changed, 35 insertions, 54 deletions
diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php
index 744bbaed6f8..ead3dfd0195 100644
--- a/apps/encryption/tests/Command/TestEnableMasterKey.php
+++ b/apps/encryption/tests/Command/TestEnableMasterKey.php
@@ -55,11 +55,11 @@ class TestEnableMasterKey extends TestCase {
}
/**
- * @dataProvider dataTestExecute
*
* @param bool $isAlreadyEnabled
* @param string $answer
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')]
public function testExecute($isAlreadyEnabled, $answer): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn($isAlreadyEnabled);
@@ -81,7 +81,7 @@ class TestEnableMasterKey extends TestCase {
$this->invokePrivate($this->enableMasterKey, 'execute', [$this->input, $this->output]);
}
- public function dataTestExecute() {
+ public static function dataTestExecute() {
return [
[true, ''],
[false, 'y'],
diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php
index 7eff312d6ce..0fec3f4d6a9 100644
--- a/apps/encryption/tests/Controller/RecoveryControllerTest.php
+++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php
@@ -37,13 +37,13 @@ class RecoveryControllerTest extends TestCase {
}
/**
- * @dataProvider adminRecoveryProvider
* @param $recoveryPassword
* @param $passConfirm
* @param $enableRecovery
* @param $expectedMessage
* @param $expectedStatus
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('adminRecoveryProvider')]
public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('enableAdminRecovery')
@@ -73,13 +73,13 @@ class RecoveryControllerTest extends TestCase {
}
/**
- * @dataProvider changeRecoveryPasswordProvider
* @param $password
* @param $confirmPassword
* @param $oldPassword
* @param $expectedMessage
* @param $expectedStatus
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('changeRecoveryPasswordProvider')]
public function testChangeRecoveryPassword($password, $confirmPassword, $oldPassword, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('changeRecoveryKeyPassword')
@@ -105,11 +105,11 @@ class RecoveryControllerTest extends TestCase {
}
/**
- * @dataProvider userSetRecoveryProvider
* @param $enableRecovery
* @param $expectedMessage
* @param $expectedStatus
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('userSetRecoveryProvider')]
public function testUserSetRecovery($enableRecovery, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('setRecoveryForUser')
diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php
index 616114927e8..1bbcad77411 100644
--- a/apps/encryption/tests/Controller/StatusControllerTest.php
+++ b/apps/encryption/tests/Controller/StatusControllerTest.php
@@ -50,11 +50,11 @@ class StatusControllerTest extends TestCase {
}
/**
- * @dataProvider dataTestGetStatus
*
* @param string $status
* @param string $expectedStatus
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetStatus')]
public function testGetStatus($status, $expectedStatus): void {
$this->sessionMock->expects($this->once())
->method('getStatus')->willReturn($status);
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 345311da4d0..1355e2c855d 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -80,9 +80,8 @@ class CryptTest extends TestCase {
/**
* test generateHeader with valid key formats
- *
- * @dataProvider dataTestGenerateHeader
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGenerateHeader')]
public function testGenerateHeader($keyFormat, $expected): void {
$this->config->expects($this->once())
->method('getSystemValueString')
@@ -130,10 +129,10 @@ class CryptTest extends TestCase {
}
/**
- * @dataProvider dataProviderGetCipher
* @param string $configValue
* @param string $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderGetCipher')]
public function testGetCipher($configValue, $expected): void {
$this->config->expects($this->once())
->method('getSystemValueString')
@@ -173,9 +172,7 @@ class CryptTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestSplitMetaData
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitMetaData')]
public function testSplitMetaData($data, $expected): void {
$this->config->method('getSystemValueBool')
->with('encryption_skip_signature_check', false)
@@ -200,9 +197,7 @@ class CryptTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestHasSignature
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHasSignature')]
public function testHasSignature($data, $expected): void {
$this->config->method('getSystemValueBool')
->with('encryption_skip_signature_check', false)
@@ -219,9 +214,7 @@ class CryptTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestHasSignatureFail
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestHasSignatureFail')]
public function testHasSignatureFail($cipher): void {
$this->expectException(GenericEncryptionException::class);
@@ -249,10 +242,10 @@ class CryptTest extends TestCase {
/**
* test removePadding()
*
- * @dataProvider dataProviderRemovePadding
* @param $data
* @param $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderRemovePadding')]
public function testRemovePadding($data, $expected): void {
$result = self::invokePrivate($this->crypt, 'removePadding', [$data]);
$this->assertSame($expected, $result);
@@ -327,9 +320,8 @@ class CryptTest extends TestCase {
/**
* test return values of valid ciphers
- *
- * @dataProvider dataTestGetKeySize
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetKeySize')]
public function testGetKeySize($cipher, $expected): void {
$result = $this->invokePrivate($this->crypt, 'getKeySize', [$cipher]);
$this->assertSame($expected, $result);
@@ -354,9 +346,7 @@ class CryptTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestDecryptPrivateKey
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestDecryptPrivateKey')]
public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected): void {
$this->config->method('getSystemValueBool')
->willReturnMap([
diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php
index 83684b8be32..82e6100bce5 100644
--- a/apps/encryption/tests/Crypto/DecryptAllTest.php
+++ b/apps/encryption/tests/Crypto/DecryptAllTest.php
@@ -59,11 +59,11 @@ class DecryptAllTest extends TestCase {
}
/**
- * @dataProvider dataTestGetPrivateKey
*
* @param string $user
* @param string $recoveryKeyId
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetPrivateKey')]
public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId): void {
$password = 'passwd';
$recoveryKey = 'recoveryKey';
diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php
index 45743ae733b..6dbbd55df78 100644
--- a/apps/encryption/tests/Crypto/EncryptAllTest.php
+++ b/apps/encryption/tests/Crypto/EncryptAllTest.php
@@ -249,7 +249,7 @@ class EncryptAllTest extends TestCase {
$encryptAllCalls = [];
$encryptAll->expects($this->exactly(2))
->method('encryptUsersFiles')
- ->willReturnCallback(function ($uid) use (&$encryptAllCalls) {
+ ->willReturnCallback(function ($uid) use (&$encryptAllCalls): void {
$encryptAllCalls[] = $uid;
});
@@ -317,7 +317,7 @@ class EncryptAllTest extends TestCase {
$encryptAllCalls = [];
$encryptAll->expects($this->exactly(2))
->method('encryptFile')
- ->willReturnCallback(function (string $path) use (&$encryptAllCalls) {
+ ->willReturnCallback(function (string $path) use (&$encryptAllCalls): void {
$encryptAllCalls[] = $path;
});
@@ -346,9 +346,9 @@ class EncryptAllTest extends TestCase {
}
/**
- * @dataProvider dataTestEncryptFile
* @param $isEncrypted
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestEncryptFile')]
public function testEncryptFile($isEncrypted): void {
$fileInfo = $this->createMock(FileInfo::class);
$fileInfo->expects($this->any())->method('isEncrypted')
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 999c6242f0c..37e484550ef 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -152,9 +152,7 @@ class EncryptionTest extends TestCase {
return $publicKeys;
}
- /**
- * @dataProvider dataProviderForTestGetPathToRealFile
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderForTestGetPathToRealFile')]
public function testGetPathToRealFile($path, $expected): void {
$this->assertSame($expected,
self::invokePrivate($this->instance, 'getPathToRealFile', [$path])
@@ -170,9 +168,7 @@ class EncryptionTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestBegin
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestBegin')]
public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
@@ -265,11 +261,11 @@ class EncryptionTest extends TestCase {
}
/**
- * @dataProvider dataTestUpdate
*
* @param string $fileKey
* @param boolean $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdate')]
public function testUpdate($fileKey, $expected): void {
$this->keyManagerMock->expects($this->once())
->method('getFileKey')->willReturn($fileKey);
@@ -354,9 +350,8 @@ class EncryptionTest extends TestCase {
/**
* by default the encryption module should encrypt regular files, files in
* files_versions and files in files_trashbin
- *
- * @dataProvider dataTestShouldEncrypt
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldEncrypt')]
public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected): void {
$this->utilMock->expects($this->once())->method('shouldEncryptHomeStorage')
->willReturn($shouldEncryptHomeStorage);
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index 187c21bc687..3fe76fc4f59 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -166,9 +166,7 @@ class KeyManagerTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestUserHasKeys
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUserHasKeys')]
public function testUserHasKeys($key, $expected): void {
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
@@ -221,10 +219,9 @@ class KeyManagerTest extends TestCase {
}
/**
- * @dataProvider dataTestInit
- *
* @param bool $useMasterKey
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestInit')]
public function testInit($useMasterKey): void {
/** @var KeyManager&MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
@@ -248,7 +245,7 @@ class KeyManagerTest extends TestCase {
$sessionSetStatusCalls = [];
$this->sessionMock->expects($this->exactly(2))
->method('setStatus')
- ->willReturnCallback(function (string $status) use (&$sessionSetStatusCalls) {
+ ->willReturnCallback(function (string $status) use (&$sessionSetStatusCalls): void {
$sessionSetStatusCalls[] = $status;
});
@@ -356,13 +353,13 @@ class KeyManagerTest extends TestCase {
}
/**
- * @dataProvider dataTestGetFileKey
*
* @param $uid
* @param $isMasterKeyEnabled
* @param $privateKey
* @param $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetFileKey')]
public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $encryptedFileKey, $expected): void {
$path = '/foo.txt';
@@ -452,13 +449,13 @@ class KeyManagerTest extends TestCase {
/**
* test add public share key and or recovery key to the list of public keys
*
- * @dataProvider dataTestAddSystemKeys
*
* @param array $accessList
* @param array $publicKeys
* @param string $uid
* @param array $expectedKeys
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestAddSystemKeys')]
public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys): void {
$publicShareKeyId = 'publicShareKey';
$recoveryKeyId = 'recoveryKey';
@@ -539,10 +536,9 @@ class KeyManagerTest extends TestCase {
}
/**
- * @dataProvider dataTestValidateMasterKey
- *
* @param $masterKey
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestValidateMasterKey')]
public function testValidateMasterKey($masterKey): void {
/** @var KeyManager&MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php
index 9e38f857e73..986502749c8 100644
--- a/apps/encryption/tests/SessionTest.php
+++ b/apps/encryption/tests/SessionTest.php
@@ -115,11 +115,11 @@ class SessionTest extends TestCase {
}
/**
- * @dataProvider dataTestIsReady
*
* @param int $status
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsReady')]
public function testIsReady($status, $expected): void {
/** @var Session&MockObject $instance */
$instance = $this->getMockBuilder(Session::class)
diff --git a/apps/encryption/tests/Settings/AdminTest.php b/apps/encryption/tests/Settings/AdminTest.php
index 5ae9e7eb3c6..8355cdf6729 100644
--- a/apps/encryption/tests/Settings/AdminTest.php
+++ b/apps/encryption/tests/Settings/AdminTest.php
@@ -53,7 +53,7 @@ class AdminTest extends TestCase {
public function testGetForm(): void {
$this->config
->method('getAppValue')
- ->will($this->returnCallback(function ($app, $key, $default) {
+ ->willReturnCallback(function ($app, $key, $default) {
if ($app === 'encryption' && $key === 'recoveryAdminEnabled' && $default === '0') {
return '1';
}
@@ -61,7 +61,7 @@ class AdminTest extends TestCase {
return '1';
}
return $default;
- }));
+ });
$params = [
'recoveryEnabled' => '1',
'initStatus' => '0',
diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php
index b2abfcba1db..6b2b8b4cad5 100644
--- a/apps/encryption/tests/Users/SetupTest.php
+++ b/apps/encryption/tests/Users/SetupTest.php
@@ -46,11 +46,11 @@ class SetupTest extends TestCase {
}
/**
- * @dataProvider dataTestSetupUser
*
* @param bool $hasKeys
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetupUser')]
public function testSetupUser($hasKeys, $expected): void {
$this->keyManagerMock->expects($this->once())->method('userHasKeys')
->with('uid')->willReturn($hasKeys);
diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php
index 3556b9e34c1..41860a44ffb 100644
--- a/apps/encryption/tests/UtilTest.php
+++ b/apps/encryption/tests/UtilTest.php
@@ -115,11 +115,11 @@ class UtilTest extends TestCase {
}
/**
- * @dataProvider dataTestIsMasterKeyEnabled
*
* @param string $value
* @param bool $expect
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsMasterKeyEnabled')]
public function testIsMasterKeyEnabled($value, $expect): void {
$this->configMock->expects($this->once())->method('getAppValue')
->with('encryption', 'useMasterKey', '1')->willReturn($value);
@@ -136,10 +136,10 @@ class UtilTest extends TestCase {
}
/**
- * @dataProvider dataTestShouldEncryptHomeStorage
* @param string $returnValue return value from getAppValue()
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldEncryptHomeStorage')]
public function testShouldEncryptHomeStorage($returnValue, $expected): void {
$this->configMock->expects($this->once())->method('getAppValue')
->with('encryption', 'encryptHomeStorage', '1')
@@ -157,10 +157,10 @@ class UtilTest extends TestCase {
}
/**
- * @dataProvider dataTestSetEncryptHomeStorage
* @param $value
* @param $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSetEncryptHomeStorage')]
public function testSetEncryptHomeStorage($value, $expected): void {
$this->configMock->expects($this->once())->method('setAppValue')
->with('encryption', 'encryptHomeStorage', $expected);