|
23 | 23 |
|
24 | 24 | use OCP\Share\IManager as IShareManager; |
25 | 25 |
|
| 26 | +use OCP\Share\IShare; |
| 27 | + |
26 | 28 | use OCP\SystemTag\ISystemTagManager; |
27 | 29 | use OCP\SystemTag\ISystemTagObjectMapper; |
28 | 30 |
|
@@ -384,4 +386,41 @@ public function testApproval() { |
384 | 386 | $stateForUser1 = $this->approvalService->getApprovalState($fileToReject->getId(), 'user1'); |
385 | 387 | $this->assertEquals(Application::STATE_REJECTED, $stateForUser1['state']); |
386 | 388 | } |
| 389 | + |
| 390 | + public function testRequestWithCreateSharesWhenUserCannotShareReturnsError(): void { |
| 391 | + // Share a file from user1 to user2 with read-only (no share permission). |
| 392 | + // user2 has access but cannot share -> request with createShares true must return error. |
| 393 | + $uf1 = $this->root->getUserFolder('user1'); |
| 394 | + $file = $uf1->newFile('file_no_share.txt', 'content'); |
| 395 | + $shared = $this->utilsService->createShare( |
| 396 | + $file, |
| 397 | + IShare::TYPE_USER, |
| 398 | + 'user2', |
| 399 | + 'user1', |
| 400 | + 'label' |
| 401 | + ); |
| 402 | + $this->assertTrue($shared); |
| 403 | + |
| 404 | + // Add some tags |
| 405 | + $r = $this->utilsService->createTag('pending4'); |
| 406 | + $idTagPending4 = $r['id']; |
| 407 | + $r = $this->utilsService->createTag('approved4'); |
| 408 | + $idTagApproved4 = $r['id']; |
| 409 | + $r = $this->utilsService->createTag('rejected4'); |
| 410 | + $idTagRejected4 = $r['id']; |
| 411 | + |
| 412 | + $r = $this->ruleService->createRule( |
| 413 | + $idTagPending4, $idTagApproved4, $idTagRejected4, |
| 414 | + [['entityId' => 'user3', 'type' => 'user']], |
| 415 | + [['entityId' => 'user2', 'type' => 'user']], |
| 416 | + 'user 2 request, 3 approves', |
| 417 | + false |
| 418 | + ); |
| 419 | + $ruleId = $r['id']; |
| 420 | + |
| 421 | + $result = $this->approvalService->request($file->getId(), $ruleId, 'user2', true); |
| 422 | + $this->assertArrayHasKey('error', $result); |
| 423 | + |
| 424 | + $this->ruleService->deleteRule($ruleId); |
| 425 | + } |
387 | 426 | } |
0 commit comments