Skip to content

Commit 723b441

Browse files
authored
Merge pull request #60000 from cuppett/cuppett/test-isolation
2 parents e6a1bfd + c2e2b57 commit 723b441

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/lib/TestCase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\Command\IBus;
2828
use OCP\DB\QueryBuilder\IQueryBuilder;
2929
use OCP\Files\IRootFolder;
30+
use OCP\IAppConfig;
3031
use OCP\IConfig;
3132
use OCP\IDBConnection;
3233
use OCP\IUserManager;
@@ -195,6 +196,22 @@ protected function tearDown(): void {
195196
call_user_func([$this, $methodName]);
196197
}
197198
}
199+
200+
// Clean up encryption state to prevent test pollution
201+
// This ensures encryption_enabled is reset after each test, preventing
202+
// MultiKeyEncryptException failures in subsequent tests when encryption
203+
// is left enabled but user keys don't exist
204+
try {
205+
$appConfig = Server::get(IAppConfig::class);
206+
$currentValue = $appConfig->getValueBool('core', 'encryption_enabled', false);
207+
if ($currentValue) {
208+
$appConfig->setValueBool('core', 'encryption_enabled', false);
209+
$appConfig->deleteKey('core', 'default_encryption_module');
210+
$appConfig->deleteKey('encryption', 'useMasterKey');
211+
}
212+
} catch (\Throwable $e) {
213+
// Ignore - may be called before bootstrap completes
214+
}
198215
}
199216

200217
/**

0 commit comments

Comments
 (0)