Add new tests

This commit is contained in:
Matej Bačo
2026-01-05 22:51:03 +01:00
parent 2fc5e56a61
commit b29f70a0af
4 changed files with 137 additions and 55 deletions
+2 -2
View File
@@ -45,7 +45,7 @@
"ext-sockets": "*",
"appwrite/php-runtimes": "0.19.*",
"appwrite/php-clamav": "2.0.*",
"utopia-php/abuse": "1.*",
"utopia-php/abuse": "1.*.*",
"utopia-php/analytics": "0.10.*",
"utopia-php/audit": "2.0.2-rc1",
"utopia-php/auth": "0.5.*",
@@ -64,7 +64,7 @@
"utopia-php/locale": "0.8.*",
"utopia-php/logger": "0.6.*",
"utopia-php/messaging": "0.20.*",
"utopia-php/migration": "1.3.*",
"utopia-php/migration": "dev-chore-update-sdk-19 as 1.4.0",
"utopia-php/orchestration": "0.9.*",
"utopia-php/platform": "0.7.*",
"utopia-php/pools": "0.8.*",
Generated
+53 -44
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b873febd2b03c32ec61a57b690cc44a2",
"content-hash": "4a6fc33b1b16a8e08276a28d7122a99a",
"packages": [
{
"name": "adhocore/jwt",
@@ -69,16 +69,16 @@
},
{
"name": "appwrite/appwrite",
"version": "15.1.0",
"version": "19.1.0",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-for-php.git",
"reference": "c438b3885071ac7c0329199dce5e6f6a24dd215b"
"reference": "8738e812062f899c85b2598eef43d6a247f08a56"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/c438b3885071ac7c0329199dce5e6f6a24dd215b",
"reference": "c438b3885071ac7c0329199dce5e6f6a24dd215b",
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/8738e812062f899c85b2598eef43d6a247f08a56",
"reference": "8738e812062f899c85b2598eef43d6a247f08a56",
"shasum": ""
},
"require": {
@@ -87,7 +87,7 @@
"php": ">=7.1.0"
},
"require-dev": {
"mockery/mockery": "^1.6.6",
"mockery/mockery": "^1.6.12",
"phpunit/phpunit": "^10"
},
"type": "library",
@@ -104,10 +104,10 @@
"support": {
"email": "team@appwrite.io",
"issues": "https://github.com/appwrite/sdk-for-php/issues",
"source": "https://github.com/appwrite/sdk-for-php/tree/15.1.0",
"source": "https://github.com/appwrite/sdk-for-php/tree/19.1.0",
"url": "https://appwrite.io/support"
},
"time": "2025-08-01T04:50:51+00:00"
"time": "2025-12-18T08:07:43+00:00"
},
{
"name": "appwrite/php-clamav",
@@ -3455,24 +3455,25 @@
},
{
"name": "utopia-php/abuse",
"version": "1.0.2",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/abuse.git",
"reference": "611fa66a97e87c0dbbc133a717d970da7a5ca828"
"reference": "3339d057c6bb1fa3e5ac5b2598923f6938425ec2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/611fa66a97e87c0dbbc133a717d970da7a5ca828",
"reference": "611fa66a97e87c0dbbc133a717d970da7a5ca828",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/3339d057c6bb1fa3e5ac5b2598923f6938425ec2",
"reference": "3339d057c6bb1fa3e5ac5b2598923f6938425ec2",
"shasum": ""
},
"require": {
"appwrite/appwrite": "19.*.*",
"ext-curl": "*",
"ext-pdo": "*",
"ext-redis": "*",
"php": ">=8.0",
"utopia-php/database": "*"
"utopia-php/database": "3.*.*"
},
"require-dev": {
"laravel/pint": "1.*",
@@ -3500,9 +3501,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/abuse/issues",
"source": "https://github.com/utopia-php/abuse/tree/1.0.2"
"source": "https://github.com/utopia-php/abuse/tree/1.2.0"
},
"time": "2025-10-20T07:18:33+00:00"
"time": "2026-01-05T21:29:10+00:00"
},
{
"name": "utopia-php/analytics",
@@ -4515,20 +4516,20 @@
},
{
"name": "utopia-php/migration",
"version": "1.3.9",
"version": "dev-chore-update-sdk-19",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/migration.git",
"reference": "c55ec67c74663190cda10fd79297422147be7e85"
"reference": "12b7439aae526539464a8e79b07ae4aee14a66bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/c55ec67c74663190cda10fd79297422147be7e85",
"reference": "c55ec67c74663190cda10fd79297422147be7e85",
"url": "https://api.github.com/repos/utopia-php/migration/zipball/12b7439aae526539464a8e79b07ae4aee14a66bc",
"reference": "12b7439aae526539464a8e79b07ae4aee14a66bc",
"shasum": ""
},
"require": {
"appwrite/appwrite": "15.*",
"appwrite/appwrite": "19.*",
"ext-curl": "*",
"ext-openssl": "*",
"php": ">=8.1",
@@ -4564,9 +4565,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/migration/issues",
"source": "https://github.com/utopia-php/migration/tree/1.3.9"
"source": "https://github.com/utopia-php/migration/tree/chore-update-sdk-19"
},
"time": "2025-12-08T08:45:09+00:00"
"time": "2026-01-05T21:31:41+00:00"
},
{
"name": "utopia-php/mongo",
@@ -5438,16 +5439,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "1.8.6",
"version": "1.8.9",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "b6cc29d3bd247e193f3c06b4168dc69d884645f0"
"reference": "5fc210f7403f9ecfa068cd2a74210ec6e2a3cec1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/b6cc29d3bd247e193f3c06b4168dc69d884645f0",
"reference": "b6cc29d3bd247e193f3c06b4168dc69d884645f0",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5fc210f7403f9ecfa068cd2a74210ec6e2a3cec1",
"reference": "5fc210f7403f9ecfa068cd2a74210ec6e2a3cec1",
"shasum": ""
},
"require": {
@@ -5483,9 +5484,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/1.8.6"
"source": "https://github.com/appwrite/sdk-generator/tree/1.8.9"
},
"time": "2025-12-31T10:22:17+00:00"
"time": "2026-01-02T12:09:51+00:00"
},
{
"name": "doctrine/annotations",
@@ -5713,16 +5714,16 @@
},
{
"name": "laravel/pint",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "69dcca060ecb15e4b564af63d1f642c81a241d6f"
"reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/69dcca060ecb15e4b564af63d1f642c81a241d6f",
"reference": "69dcca060ecb15e4b564af63d1f642c81a241d6f",
"url": "https://api.github.com/repos/laravel/pint/zipball/c67b4195b75491e4dfc6b00b1c78b68d86f54c90",
"reference": "c67b4195b75491e4dfc6b00b1c78b68d86f54c90",
"shasum": ""
},
"require": {
@@ -5733,9 +5734,9 @@
"php": "^8.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.90.0",
"illuminate/view": "^12.40.1",
"larastan/larastan": "^3.8.0",
"friendsofphp/php-cs-fixer": "^3.92.4",
"illuminate/view": "^12.44.0",
"larastan/larastan": "^3.8.1",
"laravel-zero/framework": "^12.0.4",
"mockery/mockery": "^1.6.12",
"nunomaduro/termwind": "^2.3.3",
@@ -5776,7 +5777,7 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2025-11-25T21:15:52+00:00"
"time": "2026-01-05T16:49:17+00:00"
},
{
"name": "matthiasmullie/minify",
@@ -8562,16 +8563,16 @@
},
{
"name": "symfony/process",
"version": "v8.0.0",
"version": "v8.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "a0a750500c4ce900d69ba4e9faf16f82c10ee149"
"reference": "0cbbd88ec836f8757641c651bb995335846abb78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/a0a750500c4ce900d69ba4e9faf16f82c10ee149",
"reference": "a0a750500c4ce900d69ba4e9faf16f82c10ee149",
"url": "https://api.github.com/repos/symfony/process/zipball/0cbbd88ec836f8757641c651bb995335846abb78",
"reference": "0cbbd88ec836f8757641c651bb995335846abb78",
"shasum": ""
},
"require": {
@@ -8603,7 +8604,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v8.0.0"
"source": "https://github.com/symfony/process/tree/v8.0.3"
},
"funding": [
{
@@ -8623,7 +8624,7 @@
"type": "tidelift"
}
],
"time": "2025-10-16T16:25:44+00:00"
"time": "2025-12-19T10:01:18+00:00"
},
{
"name": "symfony/string",
@@ -8943,10 +8944,18 @@
"time": "2024-03-07T20:33:40+00:00"
}
],
"aliases": [],
"aliases": [
{
"package": "utopia-php/migration",
"version": "dev-chore-update-sdk-19",
"alias": "1.4.0",
"alias_normalized": "1.4.0.0"
}
],
"minimum-stability": "stable",
"stability-flags": {
"utopia-php/audit": 5
"utopia-php/audit": 5,
"utopia-php/migration": 20
},
"prefer-stable": false,
"prefer-lowest": false,
@@ -363,4 +363,77 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals('191.0.113.195', $response['body']['clientIp'] ?? $response['body']['ip'] ?? '');
}
/**
* @group abuseEnabled
*/
public function testAccountAbuseReset(): void
{
$email = \uniqid() . '.abuse.reset.test@example.com';
$password = 'password';
$account = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => 'Abuse Reset Test',
]);
$this->assertEquals($account['headers']['status-code'], 201);
// 20 successful requests wont get blocked
for ($i = 0; $i < 20; $i++) {
$session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
]);
$this->assertEquals($session['headers']['status-code'], 201);
}
// 10 failures are OK
for ($i = 0; $i < 10; $i++) {
$session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => 'wrongPassword',
]);
$this->assertEquals($session['headers']['status-code'], 401);
}
// 11th request get limited
$session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => 'wrongPassword',
]);
$this->assertEquals($session['headers']['status-code'], 429);
// Even correct password is now blocked, correctness doesnt matter
$session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
]);
$this->assertEquals($session['headers']['status-code'], 429);
}
}
@@ -4783,7 +4783,7 @@ class ProjectsConsoleClientTest extends Scope
*/
/**
* @group devKeys
* @group abuseEnabled
*/
public function testCreateProjectDevKey(): void
{
@@ -4844,7 +4844,7 @@ class ProjectsConsoleClientTest extends Scope
/**
* @group devKeys
* @group abuseEnabled
*/
public function testListProjectDevKey(): void
{
@@ -4935,7 +4935,7 @@ class ProjectsConsoleClientTest extends Scope
/**
* @group devKeys
* @group abuseEnabled
*/
public function testGetProjectDevKey(): void
{
@@ -4979,7 +4979,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testGetDevKeyWithSdks(): void
{
@@ -5036,7 +5036,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testNoHostValidationWithDevKey(): void
{
@@ -5117,7 +5117,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testCorsWithDevKey(): void
{
@@ -5174,7 +5174,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testNoRateLimitWithDevKey(): void
{
@@ -5279,7 +5279,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testUpdateProjectDevKey(): void
{
@@ -5324,7 +5324,7 @@ class ProjectsConsoleClientTest extends Scope
}
/**
* @group devKeys
* @group abuseEnabled
*/
public function testDeleteProjectDevKey(): void
{