Skip to content

Commit 9ff7e62

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

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/Trash/TrashBackendTest.php

+62
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@
1111

1212
use OC\Files\SetupManager;
1313
use OC\Group\Database;
14+
use OCA\Files_Trashbin\Trash\ITrashManager;
1415
use OCA\GroupFolders\ACL\ACLManager;
1516
use OCA\GroupFolders\ACL\ACLManagerFactory;
1617
use OCA\GroupFolders\ACL\Rule;
1718
use OCA\GroupFolders\ACL\RuleManager;
1819
use OCA\GroupFolders\ACL\UserMapping\UserMapping;
1920
use OCA\GroupFolders\Folder\FolderManager;
2021
use OCA\GroupFolders\Mount\GroupFolderStorage;
22+
use OCA\GroupFolders\Trash\GroupTrashItem;
2123
use OCA\GroupFolders\Trash\TrashBackend;
24+
use OCP\Constants;
2225
use OCP\Files\Folder;
2326
use OCP\Files\IRootFolder;
2427
use OCP\IUser;
28+
use OCP\Server;
29+
use OCP\Share;
2530
use Test\TestCase;
2631
use Test\Traits\UserTrait;
2732

@@ -211,4 +216,61 @@ public function testHideDeletedTrashItemInDeletedParentFolderAcl(): void {
211216

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

0 commit comments

Comments
 (0)