Skip to content

Commit

Permalink
test(timeout): locks are deprecated after expiry
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Feb 17, 2025
1 parent 9b0dd93 commit 4f5c5ae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Feature/LockFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
use OC\Files\Lock\LockManager;
use OCA\FilesLock\AppInfo\Application;
use OCA\FilesLock\Service\ConfigService;
use OCA\FilesLock\Service\LockService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IRootFolder;
use OCP\Files\Lock\ILock;
use OCP\Files\Lock\ILockManager;
use OCP\Files\Lock\LockContext;
use OCP\IConfig;
use OCP\Lock\ManuallyLockedException;
use OCP\Share\IShare;
use Test\TestCase;
Expand Down Expand Up @@ -209,6 +211,16 @@ public function testLockUserExpire() {
self::assertEquals('CCC', $file->getContent());
}

public function testExpiredLocksAreDeprecated() {
\OCP\Server::get(IConfig::class)->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 30);
$file = $this->loginAndGetUserFolder(self::TEST_USER1)
->newFile('test-expired-lock-is-deprecated', 'AAA');
$this->lockManager->lock(new LockContext($file, ILock::TYPE_USER, self::TEST_USER1));
$this->toTheFuture(3600);
$deprecated = \OCP\Server::get(LockService::class)->getDeprecatedLocks();
self::assertNotEmpty($deprecated);
}

public function testLockUserInfinite() {
\OC::$server->getConfig()->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 0);
$file = $this->loginAndGetUserFolder(self::TEST_USER1)
Expand Down

0 comments on commit 4f5c5ae

Please sign in to comment.