From f30ec4a7db1699a63559775f7a85f3bb962b4474 Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Wed, 20 May 2026 14:38:14 +0100 Subject: [PATCH 01/12] Pin utopia-php/migration to add-smtp-migration Picks up the new SMTP settings resource added in utopia-php/migration#add-smtp-migration. Also pins utopia-php/abuse to dev-feat-bump-sdk-24 to unblock the SDK 24.* transitive constraint from migration. --- composer.json | 8 +++-- composer.lock | 99 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 68 insertions(+), 39 deletions(-) diff --git a/composer.json b/composer.json index 3cbd2068ca..52e10691a9 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.20.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "1.3.*", + "utopia-php/abuse": "dev-feat-bump-sdk-24 as 1.3.0", "utopia-php/agents": "1.2.*", "utopia-php/analytics": "0.15.*", "utopia-php/audit": "2.3.*", @@ -74,7 +74,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "0.22.*", - "utopia-php/migration": "dev-add-policies-migration as 1.12.0", + "utopia-php/migration": "dev-add-smtp-migration as 1.12.0", "utopia-php/platform": "^1.0@RC", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", @@ -123,6 +123,10 @@ "name": "migration", "type": "vcs", "url": "https://github.com/utopia-php/migration" + }, + { + "type": "vcs", + "url": "https://github.com/utopia-php/abuse" } ] } diff --git a/composer.lock b/composer.lock index 73245b5250..f4499d82f3 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "162b26a841e7884be23ca819c80ccb6f", + "content-hash": "a3917ca08f868f641edb6818768b4353", "packages": [ { "name": "adhocore/jwt", @@ -69,16 +69,16 @@ }, { "name": "appwrite/appwrite", - "version": "23.1.1", + "version": "24.1.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea" + "reference": "dcb3550a3332de1c1665a015a09e9c73ff515e4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", - "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/dcb3550a3332de1c1665a015a09e9c73ff515e4f", + "reference": "dcb3550a3332de1c1665a015a09e9c73ff515e4f", "shasum": "" }, "require": { @@ -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/23.1.1", + "source": "https://github.com/appwrite/sdk-for-php/tree/24.1.0", "url": "https://appwrite.io/support" }, - "time": "2026-05-12T11:03:36+00:00" + "time": "2026-05-20T09:37:03+00:00" }, { "name": "appwrite/php-clamav", @@ -3359,20 +3359,20 @@ }, { "name": "utopia-php/abuse", - "version": "1.3.0", + "version": "dev-feat-bump-sdk-24", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "5d7efbe5c6b0cf7d06003114fd86e24ba785582f" + "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/5d7efbe5c6b0cf7d06003114fd86e24ba785582f", - "reference": "5d7efbe5c6b0cf7d06003114fd86e24ba785582f", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/5f1b5e2594636ac6c358b16c6dedd1ec6807f764", + "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764", "shasum": "" }, "require": { - "appwrite/appwrite": "23.*", + "appwrite/appwrite": "24.*", "ext-curl": "*", "ext-pdo": "*", "ext-redis": "*", @@ -3391,23 +3391,41 @@ "Utopia\\Abuse\\": "src/Abuse" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "Utopia\\Tests\\": "tests/Abuse" + } + }, + "scripts": { + "check": [ + "./vendor/bin/phpstan analyse --level max --memory-limit=2G src tests" + ], + "lint": [ + "./vendor/bin/pint --test" + ], + "format": [ + "./vendor/bin/pint" + ], + "bench": [ + "vendor/bin/phpbench run --report=aggregate" + ] + }, "license": [ "MIT" ], "description": "A simple abuse library to manage application usage limits", "keywords": [ - "Abuse", + "abuse", "framework", "php", "upf", "utopia" ], "support": { - "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/1.3.0" + "source": "https://github.com/utopia-php/abuse/tree/feat-bump-sdk-24", + "issues": "https://github.com/utopia-php/abuse/issues" }, - "time": "2026-05-11T08:07:02+00:00" + "time": "2026-05-20T10:54:49+00:00" }, { "name": "utopia-php/agents", @@ -4606,20 +4624,20 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-policies-migration", + "version": "dev-add-smtp-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "eab858e31f0f96c122333b17a441e9a46ff801fc" + "reference": "e5dc08619aae087c6d45768225ea8d1e55eff63e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/eab858e31f0f96c122333b17a441e9a46ff801fc", - "reference": "eab858e31f0f96c122333b17a441e9a46ff801fc", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/e5dc08619aae087c6d45768225ea8d1e55eff63e", + "reference": "e5dc08619aae087c6d45768225ea8d1e55eff63e", "shasum": "" }, "require": { - "appwrite/appwrite": "23.*", + "appwrite/appwrite": "24.*", "ext-curl": "*", "ext-openssl": "*", "halaxa/json-machine": "^1.2", @@ -4672,10 +4690,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", + "source": "https://github.com/utopia-php/migration/tree/add-smtp-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T15:37:59+00:00" + "time": "2026-05-20T13:27:52+00:00" }, { "name": "utopia-php/mongo", @@ -5159,16 +5177,16 @@ }, { "name": "utopia-php/storage", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "64e132a3768e22243eda36fe4262da22fd204f3c" + "reference": "37129cf0bfcc03210172000e4388d4d3495ae013" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/64e132a3768e22243eda36fe4262da22fd204f3c", - "reference": "64e132a3768e22243eda36fe4262da22fd204f3c", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/37129cf0bfcc03210172000e4388d4d3495ae013", + "reference": "37129cf0bfcc03210172000e4388d4d3495ae013", "shasum": "" }, "require": { @@ -5205,9 +5223,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/2.0.2" + "source": "https://github.com/utopia-php/storage/tree/2.0.3" }, - "time": "2026-05-01T15:06:16+00:00" + "time": "2026-05-15T09:42:32+00:00" }, { "name": "utopia-php/system", @@ -5322,16 +5340,16 @@ }, { "name": "utopia-php/validators", - "version": "0.2.2", + "version": "0.2.3", "source": { "type": "git", "url": "https://github.com/utopia-php/validators.git", - "reference": "5d7d494e64457cd4eb67fdcfd9481f2c89796aa6" + "reference": "9770269c8ed8e6909934965fa8722103c7434c23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/validators/zipball/5d7d494e64457cd4eb67fdcfd9481f2c89796aa6", - "reference": "5d7d494e64457cd4eb67fdcfd9481f2c89796aa6", + "url": "https://api.github.com/repos/utopia-php/validators/zipball/9770269c8ed8e6909934965fa8722103c7434c23", + "reference": "9770269c8ed8e6909934965fa8722103c7434c23", "shasum": "" }, "require": { @@ -5361,9 +5379,9 @@ ], "support": { "issues": "https://github.com/utopia-php/validators/issues", - "source": "https://github.com/utopia-php/validators/tree/0.2.2" + "source": "https://github.com/utopia-php/validators/tree/0.2.3" }, - "time": "2026-04-27T16:30:24+00:00" + "time": "2026-05-14T08:05:44+00:00" }, { "name": "utopia-php/vcs", @@ -8583,15 +8601,22 @@ } ], "aliases": [ + { + "package": "utopia-php/abuse", + "version": "dev-feat-bump-sdk-24", + "alias": "1.3.0", + "alias_normalized": "1.3.0.0" + }, { "package": "utopia-php/migration", - "version": "dev-add-policies-migration", + "version": "dev-add-smtp-migration", "alias": "1.12.0", "alias_normalized": "1.12.0.0" } ], "minimum-stability": "dev", "stability-flags": { + "utopia-php/abuse": 20, "utopia-php/http": 5, "utopia-php/migration": 20, "utopia-php/platform": 5 From 52318bcf4131c398e8740072679abed53e9d26d1 Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Thu, 21 May 2026 07:54:31 +0100 Subject: [PATCH 02/12] Add SMTP migration report rule + E2E test MigrationReport gets TYPE_SMTP entry alongside the other settings. testAppwriteMigrationSMTP configures source SMTP (9 fields + password), runs the migration, asserts every non-password field lands on the destination, then resets both projects. --- .../Utopia/Response/Model/MigrationReport.php | 6 ++ .../Services/Migrations/MigrationsBase.php | 76 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 16ceb8341a..ec8728ccf7 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -107,6 +107,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_SMTP, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of SMTP configurations to be migrated (always 0 or 1 — the project-level custom SMTP settings; password is not exposed by the source API).', + 'default' => 0, + 'example' => 1, + ]) ->addRule(Resource::TYPE_SITE, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of sites to be migrated.', diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 115d5e5b72..594eed25b3 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2968,6 +2968,82 @@ trait MigrationsBase $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $destinationProjectHeaders, ['userEmail' => true]); } + public function testAppwriteMigrationSMTP(): void + { + $consoleHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + $sourceProjectId = $this->getProject()['$id']; + + // Configure SMTP on the source so the round-trip is observable. + // Password is intentionally not migrated (source API never exposes it), + // so the destination receives every other field. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/smtp', $consoleHeaders, [ + 'enabled' => true, + 'senderName' => 'Migration Sender', + 'senderEmail' => 'sender@example.com', + 'replyToName' => 'Migration Reply', + 'replyToEmail' => 'reply@example.com', + 'host' => 'smtp.example.com', + 'port' => 587, + 'username' => 'smtp-user', + 'password' => 'smtp-pass', + 'secure' => 'tls', + ]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_SMTP, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_SMTP], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_SMTP, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_SMTP]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['warning']); + + $destinationProjectId = $this->getDestinationProject()['$id']; + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertTrue($response['body']['smtpEnabled'], 'smtpEnabled should be migrated as true'); + $this->assertSame('Migration Sender', $response['body']['smtpSenderName']); + $this->assertSame('sender@example.com', $response['body']['smtpSenderEmail']); + $this->assertSame('Migration Reply', $response['body']['smtpReplyToName']); + $this->assertSame('reply@example.com', $response['body']['smtpReplyToEmail']); + $this->assertSame('smtp.example.com', $response['body']['smtpHost']); + $this->assertSame(587, $response['body']['smtpPort']); + $this->assertSame('smtp-user', $response['body']['smtpUsername']); + $this->assertSame('tls', $response['body']['smtpSecure']); + + // Reset both projects so the test is idempotent. + $reset = [ + 'enabled' => false, + 'senderName' => '', + 'senderEmail' => '', + 'replyToName' => '', + 'replyToEmail' => '', + 'host' => '', + 'port' => 0, + 'username' => '', + 'password' => '', + 'secure' => '', + ]; + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/smtp', $consoleHeaders, $reset); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/smtp', $consoleHeaders, $reset); + } + /** * Import documents from a CSV file. */ From e33daecfc7bca219ff8339684775c781f65f688f Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Thu, 21 May 2026 08:39:44 +0100 Subject: [PATCH 03/12] Fix testCreateAppwriteMigration: statusCounters is populated after sync performMigrationSync waits for the migration to reach completed status before returning, so statusCounters is populated with success/error counts by the time the test asserts on it. Flip assertEmpty -> assertNotEmpty. --- tests/e2e/Services/Migrations/MigrationsBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 594eed25b3..72b15d99b0 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -224,7 +224,7 @@ trait MigrationsBase $this->assertEquals(Appwrite::getSupportedResources(), $response['resources']); $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - $this->assertEmpty($response['statusCounters']); + $this->assertNotEmpty($response['statusCounters']); } /** From 44aa17defb726834d15b63f79d5e23abf92d24a1 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 18:05:39 +0100 Subject: [PATCH 04/12] Fix SMTP migration test using wrong PATCH endpoint scope Test was PATCHing /projects/:id/smtp with x-appwrite-project: console header, so the request scoped to the console project, not to the source or destination project being mutated. Switched to project-scoped PATCH /project/smtp with x-appwrite-project=:projectId + admin mode, matching the pattern used by auth/protocols/services tests. Also switched the destination GET from /projects/:id to /project to keep all reads on the same scope the migration library SDK uses. --- .../Services/Migrations/MigrationsBase.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 053f7859fe..10c1cf507a 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3125,11 +3125,21 @@ trait MigrationsBase ]; $sourceProjectId = $this->getProject()['$id']; + $destinationProjectId = $this->getDestinationProject()['$id']; + + $sourceAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $sourceProjectId, + 'x-appwrite-mode' => 'admin', + ]); + $destinationAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $destinationProjectId, + 'x-appwrite-mode' => 'admin', + ]); // Configure SMTP on the source so the round-trip is observable. // Password is intentionally not migrated (source API never exposes it), // so the destination receives every other field. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/smtp', $consoleHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ 'enabled' => true, 'senderName' => 'Migration Sender', 'senderEmail' => 'sender@example.com', @@ -3160,8 +3170,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['warning']); - $destinationProjectId = $this->getDestinationProject()['$id']; - $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + $response = $this->client->call(Client::METHOD_GET, '/project', $destinationAdminHeaders); $this->assertEquals(200, $response['headers']['status-code']); $this->assertTrue($response['body']['smtpEnabled'], 'smtpEnabled should be migrated as true'); @@ -3187,8 +3196,8 @@ trait MigrationsBase 'password' => '', 'secure' => '', ]; - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/smtp', $consoleHeaders, $reset); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/smtp', $consoleHeaders, $reset); + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, $reset); + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationAdminHeaders, $reset); } /** From 7a3cc807d4f39c9951067f0ed89d5f6f05fcf086 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 18:24:49 +0100 Subject: [PATCH 05/12] Point SMTP test at maildev (validated by PATCH endpoint) The SMTP update endpoint validates the SMTP connection when enabled=true. Using fake smtp.example.com:587 makes that validation fail with PROJECT_SMTP_CONFIG_INVALID, the source never actually flips, and the destination keeps the 'Mailer' fallback set by ProjectCustom. Switched to the in-cluster maildev container (the same one ProjectCustom points at) so the PATCH passes validation and the round-trip is real. --- .../Services/Migrations/MigrationsBase.php | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 10c1cf507a..7ff7c6d5a1 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3137,19 +3137,22 @@ trait MigrationsBase ]); // Configure SMTP on the source so the round-trip is observable. + // The endpoint validates the SMTP connection when enabled=true, so we + // point at the in-cluster maildev container (same as ProjectCustom). // Password is intentionally not migrated (source API never exposes it), // so the destination receives every other field. + $smtpPort = \intval(\getenv('_APP_SMTP_PORT') ?: '1025'); $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ 'enabled' => true, 'senderName' => 'Migration Sender', - 'senderEmail' => 'sender@example.com', + 'senderEmail' => 'sender@appwrite.io', 'replyToName' => 'Migration Reply', - 'replyToEmail' => 'reply@example.com', - 'host' => 'smtp.example.com', - 'port' => 587, + 'replyToEmail' => 'reply@appwrite.io', + 'host' => 'maildev', + 'port' => $smtpPort, 'username' => 'smtp-user', 'password' => 'smtp-pass', - 'secure' => 'tls', + 'secure' => '', ]); $result = $this->performMigrationSync([ @@ -3175,13 +3178,13 @@ trait MigrationsBase $this->assertEquals(200, $response['headers']['status-code']); $this->assertTrue($response['body']['smtpEnabled'], 'smtpEnabled should be migrated as true'); $this->assertSame('Migration Sender', $response['body']['smtpSenderName']); - $this->assertSame('sender@example.com', $response['body']['smtpSenderEmail']); + $this->assertSame('sender@appwrite.io', $response['body']['smtpSenderEmail']); $this->assertSame('Migration Reply', $response['body']['smtpReplyToName']); - $this->assertSame('reply@example.com', $response['body']['smtpReplyToEmail']); - $this->assertSame('smtp.example.com', $response['body']['smtpHost']); - $this->assertSame(587, $response['body']['smtpPort']); + $this->assertSame('reply@appwrite.io', $response['body']['smtpReplyToEmail']); + $this->assertSame('maildev', $response['body']['smtpHost']); + $this->assertSame($smtpPort, $response['body']['smtpPort']); $this->assertSame('smtp-user', $response['body']['smtpUsername']); - $this->assertSame('tls', $response['body']['smtpSecure']); + $this->assertSame('', $response['body']['smtpSecure']); // Reset both projects so the test is idempotent. $reset = [ From 938831ecb0c91fb13e0ff9dbf3ae0bc44f1b19c3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 18:35:37 +0100 Subject: [PATCH 06/12] Assert source SMTP PATCH succeeds in SMTP migration test If PATCH fails (e.g. validation), the test reaches the destination assertion with stale 'Mailer' from ProjectCustom and the failure looks like a migration bug. Asserting the PATCH up-front makes the real failure point visible on CI. --- tests/e2e/Services/Migrations/MigrationsBase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 7ff7c6d5a1..6953d6e147 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3142,7 +3142,7 @@ trait MigrationsBase // Password is intentionally not migrated (source API never exposes it), // so the destination receives every other field. $smtpPort = \intval(\getenv('_APP_SMTP_PORT') ?: '1025'); - $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ + $sourceSmtpUpdate = $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ 'enabled' => true, 'senderName' => 'Migration Sender', 'senderEmail' => 'sender@appwrite.io', @@ -3154,6 +3154,8 @@ trait MigrationsBase 'password' => 'smtp-pass', 'secure' => '', ]); + $this->assertEquals(200, $sourceSmtpUpdate['headers']['status-code'], 'Source SMTP PATCH must succeed (otherwise migration sees empty config)'); + $this->assertSame('Migration Sender', $sourceSmtpUpdate['body']['smtpSenderName']); $result = $this->performMigrationSync([ 'resources' => [ From bc711ba20510ca55ab0a4438ae3082ce979afc35 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 18:48:40 +0100 Subject: [PATCH 07/12] Drop secure='' from SMTP test PATCH (rejected by WhiteList validator) Param 'secure' is Nullable(WhiteList(['tls','ssl'])). Passing '' fails validation -> 400 -> source SMTP stays empty -> migration sees nothing to migrate -> destination keeps ProjectCustom's 'Mailer' default. Omit secure entirely (Nullable defaults to 'leave unchanged'). Also simplified the reset block to just {enabled: false} since most clearing ops hit the same WhiteList/Hostname validator issues. --- .../Services/Migrations/MigrationsBase.php | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 6953d6e147..b3625f08fd 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3152,7 +3152,6 @@ trait MigrationsBase 'port' => $smtpPort, 'username' => 'smtp-user', 'password' => 'smtp-pass', - 'secure' => '', ]); $this->assertEquals(200, $sourceSmtpUpdate['headers']['status-code'], 'Source SMTP PATCH must succeed (otherwise migration sees empty config)'); $this->assertSame('Migration Sender', $sourceSmtpUpdate['body']['smtpSenderName']); @@ -3188,21 +3187,10 @@ trait MigrationsBase $this->assertSame('smtp-user', $response['body']['smtpUsername']); $this->assertSame('', $response['body']['smtpSecure']); - // Reset both projects so the test is idempotent. - $reset = [ - 'enabled' => false, - 'senderName' => '', - 'senderEmail' => '', - 'replyToName' => '', - 'replyToEmail' => '', - 'host' => '', - 'port' => 0, - 'username' => '', - 'password' => '', - 'secure' => '', - ]; - $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, $reset); - $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationAdminHeaders, $reset); + // Reset both projects so the test is idempotent. Disabling skips the + // connection-validation branch in the SMTP update endpoint. + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationAdminHeaders, ['enabled' => false]); } /** From 1c8a280aca8182564addd43e61dd06dee411c832 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 18:58:00 +0100 Subject: [PATCH 08/12] Simplify SMTP test: hardcode port 1025, trim comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match the convention in tests/e2e/Services/Project/SMTPBase.php — hardcoded maildev:1025, terse cleanup comment, drop the senderName re-assertion that duplicated the destination check. --- .../Services/Migrations/MigrationsBase.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index b3625f08fd..d139a5af8a 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3136,12 +3136,9 @@ trait MigrationsBase 'x-appwrite-mode' => 'admin', ]); - // Configure SMTP on the source so the round-trip is observable. - // The endpoint validates the SMTP connection when enabled=true, so we - // point at the in-cluster maildev container (same as ProjectCustom). - // Password is intentionally not migrated (source API never exposes it), - // so the destination receives every other field. - $smtpPort = \intval(\getenv('_APP_SMTP_PORT') ?: '1025'); + // Point at the in-cluster maildev container so the endpoint's SMTP + // connection validation passes. Password is not migrated — source + // API never exposes it. $sourceSmtpUpdate = $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ 'enabled' => true, 'senderName' => 'Migration Sender', @@ -3149,12 +3146,11 @@ trait MigrationsBase 'replyToName' => 'Migration Reply', 'replyToEmail' => 'reply@appwrite.io', 'host' => 'maildev', - 'port' => $smtpPort, + 'port' => 1025, 'username' => 'smtp-user', 'password' => 'smtp-pass', ]); - $this->assertEquals(200, $sourceSmtpUpdate['headers']['status-code'], 'Source SMTP PATCH must succeed (otherwise migration sees empty config)'); - $this->assertSame('Migration Sender', $sourceSmtpUpdate['body']['smtpSenderName']); + $this->assertEquals(200, $sourceSmtpUpdate['headers']['status-code']); $result = $this->performMigrationSync([ 'resources' => [ @@ -3183,12 +3179,11 @@ trait MigrationsBase $this->assertSame('Migration Reply', $response['body']['smtpReplyToName']); $this->assertSame('reply@appwrite.io', $response['body']['smtpReplyToEmail']); $this->assertSame('maildev', $response['body']['smtpHost']); - $this->assertSame($smtpPort, $response['body']['smtpPort']); + $this->assertSame(1025, $response['body']['smtpPort']); $this->assertSame('smtp-user', $response['body']['smtpUsername']); $this->assertSame('', $response['body']['smtpSecure']); - // Reset both projects so the test is idempotent. Disabling skips the - // connection-validation branch in the SMTP update endpoint. + // Reset both projects so the test is idempotent. $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, ['enabled' => false]); $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationAdminHeaders, ['enabled' => false]); } From 5de873242eb2eb595b7253e383e409e34bd08919 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 19:40:07 +0100 Subject: [PATCH 09/12] Drop username/password from SMTP test PATCH to skip maildev auth PHPMailer attempts SMTP AUTH when username is non-empty. maildev rejects the auth handshake -> connection validation in the SMTP update endpoint fails -> 400, source never mutates. Matches SMTPBase enable-tests which also omit credentials. Also added a post-PATCH GET on source as a sanity check so a regression that targets the wrong project shows up before the migration call. --- tests/e2e/Services/Migrations/MigrationsBase.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index d139a5af8a..2c82f8e3ee 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3147,11 +3147,14 @@ trait MigrationsBase 'replyToEmail' => 'reply@appwrite.io', 'host' => 'maildev', 'port' => 1025, - 'username' => 'smtp-user', - 'password' => 'smtp-pass', ]); $this->assertEquals(200, $sourceSmtpUpdate['headers']['status-code']); + // Cross-check the PATCH actually landed on the SOURCE project, not on + // a sibling scope. If this fails we've targeted the wrong project. + $sourceProjectAfter = $this->client->call(Client::METHOD_GET, '/project', $sourceAdminHeaders); + $this->assertSame('Migration Sender', $sourceProjectAfter['body']['smtpSenderName']); + $result = $this->performMigrationSync([ 'resources' => [ Resource::TYPE_SMTP, @@ -3180,7 +3183,6 @@ trait MigrationsBase $this->assertSame('reply@appwrite.io', $response['body']['smtpReplyToEmail']); $this->assertSame('maildev', $response['body']['smtpHost']); $this->assertSame(1025, $response['body']['smtpPort']); - $this->assertSame('smtp-user', $response['body']['smtpUsername']); $this->assertSame('', $response['body']['smtpSecure']); // Reset both projects so the test is idempotent. From 09036f30dda3470ec289e45d7a9096c161367d96 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 21:40:55 +0100 Subject: [PATCH 10/12] Bump migration pin to pull in GROUP_SETTINGS extractServices fix --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 9df8205d71..f514e557a0 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "e5fbe97d908fb5d50102fa8bc43d078fb9c2f72a" + "reference": "0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/e5fbe97d908fb5d50102fa8bc43d078fb9c2f72a", - "reference": "e5fbe97d908fb5d50102fa8bc43d078fb9c2f72a", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e", + "reference": "0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-smtp-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-21T13:29:03+00:00" + "time": "2026-05-27T20:36:15+00:00" }, { "name": "utopia-php/mongo", From 498014bd22805f7cc89104ffa042229e38ac868c Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 21:56:53 +0100 Subject: [PATCH 11/12] Fix composer.lock migration + appwrite/appwrite pins (stale from cascade merge) --- composer.lock | 75 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/composer.lock b/composer.lock index 537fb56ea3..f514e557a0 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "7bd4c82e7547f2983f272c86787b4619", + "content-hash": "8da71a00a7b70a997556f382ac81e42d", "packages": [ { "name": "adhocore/jwt", @@ -69,16 +69,16 @@ }, { "name": "appwrite/appwrite", - "version": "23.1.1", + "version": "24.2.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea" + "reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", - "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/d3217b6524b9d174ab91fb7ffc555c68bfa1da97", + "reference": "d3217b6524b9d174ab91fb7ffc555c68bfa1da97", "shasum": "" }, "require": { @@ -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/23.1.1", + "source": "https://github.com/appwrite/sdk-for-php/tree/24.2.0", "url": "https://appwrite.io/support" }, - "time": "2026-05-12T11:03:36+00:00" + "time": "2026-05-21T18:56:51+00:00" }, { "name": "appwrite/php-clamav", @@ -3359,20 +3359,20 @@ }, { "name": "utopia-php/abuse", - "version": "1.3.0", + "version": "dev-feat-bump-sdk-24", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "5d7efbe5c6b0cf7d06003114fd86e24ba785582f" + "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/5d7efbe5c6b0cf7d06003114fd86e24ba785582f", - "reference": "5d7efbe5c6b0cf7d06003114fd86e24ba785582f", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/5f1b5e2594636ac6c358b16c6dedd1ec6807f764", + "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764", "shasum": "" }, "require": { - "appwrite/appwrite": "23.*", + "appwrite/appwrite": "24.*", "ext-curl": "*", "ext-pdo": "*", "ext-redis": "*", @@ -3391,23 +3391,41 @@ "Utopia\\Abuse\\": "src/Abuse" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "Utopia\\Tests\\": "tests/Abuse" + } + }, + "scripts": { + "check": [ + "./vendor/bin/phpstan analyse --level max --memory-limit=2G src tests" + ], + "lint": [ + "./vendor/bin/pint --test" + ], + "format": [ + "./vendor/bin/pint" + ], + "bench": [ + "vendor/bin/phpbench run --report=aggregate" + ] + }, "license": [ "MIT" ], "description": "A simple abuse library to manage application usage limits", "keywords": [ - "Abuse", + "abuse", "framework", "php", "upf", "utopia" ], "support": { - "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/1.3.0" + "source": "https://github.com/utopia-php/abuse/tree/feat-bump-sdk-24", + "issues": "https://github.com/utopia-php/abuse/issues" }, - "time": "2026-05-11T08:07:02+00:00" + "time": "2026-05-20T10:54:49+00:00" }, { "name": "utopia-php/agents", @@ -4657,20 +4675,20 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-webhook-migration", + "version": "dev-add-smtp-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "a351e83121d0241737d99102e4d63e15c75da5b0" + "reference": "0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/a351e83121d0241737d99102e4d63e15c75da5b0", - "reference": "a351e83121d0241737d99102e4d63e15c75da5b0", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e", + "reference": "0d7e56a85cdc798e7e9c0b7ccafcbdf1c12c264e", "shasum": "" }, "require": { - "appwrite/appwrite": "23.*", + "appwrite/appwrite": "24.*", "ext-curl": "*", "ext-openssl": "*", "halaxa/json-machine": "^1.2", @@ -4723,10 +4741,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-webhook-migration", + "source": "https://github.com/utopia-php/migration/tree/add-smtp-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-27T20:34:30+00:00" + "time": "2026-05-27T20:36:15+00:00" }, { "name": "utopia-php/mongo", @@ -8567,15 +8585,22 @@ } ], "aliases": [ + { + "package": "utopia-php/abuse", + "version": "dev-feat-bump-sdk-24", + "alias": "1.3.0", + "alias_normalized": "1.3.0.0" + }, { "package": "utopia-php/migration", - "version": "dev-add-webhook-migration", + "version": "dev-add-smtp-migration", "alias": "1.12.0", "alias_normalized": "1.12.0.0" } ], "minimum-stability": "dev", "stability-flags": { + "utopia-php/abuse": 20, "utopia-php/migration": 20 }, "prefer-stable": true, From 14ddc7f177114f49eb792662432af947006f368f Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 28 May 2026 17:04:27 +0100 Subject: [PATCH 12/12] Use API key headers in SMTP migration test (drop admin-mode pattern) --- .../Services/Migrations/MigrationsBase.php | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 2c8e5b95d9..08b26574ef 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -3097,29 +3097,24 @@ trait MigrationsBase public function testAppwriteMigrationSMTP(): void { - $consoleHeaders = [ - 'content-type' => 'application/json', - 'x-appwrite-project' => 'console', - 'origin' => 'http://localhost', - 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - ]; - $sourceProjectId = $this->getProject()['$id']; $destinationProjectId = $this->getDestinationProject()['$id']; - $sourceAdminHeaders = \array_merge($consoleHeaders, [ + $sourceKeyHeaders = [ + 'content-type' => 'application/json', 'x-appwrite-project' => $sourceProjectId, - 'x-appwrite-mode' => 'admin', - ]); - $destinationAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]; + $destinationKeyHeaders = [ + 'content-type' => 'application/json', 'x-appwrite-project' => $destinationProjectId, - 'x-appwrite-mode' => 'admin', - ]); + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]; // Point at the in-cluster maildev container so the endpoint's SMTP // connection validation passes. Password is not migrated — source // API never exposes it. - $sourceSmtpUpdate = $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, [ + $sourceSmtpUpdate = $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceKeyHeaders, [ 'enabled' => true, 'senderName' => 'Migration Sender', 'senderEmail' => 'sender@appwrite.io', @@ -3132,7 +3127,7 @@ trait MigrationsBase // Cross-check the PATCH actually landed on the SOURCE project, not on // a sibling scope. If this fails we've targeted the wrong project. - $sourceProjectAfter = $this->client->call(Client::METHOD_GET, '/project', $sourceAdminHeaders); + $sourceProjectAfter = $this->client->call(Client::METHOD_GET, '/project', $sourceKeyHeaders); $this->assertSame('Migration Sender', $sourceProjectAfter['body']['smtpSenderName']); $result = $this->performMigrationSync([ @@ -3153,7 +3148,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SMTP]['warning']); - $response = $this->client->call(Client::METHOD_GET, '/project', $destinationAdminHeaders); + $response = $this->client->call(Client::METHOD_GET, '/project', $destinationKeyHeaders); $this->assertEquals(200, $response['headers']['status-code']); $this->assertTrue($response['body']['smtpEnabled'], 'smtpEnabled should be migrated as true'); @@ -3166,8 +3161,8 @@ trait MigrationsBase $this->assertSame('', $response['body']['smtpSecure']); // Reset both projects so the test is idempotent. - $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceAdminHeaders, ['enabled' => false]); - $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationAdminHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $sourceKeyHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/smtp', $destinationKeyHeaders, ['enabled' => false]); } /**