Merge pull request #4066 from nextcloud/bugfix/delete_acl

Fix deleteAcl
This commit is contained in:
Julius Härtl
2022-09-23 10:05:09 +02:00
committed by GitHub
4 changed files with 20 additions and 9 deletions

View File

@@ -81,7 +81,7 @@ class CardReferenceProvider implements IReferenceProvider {
$card = $this->sanitizeSerializedCard($card);
$board = $this->sanitizeSerializedBoard($board);
$stack = $this->sanitizeSerializedStack($stack);
/** @var IReference $reference */
$reference = new Reference($referenceText);
$reference->setRichObject(Application::APP_ID . '-card', [
'id' => $boardId . '/' . $cardId,

View File

@@ -42,6 +42,7 @@ use OCA\Deck\Event\AclUpdatedEvent;
use OCA\Deck\NoPermissionException;
use OCA\Deck\Notification\NotificationHelper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -55,6 +56,8 @@ use OCP\IUserManager;
use OCA\Deck\BadRequestException;
use OCP\IURLGenerator;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class BoardService {
private BoardMapper $boardMapper;
@@ -592,12 +595,14 @@ class BoardService {
}
/**
* @throws DbException
* @throws DoesNotExistException
* @throws \OCA\Deck\NoPermissionException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
* @throws NoPermissionException
* @throws MultipleObjectsReturnedException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function deleteAcl(int $id): bool {
public function deleteAcl(int $id): ?Acl {
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
/** @var Acl $acl */
$acl = $this->aclMapper->find($id);
@@ -622,8 +627,10 @@ class BoardService {
}
}
$deletedAcl = $this->aclMapper->delete($acl);
$this->eventDispatcher->dispatchTyped(new AclDeletedEvent($acl));
return (bool) $this->aclMapper->delete($acl);
return $deletedAcl;
}
/**

View File

@@ -427,6 +427,6 @@ class BoardServiceTest extends TestCase {
->method('delete')
->with($acl)
->willReturn($acl);
$this->assertTrue($this->service->deleteAcl(123));
$this->assertEquals($acl, $this->service->deleteAcl(123));
}
}

View File

@@ -164,10 +164,14 @@ class BoardControllerTest extends \Test\TestCase {
}
public function testDeleteAcl() {
$acl = $this->getMockBuilder(Acl::class)
->disableOriginalConstructor()
->getMock();
$this->boardService->expects($this->once())
->method('deleteAcl')
->with(1)
->willReturn(true);
$this->assertEquals(true, $this->controller->deleteAcl(1));
->willReturn($acl);
$this->assertEquals($acl, $this->controller->deleteAcl(1));
}
}