Added BadRequestException checks in DefaultBoardService. Fixed bug in DefaultBoardService BadRequestException checks.

Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
Ryan Fletcher
2018-08-07 08:50:00 -04:00
committed by Julius Härtl
parent 6f5c0a2816
commit aba7d02cfe
3 changed files with 20 additions and 4 deletions

View File

@@ -446,15 +446,15 @@ class BoardService {
throw new BadRequestException('id must be a number'); throw new BadRequestException('id must be a number');
} }
if ($edit === false || $edit === null) { if ($edit === null) {
throw new BadRequestException('edit must be provided'); throw new BadRequestException('edit must be provided');
} }
if ($share === false || $share === null) { if ($share === null) {
throw new BadRequestException('share must be provided'); throw new BadRequestException('share must be provided');
} }
if ($manage === false || $manage === null) { if ($manage === null) {
throw new BadRequestException('manage must be provided'); throw new BadRequestException('manage must be provided');
} }

View File

@@ -29,6 +29,7 @@ use OCA\Deck\Service\StackService;
use OCA\Deck\Service\CardService; use OCA\Deck\Service\CardService;
use OCP\IConfig; use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCA\Deck\BadRequestException;
class DefaultBoardService { class DefaultBoardService {
@@ -83,8 +84,22 @@ class DefaultBoardService {
* @throws \OCA\Deck\StatusException * @throws \OCA\Deck\StatusException
* @throws \OCP\AppFramework\Db\DoesNotExistException * @throws \OCP\AppFramework\Db\DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws BadRequestException
*/ */
public function createDefaultBoard($title, $userId, $color) { public function createDefaultBoard($title, $userId, $color) {
if ($title === false || $title === null) {
throw new BadRequestException('title must be provided');
}
if ($userId === false || $userId == null) {
throw new BadRequestException('userId must be provided');
}
if ($color === false || $color === null) {
throw new BadRequestException('color must be provided');
}
$defaultBoard = $this->boardService->create($title, $userId, $color); $defaultBoard = $this->boardService->create($title, $userId, $color);
$defaultStacks = []; $defaultStacks = [];
$defaultCards = []; $defaultCards = [];

View File

@@ -67,6 +67,7 @@ class DefaultBoardServiceTest extends TestCase {
$this->cardService = $this->createMock(CardService::class); $this->cardService = $this->createMock(CardService::class);
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class); $this->l10n = $this->createMock(IL10N::class);
$this->userId = 'admin';
$this->service = new DefaultBoardService( $this->service = new DefaultBoardService(
$this->l10n, $this->l10n,