mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
fix(tests): Fix encryption test isolation between test runs
Add global encryption teardown to TestCase base class so encryption state does not leak between test suites regardless of which tests ran earlier. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Stephen Cuppett <steve@cuppett.com>
This commit is contained in:
parent
b81a45b560
commit
c2e2b5704d
1 changed files with 17 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ use OC\User\Session;
|
|||
use OCP\Command\IBus;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
|
|
@ -195,6 +196,22 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
|
|||
call_user_func([$this, $methodName]);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up encryption state to prevent test pollution
|
||||
// This ensures encryption_enabled is reset after each test, preventing
|
||||
// MultiKeyEncryptException failures in subsequent tests when encryption
|
||||
// is left enabled but user keys don't exist
|
||||
try {
|
||||
$appConfig = Server::get(IAppConfig::class);
|
||||
$currentValue = $appConfig->getValueBool('core', 'encryption_enabled', false);
|
||||
if ($currentValue) {
|
||||
$appConfig->setValueBool('core', 'encryption_enabled', false);
|
||||
$appConfig->deleteKey('core', 'default_encryption_module');
|
||||
$appConfig->deleteKey('encryption', 'useMasterKey');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Ignore - may be called before bootstrap completes
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue