Merge branch 'main' into fix/vcs-installation-region-check

This commit is contained in:
Harsh Mahajan authored and GitHub committed 2026-07-27 17:16:05 +05:30
commit 31b2201b2d
11 files changed
+470 -99

No files matched your search

+3 -1
View File
@@ -6,7 +6,9 @@ foreach ($vars as $key => $value) {
if ($value === null || $value === '') {
echo $key . "=\n";
} else {
echo $key . '="' . addcslashes((string) $value, '"\\$`') . '"' . "\n";
// Escape newlines and special chars so multiline secrets (e.g. GitHub App
// private keys) survive install/upgrade rewrites as a single .env line.
echo $key . '="' . \Appwrite\Docker\Env::encodeValue((string) $value) . '"' . "\n";
}
}
?>
Generated
+55 -60
View File
@@ -3167,7 +3167,7 @@
},
{
"name": "utopia-php/audit",
"version": "2.9.0",
"version": "2.9.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/audit.git",
@@ -3206,7 +3206,7 @@
],
"support": {
"issues": "https://github.com/utopia-php/audit/issues",
"source": "https://github.com/utopia-php/audit/tree/2.9.0"
"source": "https://github.com/utopia-php/audit/tree/2.9.1"
},
"time": "2026-07-15T10:27:51+00:00"
},
@@ -3635,16 +3635,16 @@
},
{
"name": "utopia-php/database",
"version": "6.4.4",
"version": "6.5.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "a1796fd360d58abcc3bb3e1b615fcebc04ba9100"
"reference": "7fd133e99698feb300a689be8767efa975c2cf13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/a1796fd360d58abcc3bb3e1b615fcebc04ba9100",
"reference": "a1796fd360d58abcc3bb3e1b615fcebc04ba9100",
"url": "https://api.github.com/repos/utopia-php/database/zipball/7fd133e99698feb300a689be8767efa975c2cf13",
"reference": "7fd133e99698feb300a689be8767efa975c2cf13",
"shasum": ""
},
"require": {
@@ -3689,9 +3689,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/6.4.4"
"source": "https://github.com/utopia-php/database/tree/6.5.1"
},
"time": "2026-07-17T08:21:36+00:00"
"time": "2026-07-27T09:40:21+00:00"
},
{
"name": "utopia-php/detector",
@@ -4055,16 +4055,16 @@
},
{
"name": "utopia-php/http",
"version": "2.0.0-rc18",
"version": "2.0.0-rc19",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/http.git",
"reference": "3bfc500c6a53ffb87d4dcb95b4712b6a91b24439"
"reference": "7a9419858c6c612a8d783024ad46740f857e4430"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/http/zipball/3bfc500c6a53ffb87d4dcb95b4712b6a91b24439",
"reference": "3bfc500c6a53ffb87d4dcb95b4712b6a91b24439",
"url": "https://api.github.com/repos/utopia-php/http/zipball/7a9419858c6c612a8d783024ad46740f857e4430",
"reference": "7a9419858c6c612a8d783024ad46740f857e4430",
"shasum": ""
},
"require": {
@@ -4102,22 +4102,22 @@
],
"support": {
"issues": "https://github.com/utopia-php/http/issues",
"source": "https://github.com/utopia-php/http/tree/2.0.0-rc18"
"source": "https://github.com/utopia-php/http/tree/2.0.0-rc19"
},
"time": "2026-07-13T16:18:22+00:00"
"time": "2026-07-27T07:23:46+00:00"
},
{
"name": "utopia-php/image",
"version": "0.8.7",
"version": "0.8.9",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/image.git",
"reference": "ed06c72998869f5d66026c7e4b7e1bcc1bbf45c7"
"reference": "6647714267e43bae25c8e8ae7021264eca4a1e84"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/image/zipball/ed06c72998869f5d66026c7e4b7e1bcc1bbf45c7",
"reference": "ed06c72998869f5d66026c7e4b7e1bcc1bbf45c7",
"url": "https://api.github.com/repos/utopia-php/image/zipball/6647714267e43bae25c8e8ae7021264eca4a1e84",
"reference": "6647714267e43bae25c8e8ae7021264eca4a1e84",
"shasum": ""
},
"require": {
@@ -4125,11 +4125,6 @@
"ext-imagick": "*",
"php": ">=8.1"
},
"require-dev": {
"laravel/pint": "1.24.*",
"phpstan/phpstan": "2.1.*",
"phpunit/phpunit": "10.5.*"
},
"suggest": {
"ext-imagick": "Imagick extension is required for Imagick adapter"
},
@@ -4153,9 +4148,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/image/issues",
"source": "https://github.com/utopia-php/image/tree/0.8.7"
"source": "https://github.com/utopia-php/image/tree/0.8.9"
},
"time": "2026-07-13T12:12:06+00:00"
"time": "2026-07-20T18:04:09+00:00"
},
{
"name": "utopia-php/locale",
@@ -5421,31 +5416,31 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "2.4.13",
"version": "2.4.19",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "7ead3b6ff1746ae950cacca55bc9800708d5beff"
"reference": "d0e58c93a8d7021a69d2a5d6b30fa826a5404fb9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7ead3b6ff1746ae950cacca55bc9800708d5beff",
"reference": "7ead3b6ff1746ae950cacca55bc9800708d5beff",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d0e58c93a8d7021a69d2a5d6b30fa826a5404fb9",
"reference": "d0e58c93a8d7021a69d2a5d6b30fa826a5404fb9",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"matthiasmullie/minify": "1.3.*",
"matthiasmullie/minify": "^1.3",
"php": ">=8.5",
"twig/twig": "3.28.*"
"twig/twig": "^3.28"
},
"require-dev": {
"brianium/paratest": "7.*",
"phpunit/phpunit": "11.*",
"brianium/paratest": "^7",
"phpunit/phpunit": "^11",
"rector/rector": "^2.4",
"squizlabs/php_codesniffer": "4.*"
"squizlabs/php_codesniffer": "^4"
},
"type": "library",
"autoload": {
@@ -5467,9 +5462,9 @@
"description": "SDK generator for Appwrite APIs across multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/2.4.13"
"source": "https://github.com/appwrite/sdk-generator/tree/2.4.19"
},
"time": "2026-07-13T07:30:15+00:00"
"time": "2026-07-24T06:18:23+00:00"
},
{
"name": "brianium/paratest",
@@ -6177,11 +6172,11 @@
},
{
"name": "phpstan/phpstan",
"version": "2.2.5",
"version": "2.2.6",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/909c1e5fef7989ac0d0c1c5c42e32a5c4f6198a0",
"reference": "909c1e5fef7989ac0d0c1c5c42e32a5c4f6198a0",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a6e9b5a9420f6109c091e87d82683bd1a80b87ed",
"reference": "a6e9b5a9420f6109c091e87d82683bd1a80b87ed",
"shasum": ""
},
"require": {
@@ -6237,7 +6232,7 @@
"type": "github"
}
],
"time": "2026-07-05T06:31:06+00:00"
"time": "2026-07-26T21:22:49+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -6586,16 +6581,16 @@
},
{
"name": "phpunit/phpunit",
"version": "12.5.31",
"version": "12.5.32",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d"
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0608d157a284f15cc73b99a3327eff06b66a176d",
"reference": "0608d157a284f15cc73b99a3327eff06b66a176d",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c02591dd7840ed124a98d7770753329ad28e9f8f",
"reference": "c02591dd7840ed124a98d7770753329ad28e9f8f",
"shasum": ""
},
"require": {
@@ -6664,7 +6659,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.31"
"source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.32"
},
"funding": [
{
@@ -6672,25 +6667,25 @@
"type": "other"
}
],
"time": "2026-07-06T14:54:16+00:00"
"time": "2026-07-25T06:54:13+00:00"
},
{
"name": "rector/rector",
"version": "2.5.7",
"version": "2.5.8",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "ba22f8c087848278fed6b4910d4cf1108096d8d3"
"reference": "861c77fd2a6d45317a401f4e0b617f947e8b6f96"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/ba22f8c087848278fed6b4910d4cf1108096d8d3",
"reference": "ba22f8c087848278fed6b4910d4cf1108096d8d3",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/861c77fd2a6d45317a401f4e0b617f947e8b6f96",
"reference": "861c77fd2a6d45317a401f4e0b617f947e8b6f96",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0",
"phpstan/phpstan": "^2.2.2"
"phpstan/phpstan": "^2.2.6"
},
"conflict": {
"rector/rector-doctrine": "*",
@@ -6724,7 +6719,7 @@
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/2.5.7"
"source": "https://github.com/rectorphp/rector/tree/2.5.8"
},
"funding": [
{
@@ -6732,7 +6727,7 @@
"type": "github"
}
],
"time": "2026-07-13T15:24:18+00:00"
"time": "2026-07-27T06:19:16+00:00"
},
{
"name": "sebastian/cli-parser",
@@ -7697,16 +7692,16 @@
},
{
"name": "swoole/ide-helper",
"version": "6.0.2",
"version": "6.2.2",
"source": {
"type": "git",
"url": "https://github.com/swoole/ide-helper.git",
"reference": "6f12243dce071714c5febe059578d909698f9a52"
"reference": "ad91a281e135f498426fb2e5297376581a4e2dca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swoole/ide-helper/zipball/6f12243dce071714c5febe059578d909698f9a52",
"reference": "6f12243dce071714c5febe059578d909698f9a52",
"url": "https://api.github.com/repos/swoole/ide-helper/zipball/ad91a281e135f498426fb2e5297376581a4e2dca",
"reference": "ad91a281e135f498426fb2e5297376581a4e2dca",
"shasum": ""
},
"type": "library",
@@ -7723,9 +7718,9 @@
"description": "IDE help files for Swoole.",
"support": {
"issues": "https://github.com/swoole/ide-helper/issues",
"source": "https://github.com/swoole/ide-helper/tree/6.0.2"
"source": "https://github.com/swoole/ide-helper/tree/6.2.2"
},
"time": "2025-03-23T07:31:41+00:00"
"time": "2026-07-25T08:15:29+00:00"
},
{
"name": "symfony/console",
@@ -8438,5 +8433,5 @@
"platform-dev": {
"ext-fileinfo": "*"
},
"plugin-api-version": "2.9.0"
"plugin-api-version": "2.6.0"
}
+6 -6
View File
@@ -935,7 +935,7 @@ services:
- _APP_MIGRATION_HOST
appwrite-task-maintenance:
entrypoint: maintenance
restart: on-failure:3
restart: unless-stopped
logging:
driver: json-file
options:
@@ -982,7 +982,7 @@ services:
- _APP_DATABASE_SHARED_TABLES
appwrite-task-interval:
entrypoint: interval
restart: on-failure:3
restart: unless-stopped
logging:
driver: json-file
options:
@@ -1024,7 +1024,7 @@ services:
appwrite-task-scheduler-functions:
entrypoint: schedule-functions
restart: on-failure:3
restart: unless-stopped
logging:
driver: json-file
options:
@@ -1063,7 +1063,7 @@ services:
- _APP_DATABASE_SHARED_TABLES
appwrite-task-scheduler-executions:
entrypoint: schedule-executions
restart: on-failure:3
restart: unless-stopped
logging:
driver: json-file
options:
@@ -1102,7 +1102,7 @@ services:
- _APP_DATABASE_SHARED_TABLES
appwrite-task-scheduler-messages:
entrypoint: schedule-messages
restart: on-failure:3
restart: unless-stopped
logging:
driver: json-file
options:
@@ -1290,7 +1290,7 @@ services:
options:
max-file: "5"
max-size: 10m
restart: on-failure:3
restart: unless-stopped
networks:
- appwrite
volumes:
+181 -19
View File
@@ -5,31 +5,168 @@ namespace Appwrite\Docker;
class Env
{
/**
* @var array
* @var array<string, string|null>
*/
protected $vars = [];
public function __construct(string $data)
{
$data = explode("\n", $data);
$length = \strlen($data);
$offset = 0;
foreach ($data as &$row) {
$row = explode('=', $row, 2);
$key = trim($row[0]);
$value = (isset($row[1])) ? (function (string $v): string {
$v = trim($v);
if (
(\str_starts_with($v, '"') && \str_ends_with($v, '"')) ||
(\str_starts_with($v, "'") && \str_ends_with($v, "'"))
) {
return \substr($v, 1, -1);
}
return $v;
})(trim($row[1])) : null;
if ($key) {
$this->vars[$key] = $value;
while ($offset < $length) {
$lineEnd = \strpos($data, "\n", $offset);
if ($lineEnd === false) {
$lineEnd = $length;
}
$line = \substr($data, $offset, $lineEnd - $offset);
// Normalize Windows newlines for line-oriented parsing of keys.
if (\str_ends_with($line, "\r")) {
$line = \substr($line, 0, -1);
}
$trimmed = \ltrim($line, " \t");
// Skip blank lines and comments (including indented comments).
if ($trimmed === '' || $trimmed[0] === '#') {
$offset = $lineEnd < $length ? $lineEnd + 1 : $length;
continue;
}
$equals = \strpos($line, '=');
if ($equals === false) {
// Skip malformed lines without an assignment on this line.
$offset = $lineEnd < $length ? $lineEnd + 1 : $length;
continue;
}
$key = \trim(\substr($line, 0, $equals));
if ($key === '') {
$offset = $lineEnd < $length ? $lineEnd + 1 : $length;
continue;
}
// Value starts after '=' in the full buffer so quoted values may span lines.
$valueOffset = $offset + $equals + 1;
// Consume optional whitespace before the value.
while ($valueOffset < $length && ($data[$valueOffset] === ' ' || $data[$valueOffset] === "\t")) {
$valueOffset++;
}
if ($valueOffset >= $length || $data[$valueOffset] === "\n" || $data[$valueOffset] === "\r") {
$this->vars[$key] = '';
$offset = $valueOffset < $length ? (($data[$valueOffset] === "\r" && $valueOffset + 1 < $length && $data[$valueOffset + 1] === "\n") ? $valueOffset + 2 : $valueOffset + 1) : $length;
continue;
}
$quote = $data[$valueOffset];
if ($quote === '"' || $quote === "'") {
$contentStart = $valueOffset + 1;
$scanOffset = $contentStart;
$value = '';
$closed = false;
$crossedNewline = false;
while ($scanOffset < $length) {
$char = $data[$scanOffset];
if ($char === "\n" || $char === "\r") {
$crossedNewline = true;
}
if ($char === $quote) {
// A later line's opening quote (KEY=") must not close an
// earlier unterminated value, or upgrade will drop that key.
if ($crossedNewline && self::isAssignmentOpener($data, $scanOffset)) {
break;
}
$scanOffset++;
$closed = true;
break;
}
if ($quote === '"' && $char === '\\' && $scanOffset + 1 < $length) {
$next = $data[$scanOffset + 1];
$value .= match ($next) {
'n' => "\n",
'r' => "\r",
't' => "\t",
'\\' => '\\',
'"' => '"',
"'" => "'",
'$' => '$',
'`' => '`',
// Preserve unknown escapes as a literal backslash + next char
// (e.g. Windows paths or patterns like `\d`, `\q`).
default => '\\' . $next,
};
$scanOffset += 2;
continue;
}
$value .= $char;
$scanOffset++;
}
if (!$closed) {
// Unterminated quote: keep only the remainder of the starting line so
// later assignments are not absorbed into this value during upgrade.
$end = \strpos($data, "\n", $contentStart);
if ($end === false) {
$raw = \substr($data, $contentStart);
$offset = $length;
} else {
$raw = \substr($data, $contentStart, $end - $contentStart);
$offset = $end + 1;
}
if (\str_ends_with($raw, "\r")) {
$raw = \substr($raw, 0, -1);
}
$this->vars[$key] = $raw;
continue;
}
$valueOffset = $scanOffset;
// Consume trailing characters until end of line (comments/whitespace).
while ($valueOffset < $length && $data[$valueOffset] !== "\n" && $data[$valueOffset] !== "\r") {
$valueOffset++;
}
if ($valueOffset < $length) {
if ($data[$valueOffset] === "\r" && $valueOffset + 1 < $length && $data[$valueOffset + 1] === "\n") {
$valueOffset += 2;
} else {
$valueOffset++;
}
}
$this->vars[$key] = $value;
$offset = $valueOffset;
continue;
}
// Unquoted value: read until end of line, trim trailing whitespace.
$end = \strpos($data, "\n", $valueOffset);
if ($end === false) {
$raw = \substr($data, $valueOffset);
$offset = $length;
} else {
$raw = \substr($data, $valueOffset, $end - $valueOffset);
$offset = $end + 1;
}
if (\str_ends_with($raw, "\r")) {
$raw = \substr($raw, 0, -1);
}
// Strip inline comments preceded by whitespace.
if (\preg_match('/\s+#/', $raw, $matches, PREG_OFFSET_CAPTURE) === 1) {
$raw = \substr($raw, 0, $matches[0][1]);
}
$this->vars[$key] = \rtrim($raw, " \t");
}
}
@@ -66,6 +203,26 @@ class Env
return $this->vars;
}
/**
* Encode a value for a double-quoted .env assignment.
*/
public static function encodeValue(string $value): string
{
return \addcslashes($value, "\"\\\n\r\t\$`");
}
/**
* True when $quoteOffset points at a quote that opens a new KEY="..." assignment.
*/
private static function isAssignmentOpener(string $data, int $quoteOffset): bool
{
$lineStart = \strrpos(\substr($data, 0, $quoteOffset), "\n");
$lineStart = $lineStart === false ? 0 : $lineStart + 1;
$before = \substr($data, $lineStart, $quoteOffset - $lineStart);
return \preg_match('/^\s*[A-Za-z_][A-Za-z0-9_]*\s*=\s*$/', $before) === 1;
}
/**
* @return string
*/
@@ -74,7 +231,12 @@ class Env
$output = '';
foreach ($this->vars as $key => $value) {
$output .= $key . '=' . $value . "\n";
if ($value === null || $value === '') {
$output .= $key . "=\n";
continue;
}
$output .= $key . '="' . self::encodeValue((string) $value) . "\"\n";
}
return $output;
+2 -8
View File
@@ -426,14 +426,8 @@ class Install extends Action
}
}
foreach ($input as $key => $value) {
if (!is_string($value)) {
continue;
}
if (str_contains($value, "\n") || str_contains($value, "\r")) {
throw new \InvalidArgumentException('Invalid value for ' . $key);
}
}
// Multiline values (e.g. GitHub App PEM private keys) are allowed; env.phtml
// encodes them as escaped single-line double-quoted assignments.
// Set database-specific connection details
$database = $input['_APP_DB_ADAPTER'] ?? 'postgresql';
+16
View File
@@ -9,6 +9,17 @@ use Utopia\Psr7\Request\Factory;
class Client
{
public const VIEWPORT_WIDTH = 1280;
public const VIEWPORT_HEIGHT = 720;
/**
* Captured pixels per CSS pixel. Above 1 the page is rendered at a higher
* resolution than the viewport, so previews stay sharp when the console
* displays them on high-density screens or scales them up.
*/
public const SCALE = 1.5;
private Factory $factory;
/**
@@ -33,6 +44,11 @@ class Client
'theme' => $theme,
'headers' => $headers,
'sleep' => $sleep,
'viewport' => [
'width' => self::VIEWPORT_WIDTH,
'height' => self::VIEWPORT_HEIGHT,
],
'deviceScaleFactor' => self::SCALE,
]));
$status = $response->getStatusCode();
@@ -3732,6 +3732,76 @@ trait DatabasesBase
}
}
public function testGetDocumentCacheEmpty(): void
{
$databaseId = $this->setupDatabase()['databaseId'];
// Dedicated collection so the inserted document cannot change the
// document counts asserted by the shared movies-collection tests.
$collection = $this->client->call(Client::METHOD_POST, $this->getContainerUrl($databaseId), [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
$this->getContainerIdParam() => ID::unique(),
'name' => 'CacheEmpty',
$this->getSecurityParam() => true,
'permissions' => [
Permission::create(Role::user($this->getUser()['$id'])),
],
]);
$this->assertEquals(201, $collection['headers']['status-code']);
$containerId = $collection['body']['$id'];
if ($this->getSupportForAttributes()) {
$this->createAttribute($databaseId, $containerId, 'string', [
'key' => 'title',
'size' => 256,
'required' => false,
]);
$this->waitForAttribute($databaseId, $containerId, 'title');
}
$documentId = ID::unique();
// Read a document that does not exist yet -> negatively caches the miss.
$missing = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $containerId, $documentId), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(404, $missing['headers']['status-code']);
// Create that same id. This must purge the cached "not found".
$created = $this->client->call(Client::METHOD_POST, $this->getRecordUrl($databaseId, $containerId), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
$this->getRecordIdParam() => $documentId,
'data' => [
'title' => 'Cached Empty',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
],
]);
$this->assertEquals(201, $created['headers']['status-code']);
$this->assertEquals($documentId, $created['body']['$id']);
// The freshly created document must be visible right away. Without cache
// invalidation on create this would still return 404 from the marker.
$fetched = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $containerId, $documentId), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $fetched['headers']['status-code']);
$this->assertEquals($documentId, $fetched['body']['$id']);
$this->assertEquals('Cached Empty', $fetched['body']['title']);
}
public function testGetDocumentWithQueries(): void
{
$data = $this->getDocumentsList();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 25 KiB

+105 -5
View File
@@ -36,10 +36,110 @@ final class EnvTest extends TestCase
public function testExport(): void
{
$this->assertSame("_APP_X=value1
_APP_Y=value2
_APP_Z=value3
_APP_W=value5=
", $this->object->export());
$this->assertSame(
"_APP_X=\"value1\"\n_APP_Y=\"value2\"\n_APP_Z=\"value3\"\n_APP_W=\"value5=\"\n",
$this->object->export()
);
}
public function testMultilineDoubleQuotedPrivateKey(): void
{
$pem = "-----BEGIN RSA PRIVATE KEY-----\nABCDEF\n-----END RSA PRIVATE KEY-----";
$data = "_APP_VCS_GITHUB_PRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\nABCDEF\n-----END RSA PRIVATE KEY-----\"\n_APP_OTHER=ok\n";
$env = new Env($data);
$this->assertSame($pem, $env->getVar('_APP_VCS_GITHUB_PRIVATE_KEY'));
$this->assertSame('ok', $env->getVar('_APP_OTHER'));
}
public function testEscapedNewlineInDoubleQuotedValue(): void
{
$data = "_APP_VCS_GITHUB_PRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\\nABCDEF\\n-----END RSA PRIVATE KEY-----\"\n";
$env = new Env($data);
$this->assertSame(
"-----BEGIN RSA PRIVATE KEY-----\nABCDEF\n-----END RSA PRIVATE KEY-----",
$env->getVar('_APP_VCS_GITHUB_PRIVATE_KEY')
);
}
public function testRoundTripPreservesMultilineSecret(): void
{
$pem = "-----BEGIN RSA PRIVATE KEY-----\nLINE1\nLINE2\n-----END RSA PRIVATE KEY-----";
$env = new Env('');
$env->setVar('_APP_VCS_GITHUB_PRIVATE_KEY', $pem);
$env->setVar('_APP_DOMAIN', 'example.com');
$exported = $env->export();
$reloaded = new Env($exported);
$this->assertSame($pem, $reloaded->getVar('_APP_VCS_GITHUB_PRIVATE_KEY'));
$this->assertSame('example.com', $reloaded->getVar('_APP_DOMAIN'));
$this->assertStringNotContainsString("\nLINE1\n", $exported);
$this->assertStringContainsString('\\nLINE1\\n', $exported);
}
public function testEncodeValueEscapesSpecialCharacters(): void
{
$this->assertSame(
'say\\"hi\\nnext\\$path',
Env::encodeValue("say\"hi\nnext\$path")
);
}
public function testUnknownEscapesPreserveBackslash(): void
{
// .env contains unknown escapes \q and \d; both must keep the backslash.
$data = "_APP_PATTERN=\"prefix\\q and \\d digits\"\n";
$env = new Env($data);
$this->assertSame('prefix\\q and \\d digits', $env->getVar('_APP_PATTERN'));
}
public function testIndentedCommentDoesNotCaptureNextAssignment(): void
{
$data = " # indented note\n_APP_DOMAIN=example.com\n \n_APP_OPTIONS_FORCE_HTTPS=enabled\n";
$env = new Env($data);
$this->assertSame('example.com', $env->getVar('_APP_DOMAIN'));
$this->assertSame('enabled', $env->getVar('_APP_OPTIONS_FORCE_HTTPS'));
$this->assertArrayNotHasKey(' # indented note', $env->list());
$this->assertArrayNotHasKey('# indented note', $env->list());
}
public function testLineWithoutAssignmentIsSkipped(): void
{
$data = "NOT_AN_ASSIGNMENT\n_APP_DOMAIN=example.com\n";
$env = new Env($data);
$this->assertSame('example.com', $env->getVar('_APP_DOMAIN'));
$this->assertCount(1, $env->list());
}
public function testUnterminatedQuoteDoesNotAbsorbLaterAssignments(): void
{
$data = "_APP_BROKEN=\"partial-value\n_APP_DOMAIN=example.com\n_APP_OPTIONS_FORCE_HTTPS=enabled\n";
$env = new Env($data);
$this->assertSame('partial-value', $env->getVar('_APP_BROKEN'));
$this->assertSame('example.com', $env->getVar('_APP_DOMAIN'));
$this->assertSame('enabled', $env->getVar('_APP_OPTIONS_FORCE_HTTPS'));
}
public function testUnterminatedQuoteDoesNotAbsorbLaterQuotedAssignment(): void
{
$data = "_APP_BROKEN=\"partial-value\n_APP_DOMAIN=\"example.com\"\n_APP_OPTIONS_FORCE_HTTPS=enabled\n";
$env = new Env($data);
$this->assertSame('partial-value', $env->getVar('_APP_BROKEN'));
$this->assertSame('example.com', $env->getVar('_APP_DOMAIN'));
$this->assertSame('enabled', $env->getVar('_APP_OPTIONS_FORCE_HTTPS'));
}
}
+32
View File
@@ -58,9 +58,41 @@ final class ClientTest extends TestCase
'theme' => 'dark',
'headers' => ['x-appwrite-hostname' => 'example.com'],
'sleep' => 500,
'viewport' => ['width' => 1280, 'height' => 720],
'deviceScaleFactor' => 1.5,
], \json_decode((string)$this->request->getBody(), true));
}
public function testCreateCapturesAboveViewportResolution(): void
{
$response = (new Response(200, body: new Stream('png-bytes')))
->withHeader('Content-Type', 'image/png');
$this->client($response)->create('http://appwrite/', 'light');
$body = \json_decode((string)$this->request->getBody(), true);
// Left unset, the browser service defaults to a scale factor of 1, which
// captures exactly one pixel per CSS pixel and renders soft previews.
$this->assertGreaterThan(1, $body['deviceScaleFactor']);
$this->assertSame(1280, $body['viewport']['width']);
$this->assertSame(720, $body['viewport']['height']);
}
public function testCreateDoesNotBlockOnSubresources(): void
{
$response = (new Response(200, body: new Stream('png-bytes')))
->withHeader('Content-Type', 'image/png');
$this->client($response)->create('http://appwrite/', 'light');
// The browser service navigates with `domcontentloaded` unless told
// otherwise. Waiting for `load` risks exhausting the request timeout on
// sites with slow or hanging subresources, which yields no screenshot at
// all rather than an early one.
$this->assertArrayNotHasKey('waitUntil', \json_decode((string)$this->request->getBody(), true));
}
public function testCreateError(): void
{
$response = (new Response(400, body: new Stream('{"error":"Timeout exceeded"}')))