From e3716ab2b846d777ea75e87816993c9294ade78d Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Mon, 13 Dec 2021 14:09:23 +0100 Subject: [PATCH] Included prefs size exceeded test --- composer.json | 2 +- tests/e2e/Services/Account/AccountBase.php | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f534615f2..01ba42c71 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "appwrite/php-clamav": "1.1.*", "appwrite/php-runtimes": "0.6.*", - "utopia-php/framework": "0.19.*", + "utopia-php/framework": "0.19.1", "utopia-php/abuse": "0.6.*", "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.7.*", diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index fc615fef8..0e2b5f7ae 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -3,6 +3,7 @@ namespace Tests\E2E\Services\Account; use Tests\E2E\Client; +use function array_merge; trait AccountBase { @@ -751,6 +752,29 @@ trait AccountBase $this->assertEquals($response['headers']['status-code'], 400); + /** + * Prefs size exceeded + */ + + $prefsObject = []; + // Add 1000 keys + for($i = 1000; $i < 2000; $i++) { + $prefsObject["key" + $i] = "HelloWorld"; + // Each key is 7 characters and value is 10 characters + } + // That makes total size minimum of 17 000, plus any JSON stuff. Max supported is 16384, so this should exceed. + + $response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, + ]), [ + 'prefs' => $prefsObject + ]); + + $this->assertEquals($response['headers']['status-code'], 400); + return $data; }