Skip to content

Commit a665bb7

Browse files
committed
fix(Trash): Fix empty original location
Signed-off-by: provokateurin <[email protected]>
1 parent 2994e18 commit a665bb7

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/Trash/TrashBackendTest.php

+60
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
use OCA\GroupFolders\Folder\FolderManager;
2020
use OCA\GroupFolders\Mount\GroupFolderStorage;
2121
use OCA\GroupFolders\Trash\TrashBackend;
22+
use OCP\Constants;
2223
use OCP\Files\Folder;
2324
use OCP\Files\IRootFolder;
2425
use OCP\IUser;
26+
use OCP\Server;
27+
use OCP\Share;
2528
use Test\TestCase;
2629
use Test\Traits\UserTrait;
2730

@@ -211,4 +214,61 @@ public function testHideDeletedTrashItemInDeletedParentFolderAcl(): void {
211214

212215
$this->logout();
213216
}
217+
218+
public function testBug(): void {
219+
$userA = $this->createUser('A', 'test');
220+
$userAFolder = Server::get(IRootFolder::class)->getUserFolder('A');
221+
$userB = $this->createUser('B', 'test');
222+
$userBFolder = Server::get(IRootFolder::class)->getUserFolder('B');
223+
224+
$groupBackend = Server::get(Database::class);
225+
$groupBackend->createGroup('A');
226+
$groupBackend->addToGroup('A', 'A');
227+
228+
$groupFolderId = $this->folderManager->createFolder('A');
229+
$this->folderManager->addApplicableGroup($groupFolderId, 'A');
230+
$this->assertInstanceOf(Folder::class, $userAFolder->get('A'));
231+
232+
$this->loginAsUser('A');
233+
234+
$userAFolder->newFolder('A/B');
235+
$this->ruleManager->saveRule(new Rule(new UserMapping('group', 'A'), $userAFolder->get('A/B')->getId(), Constants::PERMISSION_ALL, 0));
236+
$this->ruleManager->saveRule(new Rule(new UserMapping('user', 'A'), $userAFolder->get('A/B')->getId(), Constants::PERMISSION_ALL, Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_CREATE));
237+
// TODO: Bug?
238+
//$this->assertSame(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_CREATE, $this->aclManager->getACLPermissionsForPath('A/B'));
239+
240+
$userAFolder->newFolder('A/B/C');
241+
$this->ruleManager->saveRule(new Rule(new UserMapping('user', 'A'), $userAFolder->get('A/B/C')->getId(), Constants::PERMISSION_ALL, Constants::PERMISSION_ALL));
242+
$this->assertSame(Constants::PERMISSION_ALL, $this->aclManager->getACLPermissionsForPath('A/B/C'));
243+
244+
$userAFolder->newFile('A/B/C/D', 'foo');
245+
246+
$shareManager = Server::get(Share\IManager::class);
247+
248+
$folderShare = $shareManager->newShare();
249+
$folderShare->setShareType(Share\IShare::TYPE_USER);
250+
$folderShare->setSharedWith('B');
251+
$folderShare->setSharedBy('A');
252+
$folderShare->setPermissions(19);
253+
$folderShare->setNode($userAFolder->get('A/B/C'));
254+
$folderShare = $shareManager->createShare($folderShare);
255+
$this->assertNotEmpty($folderShare->getId());
256+
257+
$fileShare = $shareManager->newShare();
258+
$fileShare->setShareType(Share\IShare::TYPE_USER);
259+
$fileShare->setSharedWith('B');
260+
$fileShare->setSharedBy('A');
261+
$fileShare->setPermissions(19);
262+
$fileShare->setNode($userAFolder->get('A/B/C/D'));
263+
$fileShare = $shareManager->createShare($fileShare);
264+
$this->assertNotEmpty($fileShare->getId());
265+
266+
$this->loginAsUser('B');
267+
268+
$this->assertTrue($userBFolder->get('D')->isDeletable());
269+
$userBFolder->get('D')->delete();
270+
271+
// TODO: Bug?
272+
$this->assertCount(1, $this->trashBackend->listTrashRoot($userA));
273+
}
214274
}

0 commit comments

Comments
 (0)