test: adjust tests to caching of key validation

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-03-26 17:09:33 +01:00 committed by backportbot[bot]
parent 00d9a2eccb
commit e1e5671a07
3 changed files with 16 additions and 1 deletions

View file

@ -12,6 +12,7 @@ namespace OCA\Encryption\Tests\Command;
use OC\Files\View;
use OCA\Encryption\Command\FixEncryptedVersion;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Util;
use OCP\Files\IRootFolder;
use OCP\IConfig;
@ -47,6 +48,8 @@ class FixEncryptedVersionTest extends TestCase {
public function setUp(): void {
parent::setUp();
Server::get(KeyManager::class)->validateMasterKey();
Server::get(KeyManager::class)->validateShareKey();
Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '1');

View file

@ -11,6 +11,7 @@ namespace OCA\encryption\tests;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCA\Encryption\KeyManager;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Server;
@ -32,6 +33,8 @@ class EncryptedStorageTest extends TestCase {
use UserTrait;
public function testMoveFromEncrypted(): void {
Server::get(KeyManager::class)->validateMasterKey();
Server::get(KeyManager::class)->validateShareKey();
$this->createUser('test1', 'test2');
$this->setupForUser('test1', 'test2');

View file

@ -12,6 +12,8 @@ namespace OCA\Encryption\Tests\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCP\ICache;
use OCP\ICacheFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@ -32,9 +34,16 @@ class SetupTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$cache = $this->createMock(ICache::class);
$cacheFactory = $this->createMock(ICacheFactory::class);
$cacheFactory->method('createLocal')
->willReturn($cache);
$this->instance = new Setup(
$this->cryptMock,
$this->keyManagerMock);
$this->keyManagerMock,
$cacheFactory,
);
}