mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
49bf1198b2
Agent-Logs-Url: https://github.com/appwrite/appwrite/sessions/517a4586-d3e8-40b3-a3a9-f2d2ca82b0a0 Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\E2E\Services\Advisor;
|
|
|
|
use Tests\E2E\Client;
|
|
use Tests\E2E\Scopes\ProjectCustom;
|
|
use Tests\E2E\Scopes\Scope;
|
|
use Tests\E2E\Scopes\SideServer;
|
|
use Utopia\Database\Helpers\ID;
|
|
|
|
class AdvisorCustomServerTest extends Scope
|
|
{
|
|
use AdvisorBase;
|
|
use ProjectCustom;
|
|
use SideServer;
|
|
|
|
public function testReadWithAdvisorScopes(): void
|
|
{
|
|
$projectId = $this->getProject()['$id'];
|
|
|
|
$userKey = $this->getNewKey([
|
|
// Advisor read APIs are protected by the underlying report/insight resource scopes.
|
|
'insights.read',
|
|
'reports.read',
|
|
]);
|
|
|
|
$listed = $this->client->call(
|
|
Client::METHOD_GET,
|
|
'/reports',
|
|
[
|
|
'content-type' => 'application/json',
|
|
'x-appwrite-project' => $projectId,
|
|
'x-appwrite-key' => $userKey,
|
|
]
|
|
);
|
|
|
|
$this->assertSame(200, $listed['headers']['status-code']);
|
|
|
|
$create = $this->client->call(
|
|
Client::METHOD_POST,
|
|
'/reports',
|
|
[
|
|
'content-type' => 'application/json',
|
|
'x-appwrite-project' => $projectId,
|
|
'x-appwrite-key' => $userKey,
|
|
],
|
|
[
|
|
'reportId' => ID::unique(),
|
|
'type' => 'audit',
|
|
'title' => 'Read-only check',
|
|
'targetType' => 'sites',
|
|
'target' => 'home',
|
|
]
|
|
);
|
|
|
|
$this->assertSame(404, $create['headers']['status-code']);
|
|
}
|
|
}
|