|
39 | 39 | use OCP\Security\ICrypto; |
40 | 40 | use OCP\Share\IManager as IShareManager; |
41 | 41 |
|
| 42 | +use OCP\Share\IShare; |
| 43 | + |
42 | 44 | use OCP\SystemTag\ISystemTagManager; |
43 | 45 | use OCP\SystemTag\ISystemTagObjectMapper; |
44 | 46 |
|
@@ -429,4 +431,41 @@ public function testApproval() { |
429 | 431 | $stateForUser1 = $this->approvalService->getApprovalState($fileToReject->getId(), 'user1'); |
430 | 432 | $this->assertEquals(Application::STATE_REJECTED, $stateForUser1['state']); |
431 | 433 | } |
| 434 | + |
| 435 | + public function testRequestWithCreateSharesWhenUserCannotShareReturnsError(): void { |
| 436 | + // Share a file from user1 to user2 with read-only (no share permission). |
| 437 | + // user2 has access but cannot share -> request with createShares true must return error. |
| 438 | + $uf1 = $this->root->getUserFolder('user1'); |
| 439 | + $file = $uf1->newFile('file_no_share.txt', 'content'); |
| 440 | + $shared = $this->utilsService->createShare( |
| 441 | + $file, |
| 442 | + IShare::TYPE_USER, |
| 443 | + 'user2', |
| 444 | + 'user1', |
| 445 | + 'label' |
| 446 | + ); |
| 447 | + $this->assertTrue($shared); |
| 448 | + |
| 449 | + // Add some tags |
| 450 | + $r = $this->utilsService->createTag('pending4'); |
| 451 | + $idTagPending4 = $r['id']; |
| 452 | + $r = $this->utilsService->createTag('approved4'); |
| 453 | + $idTagApproved4 = $r['id']; |
| 454 | + $r = $this->utilsService->createTag('rejected4'); |
| 455 | + $idTagRejected4 = $r['id']; |
| 456 | + |
| 457 | + $r = $this->ruleService->createRule( |
| 458 | + $idTagPending4, $idTagApproved4, $idTagRejected4, |
| 459 | + [['entityId' => 'user3', 'type' => 'user']], |
| 460 | + [['entityId' => 'user2', 'type' => 'user']], |
| 461 | + 'user 2 request, 3 approves', |
| 462 | + false |
| 463 | + ); |
| 464 | + $ruleId = $r['id']; |
| 465 | + |
| 466 | + $result = $this->approvalService->request($file->getId(), $ruleId, 'user2', true); |
| 467 | + $this->assertArrayHasKey('error', $result); |
| 468 | + |
| 469 | + $this->ruleService->deleteRule($ruleId); |
| 470 | + } |
432 | 471 | } |
0 commit comments