mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #13194 from appwrite/test/sites-start-command-not-exposed
fix(sites): stop listFrameworks leaking runtime start commands
This commit is contained in:
3 files changed
+66
No files matched your search
@@ -562,6 +562,10 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
foreach ($data[$key] as $index => $item) {
|
||||
if (\is_array($item) && !\is_array($rule['type']) && self::hasModel($rule['type'])) {
|
||||
$item = new Document($item);
|
||||
}
|
||||
|
||||
if ($item instanceof Document) {
|
||||
$ruleType = null;
|
||||
|
||||
|
||||
@@ -117,6 +117,28 @@ final class SitesCustomClientTest extends Scope
|
||||
$this->assertEquals(400, $templates['headers']['status-code']);
|
||||
}
|
||||
|
||||
public function testListTemplatesHidesInternalFields()
|
||||
{
|
||||
$templates = $this->client->call(Client::METHOD_GET, '/sites/templates', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'limit' => 5000,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $templates['headers']['status-code']);
|
||||
$this->assertGreaterThan(0, $templates['body']['total']);
|
||||
|
||||
$this->assertStringNotContainsString('startCommand', (string) json_encode($templates['body']));
|
||||
$this->assertStringNotContainsString('score', (string) json_encode($templates['body']));
|
||||
|
||||
$template = $this->getTemplate('starter-for-nextjs');
|
||||
|
||||
$this->assertEquals(200, $template['headers']['status-code']);
|
||||
|
||||
$this->assertStringNotContainsString('startCommand', (string) json_encode($template['body']));
|
||||
}
|
||||
|
||||
public function testGetTemplate()
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -2348,6 +2348,46 @@ final class SitesCustomServerTest extends Scope
|
||||
$this->assertArrayHasKey('outputDirectory', $framework['adapters'][0]);
|
||||
}
|
||||
|
||||
public function testGetFrameworksHidesStartCommand(): void
|
||||
{
|
||||
$frameworks = $this->client->call(Client::METHOD_GET, '/sites/frameworks', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]));
|
||||
|
||||
$this->assertEquals(200, $frameworks['headers']['status-code']);
|
||||
$this->assertGreaterThan(0, $frameworks['body']['total']);
|
||||
|
||||
$this->assertStringNotContainsString('startCommand', (string) json_encode($frameworks['body']));
|
||||
}
|
||||
|
||||
public function testCreateSiteHidesStartCommand(): void
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'SSR site without a start command',
|
||||
'framework' => 'nextjs',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'node-22',
|
||||
'outputDirectory' => './.next',
|
||||
'buildCommand' => 'npm run build',
|
||||
'installCommand' => 'npm install',
|
||||
]);
|
||||
|
||||
$site = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $site['headers']['status-code']);
|
||||
|
||||
// An omitted start command stays empty; the runtime resolves its own default at boot.
|
||||
$this->assertSame('', $site['body']['startCommand']);
|
||||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
|
||||
public function testSiteStatic(): void
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
|
||||
Reference in new issue
Block a user