|
19 | 19 | use OCA\GroupFolders\Folder\FolderManager;
|
20 | 20 | use OCA\GroupFolders\Mount\GroupFolderStorage;
|
21 | 21 | use OCA\GroupFolders\Trash\TrashBackend;
|
| 22 | +use OCP\Constants; |
22 | 23 | use OCP\Files\Folder;
|
23 | 24 | use OCP\Files\IRootFolder;
|
24 | 25 | use OCP\IUser;
|
| 26 | +use OCP\Server; |
| 27 | +use OCP\Share; |
25 | 28 | use Test\TestCase;
|
26 | 29 | use Test\Traits\UserTrait;
|
27 | 30 |
|
@@ -211,4 +214,61 @@ public function testHideDeletedTrashItemInDeletedParentFolderAcl(): void {
|
211 | 214 |
|
212 | 215 | $this->logout();
|
213 | 216 | }
|
| 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 | + } |
214 | 274 | }
|
0 commit comments