Skip to content

Commit 1276961

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

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/Trash/TrashBackendTest.php

+61
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,62 @@ 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->setFolderACL($groupFolderId, true);
230+
$this->folderManager->addApplicableGroup($groupFolderId, 'A');
231+
$this->assertInstanceOf(Folder::class, $userAFolder->get('A'));
232+
233+
$this->loginAsUser('A');
234+
235+
$userAFolder->newFolder('A/B');
236+
$this->ruleManager->saveRule(new Rule(new UserMapping('group', 'A'), $userAFolder->get('A/B')->getId(), Constants::PERMISSION_ALL, 0));
237+
$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));
238+
// TODO: Bug?
239+
//$this->assertSame(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_CREATE, $this->aclManager->getACLPermissionsForPath('A/B'));
240+
241+
$userAFolder->newFolder('A/B/C');
242+
$this->ruleManager->saveRule(new Rule(new UserMapping('user', 'A'), $userAFolder->get('A/B/C')->getId(), Constants::PERMISSION_ALL, Constants::PERMISSION_ALL));
243+
$this->assertSame(Constants::PERMISSION_ALL, $this->aclManager->getACLPermissionsForPath('A/B/C'));
244+
245+
$userAFolder->newFile('A/B/C/D', 'foo');
246+
247+
$shareManager = Server::get(Share\IManager::class);
248+
249+
$folderShare = $shareManager->newShare();
250+
$folderShare->setShareType(Share\IShare::TYPE_USER);
251+
$folderShare->setSharedWith('B');
252+
$folderShare->setSharedBy('A');
253+
$folderShare->setPermissions(19);
254+
$folderShare->setNode($userAFolder->get('A/B/C'));
255+
$folderShare = $shareManager->createShare($folderShare);
256+
$this->assertNotEmpty($folderShare->getId());
257+
258+
$fileShare = $shareManager->newShare();
259+
$fileShare->setShareType(Share\IShare::TYPE_USER);
260+
$fileShare->setSharedWith('B');
261+
$fileShare->setSharedBy('A');
262+
$fileShare->setPermissions(19);
263+
$fileShare->setNode($userAFolder->get('A/B/C/D'));
264+
$fileShare = $shareManager->createShare($fileShare);
265+
$this->assertNotEmpty($fileShare->getId());
266+
267+
$this->loginAsUser('B');
268+
269+
$this->assertTrue($userBFolder->get('D')->isDeletable());
270+
$userBFolder->get('D')->delete();
271+
272+
// TODO: Bug?
273+
$this->assertCount(1, $this->trashBackend->listTrashRoot($userA));
274+
}
214275
}

0 commit comments

Comments
 (0)