2026-05-01 00:40:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
2026-05-11 01:59:31 +00:00
|
|
|
namespace Tests\E2E\Services\Advisor;
|
2026-05-01 00:40:59 +00:00
|
|
|
|
2026-05-06 08:20:54 +00:00
|
|
|
use Tests\E2E\Client;
|
2026-05-01 00:40:59 +00:00
|
|
|
use Tests\E2E\Scopes\ProjectCustom;
|
|
|
|
|
use Tests\E2E\Scopes\Scope;
|
|
|
|
|
use Tests\E2E\Scopes\SideServer;
|
2026-05-06 08:20:54 +00:00
|
|
|
use Utopia\Database\Helpers\ID;
|
2026-05-01 00:40:59 +00:00
|
|
|
|
2026-05-11 01:59:31 +00:00
|
|
|
class AdvisorCustomServerTest extends Scope
|
2026-05-01 00:40:59 +00:00
|
|
|
{
|
2026-05-11 01:59:31 +00:00
|
|
|
use AdvisorBase;
|
2026-05-01 00:40:59 +00:00
|
|
|
use ProjectCustom;
|
|
|
|
|
use SideServer;
|
2026-05-06 08:20:54 +00:00
|
|
|
|
2026-05-08 06:07:23 +00:00
|
|
|
public function testReadWithAdvisorScopes(): void
|
2026-05-06 08:20:54 +00:00
|
|
|
{
|
2026-05-08 13:49:22 +00:00
|
|
|
$projectId = $this->getProject()['$id'];
|
|
|
|
|
|
2026-05-06 08:20:54 +00:00
|
|
|
$userKey = $this->getNewKey([
|
2026-05-11 02:08:29 +00:00
|
|
|
// Advisor read APIs are protected by the underlying report/insight resource scopes.
|
2026-05-06 08:20:54 +00:00
|
|
|
'insights.read',
|
2026-05-08 06:07:23 +00:00
|
|
|
'reports.read',
|
2026-05-06 08:20:54 +00:00
|
|
|
]);
|
|
|
|
|
|
2026-05-08 06:07:23 +00:00
|
|
|
$listed = $this->client->call(
|
|
|
|
|
Client::METHOD_GET,
|
|
|
|
|
'/reports',
|
|
|
|
|
[
|
|
|
|
|
'content-type' => 'application/json',
|
2026-05-08 13:49:22 +00:00
|
|
|
'x-appwrite-project' => $projectId,
|
2026-05-08 06:07:23 +00:00
|
|
|
'x-appwrite-key' => $userKey,
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertSame(200, $listed['headers']['status-code']);
|
|
|
|
|
|
|
|
|
|
$create = $this->client->call(
|
2026-05-06 08:20:54 +00:00
|
|
|
Client::METHOD_POST,
|
2026-05-08 06:07:23 +00:00
|
|
|
'/reports',
|
2026-05-06 08:20:54 +00:00
|
|
|
[
|
|
|
|
|
'content-type' => 'application/json',
|
2026-05-08 13:49:22 +00:00
|
|
|
'x-appwrite-project' => $projectId,
|
2026-05-06 08:20:54 +00:00
|
|
|
'x-appwrite-key' => $userKey,
|
|
|
|
|
],
|
2026-05-08 06:07:23 +00:00
|
|
|
[
|
|
|
|
|
'reportId' => ID::unique(),
|
|
|
|
|
'type' => 'audit',
|
|
|
|
|
'title' => 'Read-only check',
|
|
|
|
|
'targetType' => 'sites',
|
|
|
|
|
'target' => 'home',
|
|
|
|
|
]
|
2026-05-06 08:20:54 +00:00
|
|
|
);
|
|
|
|
|
|
2026-05-08 06:07:23 +00:00
|
|
|
$this->assertSame(404, $create['headers']['status-code']);
|
2026-05-06 08:20:54 +00:00
|
|
|
}
|
2026-05-01 00:40:59 +00:00
|
|
|
}
|