Skip to content

Commit e1e5671

Browse files
icewind1991backportbot[bot]
authored andcommitted
test: adjust tests to caching of key validation
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 00d9a2e commit e1e5671

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

apps/encryption/tests/Command/FixEncryptedVersionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use OC\Files\View;
1414
use OCA\Encryption\Command\FixEncryptedVersion;
15+
use OCA\Encryption\KeyManager;
1516
use OCA\Encryption\Util;
1617
use OCP\Files\IRootFolder;
1718
use OCP\IConfig;
@@ -47,6 +48,8 @@ class FixEncryptedVersionTest extends TestCase {
4748

4849
public function setUp(): void {
4950
parent::setUp();
51+
Server::get(KeyManager::class)->validateMasterKey();
52+
Server::get(KeyManager::class)->validateShareKey();
5053

5154
Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '1');
5255

apps/encryption/tests/EncryptedStorageTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OC\Files\Storage\Temporary;
1212
use OC\Files\Storage\Wrapper\Encryption;
1313
use OC\Files\View;
14+
use OCA\Encryption\KeyManager;
1415
use OCP\Files\Mount\IMountManager;
1516
use OCP\Files\Storage\IDisableEncryptionStorage;
1617
use OCP\Server;
@@ -32,6 +33,8 @@ class EncryptedStorageTest extends TestCase {
3233
use UserTrait;
3334

3435
public function testMoveFromEncrypted(): void {
36+
Server::get(KeyManager::class)->validateMasterKey();
37+
Server::get(KeyManager::class)->validateShareKey();
3538
$this->createUser('test1', 'test2');
3639
$this->setupForUser('test1', 'test2');
3740

apps/encryption/tests/Users/SetupTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use OCA\Encryption\Crypto\Crypt;
1313
use OCA\Encryption\KeyManager;
1414
use OCA\Encryption\Users\Setup;
15+
use OCP\ICache;
16+
use OCP\ICacheFactory;
1517
use PHPUnit\Framework\MockObject\MockObject;
1618
use Test\TestCase;
1719

@@ -32,9 +34,16 @@ protected function setUp(): void {
3234
->disableOriginalConstructor()
3335
->getMock();
3436

37+
$cache = $this->createMock(ICache::class);
38+
$cacheFactory = $this->createMock(ICacheFactory::class);
39+
$cacheFactory->method('createLocal')
40+
->willReturn($cache);
41+
3542
$this->instance = new Setup(
3643
$this->cryptMock,
37-
$this->keyManagerMock);
44+
$this->keyManagerMock,
45+
$cacheFactory,
46+
);
3847
}
3948

4049

0 commit comments

Comments
 (0)