aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-09-15 22:32:31 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2024-09-15 22:32:31 +0200
commit49dd79eabb2b8902559a7a4e8f8fcad54f46b604 (patch)
tree2af18db46ba463368dc4461d7436fb69577923de /apps/encryption/tests
parent4281ce6fa1bb8235426099d720734d2394bec203 (diff)
downloadnextcloud-server-49dd79eabb2b8902559a7a4e8f8fcad54f46b604.tar.gz
nextcloud-server-49dd79eabb2b8902559a7a4e8f8fcad54f46b604.zip
refactor: Add void return type to PHPUnit test methods
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r--apps/encryption/tests/Command/FixEncryptedVersionTest.php20
-rw-r--r--apps/encryption/tests/Command/TestEnableMasterKey.php2
-rw-r--r--apps/encryption/tests/Controller/RecoveryControllerTest.php6
-rw-r--r--apps/encryption/tests/Controller/SettingsControllerTest.php8
-rw-r--r--apps/encryption/tests/Controller/StatusControllerTest.php2
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php38
-rw-r--r--apps/encryption/tests/Crypto/DecryptAllTest.php4
-rw-r--r--apps/encryption/tests/Crypto/EncryptAllTest.php14
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php24
-rw-r--r--apps/encryption/tests/EncryptedStorageTest.php2
-rw-r--r--apps/encryption/tests/HookManagerTest.php4
-rw-r--r--apps/encryption/tests/Hooks/UserHooksTest.php16
-rw-r--r--apps/encryption/tests/KeyManagerTest.php60
-rw-r--r--apps/encryption/tests/RecoveryTest.php22
-rw-r--r--apps/encryption/tests/SessionTest.php24
-rw-r--r--apps/encryption/tests/Settings/AdminTest.php6
-rw-r--r--apps/encryption/tests/Users/SetupTest.php4
-rw-r--r--apps/encryption/tests/UtilTest.php14
18 files changed, 135 insertions, 135 deletions
diff --git a/apps/encryption/tests/Command/FixEncryptedVersionTest.php b/apps/encryption/tests/Command/FixEncryptedVersionTest.php
index c021c366ad8..fd6e27e030b 100644
--- a/apps/encryption/tests/Command/FixEncryptedVersionTest.php
+++ b/apps/encryption/tests/Command/FixEncryptedVersionTest.php
@@ -75,7 +75,7 @@ class FixEncryptedVersionTest extends TestCase {
* In this test the encrypted version of the file is less than the original value
* but greater than zero
*/
- public function testEncryptedVersionLessThanOriginalValue() {
+ public function testEncryptedVersionLessThanOriginalValue(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -143,7 +143,7 @@ Fixed the file: \"/$this->userId/files/world.txt\" with version 4", $output);
* In this test the encrypted version of the file is greater than the original value
* but greater than zero
*/
- public function testEncryptedVersionGreaterThanOriginalValue() {
+ public function testEncryptedVersionGreaterThanOriginalValue(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -202,7 +202,7 @@ The file \"/$this->userId/files/world.txt\" is: OK
Fixed the file: \"/$this->userId/files/world.txt\" with version 4", $output);
}
- public function testVersionIsRestoredToOriginalIfNoFixIsFound() {
+ public function testVersionIsRestoredToOriginalIfNoFixIsFound(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -232,7 +232,7 @@ Fixed the file: \"/$this->userId/files/world.txt\" with version 4", $output);
$this->assertEquals(15, $encryptedVersion);
}
- public function testRepairUnencryptedFileWhenVersionIsSet() {
+ public function testRepairUnencryptedFileWhenVersionIsSet(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -275,7 +275,7 @@ Fixed the file: \"/$this->userId/files/hello.txt\" with version 0 (unencrypted)"
/**
* Test commands with a file path
*/
- public function testExecuteWithFilePathOption() {
+ public function testExecuteWithFilePathOption(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -299,7 +299,7 @@ The file \"/$this->userId/files/hello.txt\" is: OK", $output);
/**
* Test commands with a directory path
*/
- public function testExecuteWithDirectoryPathOption() {
+ public function testExecuteWithDirectoryPathOption(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -321,7 +321,7 @@ The file \"/$this->userId/files/sub/hello.txt\" is: OK", $output);
$this->assertStringNotContainsString('world.txt', $output);
}
- public function testExecuteWithNoUser() {
+ public function testExecuteWithNoUser(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -335,7 +335,7 @@ The file \"/$this->userId/files/sub/hello.txt\" is: OK", $output);
$this->assertStringContainsString('Either a user id or --all needs to be provided', $output);
}
- public function testExecuteWithBadUser() {
+ public function testExecuteWithBadUser(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -352,7 +352,7 @@ The file \"/$this->userId/files/sub/hello.txt\" is: OK", $output);
/**
* Test commands with a directory path
*/
- public function testExecuteWithNonExistentPath() {
+ public function testExecuteWithNonExistentPath(): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(true);
@@ -369,7 +369,7 @@ The file \"/$this->userId/files/sub/hello.txt\" is: OK", $output);
/**
* Test commands without master key
*/
- public function testExecuteWithNoMasterKey() {
+ public function testExecuteWithNoMasterKey(): void {
\OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '0');
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn(false);
diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php
index 47bc978627d..2ed29becf2a 100644
--- a/apps/encryption/tests/Command/TestEnableMasterKey.php
+++ b/apps/encryption/tests/Command/TestEnableMasterKey.php
@@ -58,7 +58,7 @@ class TestEnableMasterKey extends TestCase {
* @param bool $isAlreadyEnabled
* @param string $answer
*/
- public function testExecute($isAlreadyEnabled, $answer) {
+ public function testExecute($isAlreadyEnabled, $answer): void {
$this->util->expects($this->once())->method('isMasterKeyEnabled')
->willReturn($isAlreadyEnabled);
diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php
index 955e9c7c964..8398a22039b 100644
--- a/apps/encryption/tests/Controller/RecoveryControllerTest.php
+++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php
@@ -45,7 +45,7 @@ class RecoveryControllerTest extends TestCase {
* @param $expectedMessage
* @param $expectedStatus
*/
- public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus) {
+ public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('enableAdminRecovery')
->willReturn(true);
@@ -81,7 +81,7 @@ class RecoveryControllerTest extends TestCase {
* @param $expectedMessage
* @param $expectedStatus
*/
- public function testChangeRecoveryPassword($password, $confirmPassword, $oldPassword, $expectedMessage, $expectedStatus) {
+ public function testChangeRecoveryPassword($password, $confirmPassword, $oldPassword, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('changeRecoveryKeyPassword')
->with($password, $oldPassword)
@@ -111,7 +111,7 @@ class RecoveryControllerTest extends TestCase {
* @param $expectedMessage
* @param $expectedStatus
*/
- public function testUserSetRecovery($enableRecovery, $expectedMessage, $expectedStatus) {
+ public function testUserSetRecovery($enableRecovery, $expectedMessage, $expectedStatus): void {
$this->recoveryMock->expects($this->any())
->method('setRecoveryForUser')
->with($enableRecovery)
diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php
index ee49972001c..dcad23cd759 100644
--- a/apps/encryption/tests/Controller/SettingsControllerTest.php
+++ b/apps/encryption/tests/Controller/SettingsControllerTest.php
@@ -115,7 +115,7 @@ class SettingsControllerTest extends TestCase {
/**
* test updatePrivateKeyPassword() if wrong new password was entered
*/
- public function testUpdatePrivateKeyPasswordWrongNewPassword() {
+ public function testUpdatePrivateKeyPasswordWrongNewPassword(): void {
$oldPassword = 'old';
$newPassword = 'new';
@@ -140,7 +140,7 @@ class SettingsControllerTest extends TestCase {
/**
* test updatePrivateKeyPassword() if wrong old password was entered
*/
- public function testUpdatePrivateKeyPasswordWrongOldPassword() {
+ public function testUpdatePrivateKeyPasswordWrongOldPassword(): void {
$oldPassword = 'old';
$newPassword = 'new';
@@ -166,7 +166,7 @@ class SettingsControllerTest extends TestCase {
/**
* test updatePrivateKeyPassword() with the correct old and new password
*/
- public function testUpdatePrivateKeyPassword() {
+ public function testUpdatePrivateKeyPassword(): void {
$oldPassword = 'old';
$newPassword = 'new';
@@ -227,7 +227,7 @@ class SettingsControllerTest extends TestCase {
$data['message']);
}
- public function testSetEncryptHomeStorage() {
+ public function testSetEncryptHomeStorage(): void {
$value = true;
$this->utilMock->expects($this->once())->method('setEncryptHomeStorage')->with($value);
$this->controller->setEncryptHomeStorage($value);
diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php
index 26210946cce..c88b0497abf 100644
--- a/apps/encryption/tests/Controller/StatusControllerTest.php
+++ b/apps/encryption/tests/Controller/StatusControllerTest.php
@@ -60,7 +60,7 @@ class StatusControllerTest extends TestCase {
* @param string $status
* @param string $expectedStatus
*/
- public function testGetStatus($status, $expectedStatus) {
+ public function testGetStatus($status, $expectedStatus): void {
$this->sessionMock->expects($this->once())
->method('getStatus')->willReturn($status);
$result = $this->controller->getStatus();
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 301ffaeaef3..a9869af99d9 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -53,7 +53,7 @@ class CryptTest extends TestCase {
/**
* test getOpenSSLConfig without any additional parameters
*/
- public function testGetOpenSSLConfigBasic() {
+ public function testGetOpenSSLConfigBasic(): void {
$this->config->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([]))
@@ -68,7 +68,7 @@ class CryptTest extends TestCase {
/**
* test getOpenSSLConfig with additional parameters defined in config.php
*/
- public function testGetOpenSSLConfig() {
+ public function testGetOpenSSLConfig(): void {
$this->config->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('openssl'), $this->equalTo([]))
@@ -88,7 +88,7 @@ class CryptTest extends TestCase {
*
* @dataProvider dataTestGenerateHeader
*/
- public function testGenerateHeader($keyFormat, $expected) {
+ public function testGenerateHeader($keyFormat, $expected): void {
$this->config->expects($this->once())
->method('getSystemValueString')
->with($this->equalTo('cipher'), $this->equalTo('AES-256-CTR'))
@@ -107,7 +107,7 @@ class CryptTest extends TestCase {
* test generateHeader with invalid key format
*
*/
- public function testGenerateHeaderInvalid() {
+ public function testGenerateHeaderInvalid(): void {
$this->expectException(\InvalidArgumentException::class);
$this->crypt->generateHeader('unknown');
@@ -124,7 +124,7 @@ class CryptTest extends TestCase {
];
}
- public function testGetCipherWithInvalidCipher() {
+ public function testGetCipherWithInvalidCipher(): void {
$this->config->expects($this->once())
->method('getSystemValueString')
->with($this->equalTo('cipher'), $this->equalTo('AES-256-CTR'))
@@ -142,7 +142,7 @@ class CryptTest extends TestCase {
* @param string $configValue
* @param string $expected
*/
- public function testGetCipher($configValue, $expected) {
+ public function testGetCipher($configValue, $expected): void {
$this->config->expects($this->once())
->method('getSystemValueString')
->with($this->equalTo('cipher'), $this->equalTo('AES-256-CTR'))
@@ -172,7 +172,7 @@ class CryptTest extends TestCase {
/**
* test concatIV()
*/
- public function testConcatIV() {
+ public function testConcatIV(): void {
$result = self::invokePrivate(
$this->crypt,
'concatIV',
@@ -186,7 +186,7 @@ class CryptTest extends TestCase {
/**
* @dataProvider dataTestSplitMetaData
*/
- public function testSplitMetaData($data, $expected) {
+ public function testSplitMetaData($data, $expected): void {
$this->config->method('getSystemValueBool')
->with('encryption_skip_signature_check', false)
->willReturn(true);
@@ -213,7 +213,7 @@ class CryptTest extends TestCase {
/**
* @dataProvider dataTestHasSignature
*/
- public function testHasSignature($data, $expected) {
+ public function testHasSignature($data, $expected): void {
$this->config->method('getSystemValueBool')
->with('encryption_skip_signature_check', false)
->willReturn(true);
@@ -232,7 +232,7 @@ class CryptTest extends TestCase {
/**
* @dataProvider dataTestHasSignatureFail
*/
- public function testHasSignatureFail($cipher) {
+ public function testHasSignatureFail($cipher): void {
$this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class);
$data = 'encryptedContent00iv001234567890123456xx';
@@ -251,7 +251,7 @@ class CryptTest extends TestCase {
/**
* test addPadding()
*/
- public function testAddPadding() {
+ public function testAddPadding(): void {
$result = self::invokePrivate($this->crypt, 'addPadding', ['data']);
$this->assertSame('dataxxx', $result);
}
@@ -263,7 +263,7 @@ class CryptTest extends TestCase {
* @param $data
* @param $expected
*/
- public function testRemovePadding($data, $expected) {
+ public function testRemovePadding($data, $expected): void {
$result = self::invokePrivate($this->crypt, 'removePadding', [$data]);
$this->assertSame($expected, $result);
}
@@ -283,7 +283,7 @@ class CryptTest extends TestCase {
/**
* test parseHeader()
*/
- public function testParseHeader() {
+ public function testParseHeader(): void {
$header = 'HBEGIN:foo:bar:cipher:AES-256-CFB:encoding:binary:HEND';
$result = self::invokePrivate($this->crypt, 'parseHeader', [$header]);
@@ -328,7 +328,7 @@ class CryptTest extends TestCase {
*
* @depends testEncrypt
*/
- public function testDecrypt($data) {
+ public function testDecrypt($data): void {
$result = self::invokePrivate(
$this->crypt,
'decrypt',
@@ -342,7 +342,7 @@ class CryptTest extends TestCase {
*
* @dataProvider dataTestGetKeySize
*/
- public function testGetKeySize($cipher, $expected) {
+ public function testGetKeySize($cipher, $expected): void {
$result = $this->invokePrivate($this->crypt, 'getKeySize', [$cipher]);
$this->assertSame($expected, $result);
}
@@ -351,7 +351,7 @@ class CryptTest extends TestCase {
* test exception if cipher is unknown
*
*/
- public function testGetKeySizeFailure() {
+ public function testGetKeySizeFailure(): void {
$this->expectException(\InvalidArgumentException::class);
$this->invokePrivate($this->crypt, 'getKeySize', ['foo']);
@@ -372,7 +372,7 @@ class CryptTest extends TestCase {
/**
* @dataProvider dataTestDecryptPrivateKey
*/
- public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) {
+ public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected): void {
$this->config->method('getSystemValueBool')
->withConsecutive(['encryption.legacy_format_support', false],
['encryption.use_legacy_base64_encoding', false])
@@ -430,7 +430,7 @@ class CryptTest extends TestCase {
];
}
- public function testIsValidPrivateKey() {
+ public function testIsValidPrivateKey(): void {
$res = openssl_pkey_new();
openssl_pkey_export($res, $privateKey);
@@ -445,7 +445,7 @@ class CryptTest extends TestCase {
);
}
- public function testMultiKeyEncrypt() {
+ public function testMultiKeyEncrypt(): void {
$res = openssl_pkey_new();
openssl_pkey_export($res, $privateKey);
$publicKeyPem = openssl_pkey_get_details($res)['key'];
diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php
index 2a46e542804..0d8543153ef 100644
--- a/apps/encryption/tests/Crypto/DecryptAllTest.php
+++ b/apps/encryption/tests/Crypto/DecryptAllTest.php
@@ -58,7 +58,7 @@ class DecryptAllTest extends TestCase {
);
}
- public function testUpdateSession() {
+ public function testUpdateSession(): void {
$this->session->expects($this->once())->method('prepareDecryptAll')
->with('user1', 'key1');
@@ -71,7 +71,7 @@ class DecryptAllTest extends TestCase {
* @param string $user
* @param string $recoveryKeyId
*/
- public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId) {
+ public function testGetPrivateKey($user, $recoveryKeyId, $masterKeyId): void {
$password = 'passwd';
$recoveryKey = 'recoveryKey';
$userKey = 'userKey';
diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php
index a63b826bf3c..f58ea2119e6 100644
--- a/apps/encryption/tests/Crypto/EncryptAllTest.php
+++ b/apps/encryption/tests/Crypto/EncryptAllTest.php
@@ -135,7 +135,7 @@ class EncryptAllTest extends TestCase {
);
}
- public function testEncryptAll() {
+ public function testEncryptAll(): void {
/** @var EncryptAll | \PHPUnit\Framework\MockObject\MockObject $encryptAll */
$encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs(
@@ -164,7 +164,7 @@ class EncryptAllTest extends TestCase {
$encryptAll->encryptAll($this->inputInterface, $this->outputInterface);
}
- public function testEncryptAllWithMasterKey() {
+ public function testEncryptAllWithMasterKey(): void {
/** @var EncryptAll | \PHPUnit\Framework\MockObject\MockObject $encryptAll */
$encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs(
@@ -194,7 +194,7 @@ class EncryptAllTest extends TestCase {
$encryptAll->encryptAll($this->inputInterface, $this->outputInterface);
}
- public function testCreateKeyPairs() {
+ public function testCreateKeyPairs(): void {
/** @var EncryptAll | \PHPUnit\Framework\MockObject\MockObject $encryptAll */
$encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs(
@@ -244,7 +244,7 @@ class EncryptAllTest extends TestCase {
$this->assertSame('', $userPasswords['user2']);
}
- public function testEncryptAllUsersFiles() {
+ public function testEncryptAllUsersFiles(): void {
/** @var EncryptAll | \PHPUnit\Framework\MockObject\MockObject $encryptAll */
$encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs(
@@ -280,7 +280,7 @@ class EncryptAllTest extends TestCase {
$this->invokePrivate($encryptAll, 'encryptAllUsersFiles');
}
- public function testEncryptUsersFiles() {
+ public function testEncryptUsersFiles(): void {
/** @var EncryptAll | \PHPUnit\Framework\MockObject\MockObject $encryptAll */
$encryptAll = $this->getMockBuilder(EncryptAll::class)
->setConstructorArgs(
@@ -343,7 +343,7 @@ class EncryptAllTest extends TestCase {
$this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']);
}
- public function testGenerateOneTimePassword() {
+ public function testGenerateOneTimePassword(): void {
$password = $this->invokePrivate($this->encryptAll, 'generateOneTimePassword', ['user1']);
$this->assertTrue(is_string($password));
$this->assertSame(8, strlen($password));
@@ -357,7 +357,7 @@ class EncryptAllTest extends TestCase {
* @dataProvider dataTestEncryptFile
* @param $isEncrypted
*/
- public function testEncryptFile($isEncrypted) {
+ public function testEncryptFile($isEncrypted): void {
$fileInfo = $this->createMock(FileInfo::class);
$fileInfo->expects($this->any())->method('isEncrypted')
->willReturn($isEncrypted);
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 4767d22339d..b07bd0a6b25 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -102,7 +102,7 @@ class EncryptionTest extends TestCase {
/**
* test if public key from one of the recipients is missing
*/
- public function testEndUser1() {
+ public function testEndUser1(): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(false);
@@ -115,7 +115,7 @@ class EncryptionTest extends TestCase {
* test if public key from owner is missing
*
*/
- public function testEndUser2() {
+ public function testEndUser2(): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(false);
@@ -167,7 +167,7 @@ class EncryptionTest extends TestCase {
/**
* @dataProvider dataProviderForTestGetPathToRealFile
*/
- public function testGetPathToRealFile($path, $expected) {
+ public function testGetPathToRealFile($path, $expected): void {
$this->assertSame($expected,
self::invokePrivate($this->instance, 'getPathToRealFile', [$path])
);
@@ -185,7 +185,7 @@ class EncryptionTest extends TestCase {
/**
* @dataProvider dataTestBegin
*/
- public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected) {
+ public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(false);
@@ -239,7 +239,7 @@ class EncryptionTest extends TestCase {
/**
* test begin() if decryptAll mode was activated
*/
- public function testBeginDecryptAll() {
+ public function testBeginDecryptAll(): void {
$path = '/user/files/foo.txt';
$fileKey = 'fileKey';
@@ -263,7 +263,7 @@ class EncryptionTest extends TestCase {
* in this case we can initialize the encryption without a username/password
* and continue
*/
- public function testBeginInitMasterKey() {
+ public function testBeginInitMasterKey(): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(false);
@@ -282,7 +282,7 @@ class EncryptionTest extends TestCase {
* @param string $fileKey
* @param boolean $expected
*/
- public function testUpdate($fileKey, $expected) {
+ public function testUpdate($fileKey, $expected): void {
$this->keyManagerMock->expects($this->once())
->method('getFileKey')->willReturn($fileKey);
@@ -310,7 +310,7 @@ class EncryptionTest extends TestCase {
];
}
- public function testUpdateNoUsers() {
+ public function testUpdateNoUsers(): void {
$this->invokePrivate($this->instance, 'rememberVersion', [['path' => 2]]);
$this->keyManagerMock->expects($this->never())->method('getFileKey');
@@ -329,7 +329,7 @@ class EncryptionTest extends TestCase {
* Test case if the public key is missing. Nextcloud should still encrypt
* the file for the remaining users
*/
- public function testUpdateMissingPublicKey() {
+ public function testUpdateMissingPublicKey(): void {
$this->keyManagerMock->expects($this->once())
->method('getFileKey')->willReturn('fileKey');
@@ -369,7 +369,7 @@ class EncryptionTest extends TestCase {
*
* @dataProvider dataTestShouldEncrypt
*/
- public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected) {
+ public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected): void {
$this->utilMock->expects($this->once())->method('shouldEncryptHomeStorage')
->willReturn($shouldEncryptHomeStorage);
@@ -402,14 +402,14 @@ class EncryptionTest extends TestCase {
}
- public function testDecrypt() {
+ public function testDecrypt(): void {
$this->expectException(\OC\Encryption\Exceptions\DecryptionFailedException::class);
$this->expectExceptionMessage('Cannot decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
$this->instance->decrypt('abc');
}
- public function testPrepareDecryptAll() {
+ public function testPrepareDecryptAll(): void {
/** @var \Symfony\Component\Console\Input\InputInterface $input */
$input = $this->createMock(InputInterface::class);
/** @var \Symfony\Component\Console\Output\OutputInterface $output */
diff --git a/apps/encryption/tests/EncryptedStorageTest.php b/apps/encryption/tests/EncryptedStorageTest.php
index 26d5d9c4941..7671eab4992 100644
--- a/apps/encryption/tests/EncryptedStorageTest.php
+++ b/apps/encryption/tests/EncryptedStorageTest.php
@@ -30,7 +30,7 @@ class EncryptedStorageTest extends TestCase {
use EncryptionTrait;
use UserTrait;
- public function testMoveFromEncrypted() {
+ public function testMoveFromEncrypted(): void {
$this->createUser('test1', 'test2');
$this->setupForUser('test1', 'test2');
diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php
index 4a662f3bc4a..ad1fac3407f 100644
--- a/apps/encryption/tests/HookManagerTest.php
+++ b/apps/encryption/tests/HookManagerTest.php
@@ -20,7 +20,7 @@ class HookManagerTest extends TestCase {
private static $instance;
- public function testRegisterHookWithArray() {
+ public function testRegisterHookWithArray(): void {
self::$instance->registerHook([
$this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(),
$this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(),
@@ -41,7 +41,7 @@ class HookManagerTest extends TestCase {
}
- public function testRegisterHooksWithInstance() {
+ public function testRegisterHooksWithInstance(): void {
$mock = $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock();
/** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */
self::$instance->registerHook($mock);
diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php
index 5c67a5313b6..3bb0b559fdf 100644
--- a/apps/encryption/tests/Hooks/UserHooksTest.php
+++ b/apps/encryption/tests/Hooks/UserHooksTest.php
@@ -76,7 +76,7 @@ class UserHooksTest extends TestCase {
private $params = ['uid' => 'testUser', 'password' => 'password'];
- public function testLogin() {
+ public function testLogin(): void {
$this->userSetupMock->expects($this->once())
->method('setupUser')
->willReturnOnConsecutiveCalls(true, false);
@@ -88,14 +88,14 @@ class UserHooksTest extends TestCase {
$this->assertNull($this->instance->login($this->params));
}
- public function testLogout() {
+ public function testLogout(): void {
$this->sessionMock->expects($this->once())
->method('clear');
$this->instance->logout();
$this->addToAssertionCount(1);
}
- public function testPostCreateUser() {
+ public function testPostCreateUser(): void {
$this->userSetupMock->expects($this->once())
->method('setupUser');
@@ -103,7 +103,7 @@ class UserHooksTest extends TestCase {
$this->addToAssertionCount(1);
}
- public function testPostDeleteUser() {
+ public function testPostDeleteUser(): void {
$this->keyManagerMock->expects($this->once())
->method('deletePublicKey')
->with('testUser');
@@ -112,7 +112,7 @@ class UserHooksTest extends TestCase {
$this->addToAssertionCount(1);
}
- public function testPrePasswordReset() {
+ public function testPrePasswordReset(): void {
$params = ['uid' => 'user1'];
$expected = ['user1' => true];
$this->instance->prePasswordReset($params);
@@ -121,7 +121,7 @@ class UserHooksTest extends TestCase {
$this->assertSame($expected, $passwordResetUsers);
}
- public function testPostPasswordReset() {
+ public function testPostPasswordReset(): void {
$params = ['uid' => 'user1', 'password' => 'password'];
$this->invokePrivate($this->instance, 'passwordResetUsers', [['user1' => true]]);
$this->keyManagerMock->expects($this->once())->method('backupUserKeys')
@@ -139,7 +139,7 @@ class UserHooksTest extends TestCase {
/**
* @dataProvider dataTestPreSetPassphrase
*/
- public function testPreSetPassphrase($canChange) {
+ public function testPreSetPassphrase($canChange): void {
/** @var UserHooks | \PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(UserHooks::class)
->setConstructorArgs(
@@ -269,7 +269,7 @@ class UserHooksTest extends TestCase {
$this->assertNull($this->instance->setPassphrase($this->params));
}
- public function testSetPassphraseResetUserMode() {
+ public function testSetPassphraseResetUserMode(): void {
$params = ['uid' => 'user1', 'password' => 'password'];
$this->invokePrivate($this->instance, 'passwordResetUsers', [[$params['uid'] => true]]);
$this->sessionMock->expects($this->never())->method('getPrivateKey');
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index b408c9e180b..a9919e8eab4 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -95,7 +95,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testDeleteShareKey() {
+ public function testDeleteShareKey(): void {
$this->keyStorageMock->expects($this->any())
->method('deleteFileKey')
->with($this->equalTo('/path'), $this->equalTo('keyId.shareKey'))
@@ -106,7 +106,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testGetPrivateKey() {
+ public function testGetPrivateKey(): void {
$this->keyStorageMock->expects($this->any())
->method('getUserKey')
->with($this->equalTo($this->userId), $this->equalTo('privateKey'))
@@ -118,7 +118,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testGetPublicKey() {
+ public function testGetPublicKey(): void {
$this->keyStorageMock->expects($this->any())
->method('getUserKey')
->with($this->equalTo($this->userId), $this->equalTo('publicKey'))
@@ -130,7 +130,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testRecoveryKeyExists() {
+ public function testRecoveryKeyExists(): void {
$this->keyStorageMock->expects($this->any())
->method('getSystemUserKey')
->with($this->equalTo($this->systemKeyId . '.publicKey'))
@@ -140,7 +140,7 @@ class KeyManagerTest extends TestCase {
$this->assertTrue($this->instance->recoveryKeyExists());
}
- public function testCheckRecoveryKeyPassword() {
+ public function testCheckRecoveryKeyPassword(): void {
$this->keyStorageMock->expects($this->any())
->method('getSystemUserKey')
->with($this->equalTo($this->systemKeyId . '.privateKey'))
@@ -153,7 +153,7 @@ class KeyManagerTest extends TestCase {
$this->assertTrue($this->instance->checkRecoveryPassword('pass'));
}
- public function testSetPublicKey() {
+ public function testSetPublicKey(): void {
$this->keyStorageMock->expects($this->any())
->method('setUserKey')
->with(
@@ -168,7 +168,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testSetPrivateKey() {
+ public function testSetPrivateKey(): void {
$this->keyStorageMock->expects($this->any())
->method('setUserKey')
->with(
@@ -186,7 +186,7 @@ class KeyManagerTest extends TestCase {
/**
* @dataProvider dataTestUserHasKeys
*/
- public function testUserHasKeys($key, $expected) {
+ public function testUserHasKeys($key, $expected): void {
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
->with($this->equalTo($this->userId), $this->anything())
@@ -206,7 +206,7 @@ class KeyManagerTest extends TestCase {
}
- public function testUserHasKeysMissingPrivateKey() {
+ public function testUserHasKeysMissingPrivateKey(): void {
$this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
$this->keyStorageMock->expects($this->exactly(2))
@@ -222,7 +222,7 @@ class KeyManagerTest extends TestCase {
}
- public function testUserHasKeysMissingPublicKey() {
+ public function testUserHasKeysMissingPublicKey(): void {
$this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
$this->keyStorageMock->expects($this->exactly(2))
@@ -242,7 +242,7 @@ class KeyManagerTest extends TestCase {
*
* @param bool $useMasterKey
*/
- public function testInit($useMasterKey) {
+ public function testInit($useMasterKey): void {
/** @var \OCA\Encryption\KeyManager|\PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
@@ -297,7 +297,7 @@ class KeyManagerTest extends TestCase {
}
- public function testSetRecoveryKey() {
+ public function testSetRecoveryKey(): void {
$this->keyStorageMock->expects($this->exactly(2))
->method('setSystemUserKey')
->willReturn(true);
@@ -313,7 +313,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testSetSystemPrivateKey() {
+ public function testSetSystemPrivateKey(): void {
$this->keyStorageMock->expects($this->exactly(1))
->method('setSystemUserKey')
->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))
@@ -325,7 +325,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testGetSystemPrivateKey() {
+ public function testGetSystemPrivateKey(): void {
$this->keyStorageMock->expects($this->exactly(1))
->method('getSystemUserKey')
->with($this->equalTo('keyId.privateKey'))
@@ -337,7 +337,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testGetEncryptedFileKey() {
+ public function testGetEncryptedFileKey(): void {
$this->keyStorageMock->expects($this->once())
->method('getFileKey')
->with('/', 'fileKey')
@@ -375,7 +375,7 @@ class KeyManagerTest extends TestCase {
* @param $privateKey
* @param $expected
*/
- public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $encryptedFileKey, $expected) {
+ public function testGetFileKey($uid, $isMasterKeyEnabled, $privateKey, $encryptedFileKey, $expected): void {
$path = '/foo.txt';
if ($isMasterKeyEnabled) {
@@ -446,7 +446,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testDeletePrivateKey() {
+ public function testDeletePrivateKey(): void {
$this->keyStorageMock->expects($this->once())
->method('deleteUserKey')
->with('user1', 'privateKey')
@@ -457,7 +457,7 @@ class KeyManagerTest extends TestCase {
[$this->userId]));
}
- public function testDeleteAllFileKeys() {
+ public function testDeleteAllFileKeys(): void {
$this->keyStorageMock->expects($this->once())
->method('deleteAllFileKeys')
->willReturn(true);
@@ -475,7 +475,7 @@ class KeyManagerTest extends TestCase {
* @param string $uid
* @param array $expectedKeys
*/
- public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys) {
+ public function testAddSystemKeys($accessList, $publicKeys, $uid, $expectedKeys): void {
$publicShareKeyId = 'publicShareKey';
$recoveryKeyId = 'recoveryKey';
@@ -521,11 +521,11 @@ class KeyManagerTest extends TestCase {
];
}
- public function testGetMasterKeyId() {
+ public function testGetMasterKeyId(): void {
$this->assertSame('systemKeyId', $this->instance->getMasterKeyId());
}
- public function testGetPublicMasterKey() {
+ public function testGetPublicMasterKey(): void {
$this->keyStorageMock->expects($this->once())->method('getSystemUserKey')
->with('systemKeyId.publicKey', \OCA\Encryption\Crypto\Encryption::ID)
->willReturn(true);
@@ -535,7 +535,7 @@ class KeyManagerTest extends TestCase {
);
}
- public function testGetMasterKeyPassword() {
+ public function testGetMasterKeyPassword(): void {
$this->configMock->expects($this->once())->method('getSystemValue')->with('secret')
->willReturn('password');
@@ -545,7 +545,7 @@ class KeyManagerTest extends TestCase {
}
- public function testGetMasterKeyPasswordException() {
+ public function testGetMasterKeyPasswordException(): void {
$this->expectException(\Exception::class);
$this->configMock->expects($this->once())->method('getSystemValue')->with('secret')
@@ -559,7 +559,7 @@ class KeyManagerTest extends TestCase {
*
* @param $masterKey
*/
- public function testValidateMasterKey($masterKey) {
+ public function testValidateMasterKey($masterKey): void {
/** @var \OCA\Encryption\KeyManager | \PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
@@ -607,7 +607,7 @@ class KeyManagerTest extends TestCase {
$instance->validateMasterKey();
}
- public function testValidateMasterKeyLocked() {
+ public function testValidateMasterKeyLocked(): void {
/** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */
$instance = $this->getMockBuilder(KeyManager::class)
->setConstructorArgs(
@@ -650,7 +650,7 @@ class KeyManagerTest extends TestCase {
];
}
- public function testGetVersionWithoutFileInfo() {
+ public function testGetVersionWithoutFileInfo(): void {
$view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$view->expects($this->once())
@@ -662,7 +662,7 @@ class KeyManagerTest extends TestCase {
$this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view));
}
- public function testGetVersionWithFileInfo() {
+ public function testGetVersionWithFileInfo(): void {
$view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$fileInfo = $this->getMockBuilder(FileInfo::class)
@@ -679,7 +679,7 @@ class KeyManagerTest extends TestCase {
$this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view));
}
- public function testSetVersionWithFileInfo() {
+ public function testSetVersionWithFileInfo(): void {
$view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$cache = $this->getMockBuilder(ICache::class)
@@ -709,7 +709,7 @@ class KeyManagerTest extends TestCase {
$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
}
- public function testSetVersionWithoutFileInfo() {
+ public function testSetVersionWithoutFileInfo(): void {
$view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$view->expects($this->once())
@@ -721,7 +721,7 @@ class KeyManagerTest extends TestCase {
$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
}
- public function testBackupUserKeys() {
+ public function testBackupUserKeys(): void {
$this->keyStorageMock->expects($this->once())->method('backupUserKeys')
->with('OC_DEFAULT_MODULE', 'test', 'user1');
$this->instance->backupUserKeys('test', 'user1');
diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php
index a4f4ff7fd02..4b28d408844 100644
--- a/apps/encryption/tests/RecoveryTest.php
+++ b/apps/encryption/tests/RecoveryTest.php
@@ -53,7 +53,7 @@ class RecoveryTest extends TestCase {
*/
private $instance;
- public function testEnableAdminRecoverySuccessful() {
+ public function testEnableAdminRecoverySuccessful(): void {
$this->keyManagerMock->expects($this->exactly(2))
->method('recoveryKeyExists')
->willReturnOnConsecutiveCalls(false, true);
@@ -80,7 +80,7 @@ class RecoveryTest extends TestCase {
$this->assertTrue($this->instance->enableAdminRecovery('password'));
}
- public function testEnableAdminRecoveryCouldNotCheckPassword() {
+ public function testEnableAdminRecoveryCouldNotCheckPassword(): void {
$this->keyManagerMock->expects($this->exactly(2))
->method('recoveryKeyExists')
->willReturnOnConsecutiveCalls(false, true);
@@ -107,7 +107,7 @@ class RecoveryTest extends TestCase {
$this->assertFalse($this->instance->enableAdminRecovery('password'));
}
- public function testEnableAdminRecoveryCouldNotCreateKey() {
+ public function testEnableAdminRecoveryCouldNotCreateKey(): void {
$this->keyManagerMock->expects($this->once())
->method('recoveryKeyExists')
->willReturn(false);
@@ -119,7 +119,7 @@ class RecoveryTest extends TestCase {
$this->assertFalse($this->instance->enableAdminRecovery('password'));
}
- public function testChangeRecoveryKeyPasswordSuccessful() {
+ public function testChangeRecoveryKeyPasswordSuccessful(): void {
$this->assertFalse($this->instance->changeRecoveryKeyPassword('password',
'passwordOld'));
@@ -137,7 +137,7 @@ class RecoveryTest extends TestCase {
'passwordOld'));
}
- public function testChangeRecoveryKeyPasswordCouldNotDecryptPrivateRecoveryKey() {
+ public function testChangeRecoveryKeyPasswordCouldNotDecryptPrivateRecoveryKey(): void {
$this->assertFalse($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
$this->keyManagerMock->expects($this->once())
@@ -150,7 +150,7 @@ class RecoveryTest extends TestCase {
$this->assertFalse($this->instance->changeRecoveryKeyPassword('password', 'passwordOld'));
}
- public function testDisableAdminRecovery() {
+ public function testDisableAdminRecovery(): void {
$this->keyManagerMock->expects($this->exactly(2))
->method('checkRecoveryPassword')
->willReturnOnConsecutiveCalls(true, false);
@@ -162,7 +162,7 @@ class RecoveryTest extends TestCase {
$this->assertFalse($this->instance->disableAdminRecovery('password'));
}
- public function testIsRecoveryEnabledForUser() {
+ public function testIsRecoveryEnabledForUser(): void {
$this->configMock->expects($this->exactly(2))
->method('getUserValue')
->willReturnOnConsecutiveCalls('1', '0');
@@ -171,13 +171,13 @@ class RecoveryTest extends TestCase {
$this->assertFalse($this->instance->isRecoveryEnabledForUser('admin'));
}
- public function testIsRecoveryKeyEnabled() {
+ public function testIsRecoveryKeyEnabled(): void {
$this->assertFalse($this->instance->isRecoveryKeyEnabled());
self::$tempStorage['recoveryAdminEnabled'] = '1';
$this->assertTrue($this->instance->isRecoveryKeyEnabled());
}
- public function testSetRecoveryFolderForUser() {
+ public function testSetRecoveryFolderForUser(): void {
$this->viewMock->expects($this->exactly(2))
->method('getDirectoryContent')
->willReturn([]);
@@ -185,7 +185,7 @@ class RecoveryTest extends TestCase {
$this->assertTrue($this->instance->setRecoveryForUser('1'));
}
- public function testRecoverUserFiles() {
+ public function testRecoverUserFiles(): void {
$this->viewMock->expects($this->once())
->method('getDirectoryContent')
->willReturn([]);
@@ -197,7 +197,7 @@ class RecoveryTest extends TestCase {
$this->addToAssertionCount(1);
}
- public function testRecoverFile() {
+ public function testRecoverFile(): void {
$this->keyManagerMock->expects($this->once())
->method('getEncryptedFileKey')
->willReturn(true);
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php
index 61e57f66611..10c699898fc 100644
--- a/apps/encryption/tests/SessionTest.php
+++ b/apps/encryption/tests/SessionTest.php
@@ -21,7 +21,7 @@ class SessionTest extends TestCase {
private $sessionMock;
- public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() {
+ public function testThatGetPrivateKeyThrowsExceptionWhenNotSet(): void {
$this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
$this->expectExceptionMessage('Private Key missing for user: please try to log-out and log-in again');
@@ -31,7 +31,7 @@ class SessionTest extends TestCase {
/**
* @depends testThatGetPrivateKeyThrowsExceptionWhenNotSet
*/
- public function testSetAndGetPrivateKey() {
+ public function testSetAndGetPrivateKey(): void {
$this->instance->setPrivateKey('dummyPrivateKey');
$this->assertEquals('dummyPrivateKey', $this->instance->getPrivateKey());
}
@@ -39,7 +39,7 @@ class SessionTest extends TestCase {
/**
* @depends testSetAndGetPrivateKey
*/
- public function testIsPrivateKeySet() {
+ public function testIsPrivateKeySet(): void {
$this->instance->setPrivateKey('dummyPrivateKey');
$this->assertTrue($this->instance->isPrivateKeySet());
@@ -50,21 +50,21 @@ class SessionTest extends TestCase {
self::$tempStorage['privateKey'] = 'dummyPrivateKey';
}
- public function testDecryptAllModeActivated() {
+ public function testDecryptAllModeActivated(): void {
$this->instance->prepareDecryptAll('user1', 'usersKey');
$this->assertTrue($this->instance->decryptAllModeActivated());
$this->assertSame('user1', $this->instance->getDecryptAllUid());
$this->assertSame('usersKey', $this->instance->getDecryptAllKey());
}
- public function testDecryptAllModeDeactivated() {
+ public function testDecryptAllModeDeactivated(): void {
$this->assertFalse($this->instance->decryptAllModeActivated());
}
/**
* @expectExceptionMessage 'Please activate decrypt all mode first'
*/
- public function testGetDecryptAllUidException() {
+ public function testGetDecryptAllUidException(): void {
$this->expectException(\Exception::class);
$this->instance->getDecryptAllUid();
@@ -73,7 +73,7 @@ class SessionTest extends TestCase {
/**
* @expectExceptionMessage 'No uid found while in decrypt all mode'
*/
- public function testGetDecryptAllUidException2() {
+ public function testGetDecryptAllUidException2(): void {
$this->expectException(\Exception::class);
$this->instance->prepareDecryptAll(null, 'key');
@@ -83,7 +83,7 @@ class SessionTest extends TestCase {
/**
* @expectExceptionMessage 'Please activate decrypt all mode first'
*/
- public function testGetDecryptAllKeyException() {
+ public function testGetDecryptAllKeyException(): void {
$this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
$this->instance->getDecryptAllKey();
@@ -92,7 +92,7 @@ class SessionTest extends TestCase {
/**
* @expectExceptionMessage 'No key found while in decrypt all mode'
*/
- public function testGetDecryptAllKeyException2() {
+ public function testGetDecryptAllKeyException2(): void {
$this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
$this->instance->prepareDecryptAll('user', null);
@@ -100,7 +100,7 @@ class SessionTest extends TestCase {
}
- public function testSetAndGetStatusWillSetAndReturn() {
+ public function testSetAndGetStatusWillSetAndReturn(): void {
// Check if get status will return 0 if it has not been set before
$this->assertEquals(0, $this->instance->getStatus());
@@ -120,7 +120,7 @@ class SessionTest extends TestCase {
* @param int $status
* @param bool $expected
*/
- public function testIsReady($status, $expected) {
+ public function testIsReady($status, $expected): void {
/** @var Session | \PHPUnit\Framework\MockObject\MockObject $instance */
$instance = $this->getMockBuilder(Session::class)
->setConstructorArgs([$this->sessionMock])
@@ -167,7 +167,7 @@ class SessionTest extends TestCase {
}
- public function testClearWillRemoveValues() {
+ public function testClearWillRemoveValues(): void {
$this->instance->setPrivateKey('privateKey');
$this->instance->setStatus('initStatus');
$this->instance->prepareDecryptAll('user', 'key');
diff --git a/apps/encryption/tests/Settings/AdminTest.php b/apps/encryption/tests/Settings/AdminTest.php
index 80f7803badd..4ddaeb1b84d 100644
--- a/apps/encryption/tests/Settings/AdminTest.php
+++ b/apps/encryption/tests/Settings/AdminTest.php
@@ -51,7 +51,7 @@ class AdminTest extends TestCase {
);
}
- public function testGetForm() {
+ public function testGetForm(): void {
$this->config
->method('getAppValue')
->will($this->returnCallback(function ($app, $key, $default) {
@@ -73,11 +73,11 @@ class AdminTest extends TestCase {
$this->assertEquals($expected, $this->admin->getForm());
}
- public function testGetSection() {
+ public function testGetSection(): void {
$this->assertSame('security', $this->admin->getSection());
}
- public function testGetPriority() {
+ public function testGetPriority(): void {
$this->assertSame(11, $this->admin->getPriority());
}
}
diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php
index 96d2357269e..92f24a0627c 100644
--- a/apps/encryption/tests/Users/SetupTest.php
+++ b/apps/encryption/tests/Users/SetupTest.php
@@ -42,7 +42,7 @@ class SetupTest extends TestCase {
}
- public function testSetupSystem() {
+ public function testSetupSystem(): void {
$this->keyManagerMock->expects($this->once())->method('validateShareKey');
$this->keyManagerMock->expects($this->once())->method('validateMasterKey');
@@ -55,7 +55,7 @@ class SetupTest extends TestCase {
* @param bool $hasKeys
* @param bool $expected
*/
- public function testSetupUser($hasKeys, $expected) {
+ 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 3bfc0efb516..6f2eec1ebf4 100644
--- a/apps/encryption/tests/UtilTest.php
+++ b/apps/encryption/tests/UtilTest.php
@@ -37,12 +37,12 @@ class UtilTest extends TestCase {
/** @var Util */
private $instance;
- public function testSetRecoveryForUser() {
+ public function testSetRecoveryForUser(): void {
$this->instance->setRecoveryForUser('1');
$this->assertArrayHasKey('recoveryEnabled', self::$tempStorage);
}
- public function testIsRecoveryEnabledForUser() {
+ public function testIsRecoveryEnabledForUser(): void {
$this->assertTrue($this->instance->isRecoveryEnabledForUser('admin'));
// Assert recovery will return default value if not set
@@ -50,7 +50,7 @@ class UtilTest extends TestCase {
$this->assertEquals(0, $this->instance->isRecoveryEnabledForUser('admin'));
}
- public function testUserHasFiles() {
+ public function testUserHasFiles(): void {
$this->filesMock->expects($this->once())
->method('file_exists')
->willReturn(true);
@@ -126,7 +126,7 @@ class UtilTest extends TestCase {
* @param string $value
* @param bool $expect
*/
- public function testIsMasterKeyEnabled($value, $expect) {
+ public function testIsMasterKeyEnabled($value, $expect): void {
$this->configMock->expects($this->once())->method('getAppValue')
->with('encryption', 'useMasterKey', '1')->willReturn($value);
$this->assertSame($expect,
@@ -146,7 +146,7 @@ class UtilTest extends TestCase {
* @param string $returnValue return value from getAppValue()
* @param bool $expected
*/
- public function testShouldEncryptHomeStorage($returnValue, $expected) {
+ public function testShouldEncryptHomeStorage($returnValue, $expected): void {
$this->configMock->expects($this->once())->method('getAppValue')
->with('encryption', 'encryptHomeStorage', '1')
->willReturn($returnValue);
@@ -167,7 +167,7 @@ class UtilTest extends TestCase {
* @param $value
* @param $expected
*/
- public function testSetEncryptHomeStorage($value, $expected) {
+ public function testSetEncryptHomeStorage($value, $expected): void {
$this->configMock->expects($this->once())->method('setAppValue')
->with('encryption', 'encryptHomeStorage', $expected);
$this->instance->setEncryptHomeStorage($value);
@@ -180,7 +180,7 @@ class UtilTest extends TestCase {
];
}
- public function testGetStorage() {
+ public function testGetStorage(): void {
$return = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();