Skip to content

Commit

Permalink
ci fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
  • Loading branch information
Florian Steffens committed Aug 10, 2023
1 parent c318e84 commit 29f1912
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
['name' => 'api1#indexTableRows', 'url' => '/api/1/tables/{tableId}/rows', 'verb' => 'GET'],
['name' => 'api1#indexViewRows', 'url' => '/api/1/views/{viewId}/rows', 'verb' => 'GET'],
['name' => 'api1#createRowInView', 'url' => '/api/1/views/{viewId}/rows', 'verb' => 'POST'],
['name' => 'row#createRowInTable', 'url' => '/api/1/tables/{tableId}/rows', 'verb' => 'POST'],
['name' => 'api1#createRowInTable', 'url' => '/api/1/tables/{tableId}/rows', 'verb' => 'POST'],

['name' => 'api1#getRow', 'url' => '/api/1/rows/{rowId}', 'verb' => 'GET'],
['name' => 'api1#deleteRowByView', 'url' => '/api/1/views/{viewId}/rows/{rowId}', 'verb' => 'DELETE'],
['name' => 'api1#updateRow', 'url' => '/api/1/rows/{rowId}', 'verb' => 'PUT'],
['name' => 'api1#deleteRow', 'url' => '/api/1/rows/{rowId}', 'verb' => 'DELETE'],
// -> import
['name' => 'api1#importInTable', 'url' => '/api/1/import/table/{tablesId}', 'verb' => 'POST'],
['name' => 'api1#importInTable', 'url' => '/api/1/import/table/{tableId}', 'verb' => 'POST'],
['name' => 'api1#importInView', 'url' => '/api/1/import/views/{viewId}', 'verb' => 'POST'],

// Deprecated API calls
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public function getTable(int $tableId): DataResponse {
* @CORS
* @NoCSRFRequired
*/
public function updateTable(int $id, string $title = null, string $emoji = null): DataResponse {
return $this->handleError(function () use ($id, $title, $emoji) {
return $this->tableService->update($id, $title, $emoji, $this->userId);
public function updateTable(int $tableId, string $title = null, string $emoji = null): DataResponse {
return $this->handleError(function () use ($tableId, $title, $emoji) {
return $this->tableService->update($tableId, $title, $emoji, $this->userId);
});
}

Expand Down
8 changes: 7 additions & 1 deletion lib/Service/PermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function preCheckUserId(string $userId = null, bool $canBeEmpty = true):

// ***** TABLES permissions *****

public function canReadTable(Table $table, ?string $userId = null): bool {
return $this->canReadColumnsByTableId($table->getId(), $userId);
}

/**
* @param Table $table
* @param string|null $userId
Expand Down Expand Up @@ -173,7 +177,9 @@ public function canReadColumnsByViewId(int $viewId, ?string $userId = null): boo
}

public function canReadColumnsByTableId(int $tableId, ?string $userId = null): bool {
return $this->canReadRowsByElementId($tableId, 'table', $userId);
$canReadRows = $this->checkPermissionById($tableId, 'table', 'read', $userId);
$canCreateRows = $this->checkPermissionById($tableId, 'table', 'create', $userId);
return $canCreateRows || $canReadRows;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/Service/TableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function find(int $id, bool $skipTableEnhancement = false, ?string $userI
$table = $this->mapper->find($id);

// security
if (!$this->permissionsService->canManageTable($table, $userId)) {
if (!$this->permissionsService->canReadTable($table, $userId)) {
throw new PermissionError('PermissionError: can not read table with id '.$id);
}

Expand All @@ -224,7 +224,6 @@ public function find(int $id, bool $skipTableEnhancement = false, ?string $userI
* @throws DoesNotExistException
* @throws InternalError
* @throws MultipleObjectsReturnedException
* @throws NotFoundError
* @throws PermissionError
* @throws \OCP\DB\Exception
*/
Expand Down
1 change: 1 addition & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public function userTables(string $user, TableNode $body = null): void {
);

$data = $this->getDataFromResponse($this->response);

Assert::assertEquals(200, $this->response->getStatusCode());

// check if tables are empty
Expand Down

0 comments on commit 29f1912

Please sign in to comment.