fix(tests): Migrate EncryptionTrait and test files to typed IAppConfig

Update EncryptionTrait, EncryptionMasterKeyUploadTest, EncryptionUploadTest,
and EncryptedSizePropagationTest to use typed IAppConfig::setValueBool/
getValueBool for encryption_enabled and useMasterKey, preventing
AppConfigTypeConflictException when the keys are stored as BOOL type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Stephen Cuppett <steve@cuppett.com>
pull/60002/head
Stephen Cuppett 2 months ago
parent 37a0d6887f
commit b86fa0d0df
  1. 4
      apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php
  2. 4
      apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php
  3. 2
      apps/files_sharing/tests/EncryptedSizePropagationTest.php
  4. 10
      tests/lib/Traits/EncryptionTrait.php

@ -10,7 +10,7 @@ declare(strict_types=1);
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OC\Files\View;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\ITempManager;
use OCP\Server;
use Test\Traits\EncryptionTrait;
@ -30,7 +30,7 @@ class EncryptionMasterKeyUploadTest extends UploadTest {
$tmpFolder = Server::get(ITempManager::class)->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
// we use the master key
Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '1');
Server::get(IAppConfig::class)->setValueBool('encryption', 'useMasterKey', true);
$this->setupForUser($name, $password);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');

@ -10,7 +10,7 @@ declare(strict_types=1);
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OC\Files\View;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\ITempManager;
use OCP\Server;
use Test\Traits\EncryptionTrait;
@ -30,7 +30,7 @@ class EncryptionUploadTest extends UploadTest {
$tmpFolder = Server::get(ITempManager::class)->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
// we use per-user keys
Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '0');
Server::get(IAppConfig::class)->setValueBool('encryption', 'useMasterKey', false);
$this->setupForUser($name, $password);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');

@ -19,7 +19,7 @@ class EncryptedSizePropagationTest extends SizePropagationTest {
protected function setUp(): void {
parent::setUp();
$this->config->setAppValue('encryption', 'useMasterKey', '0');
$this->appConfig->setValueBool('encryption', 'useMasterKey', false);
}
protected function setupUser($name, $password = '') {

@ -18,6 +18,7 @@ use OCA\Encryption\Users\Setup;
use OCP\App\IAppManager;
use OCP\Encryption\IManager;
use OCP\Files\ISetupManager;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\IUserSession;
@ -47,6 +48,8 @@ trait EncryptionTrait {
*/
private $config;
private IAppConfig $appConfig;
/**
* @var Application
*/
@ -108,16 +111,17 @@ trait EncryptionTrait {
$this->encryptionApp = new Application([], $isReady);
$this->config = Server::get(IConfig::class);
$this->encryptionWasEnabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
$this->appConfig = Server::get(IAppConfig::class);
$this->encryptionWasEnabled = $this->appConfig->getValueBool('core', 'encryption_enabled');
$this->originalEncryptionModule = $this->config->getAppValue('core', 'default_encryption_module');
$this->config->setAppValue('core', 'default_encryption_module', Encryption::ID);
$this->config->setAppValue('core', 'encryption_enabled', 'yes');
$this->appConfig->setValueBool('core', 'encryption_enabled', true);
$this->assertTrue(Server::get(\OCP\Encryption\IManager::class)->isEnabled());
}
protected function tearDownEncryptionTrait() {
if ($this->config) {
$this->config->setAppValue('core', 'encryption_enabled', $this->encryptionWasEnabled);
$this->appConfig->setValueBool('core', 'encryption_enabled', $this->encryptionWasEnabled);
$this->config->setAppValue('core', 'default_encryption_module', $this->originalEncryptionModule);
$this->config->deleteAppValue('encryption', 'useMasterKey');
}

Loading…
Cancel
Save