From 8620cf1921c092169592fd40d8c7d963d3499210 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 14 May 2026 20:28:23 +0100 Subject: [PATCH 1/5] Add webhook migration support MigrationReport now exposes webhook count. Composer pins point at the add-webhook-migration dev branches. --- composer.json | 2 +- composer.lock | 28 +++++++++---------- .../Utopia/Response/Model/MigrationReport.php | 6 ++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 67b0dfcf59..1b4c901ebd 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "0.22.*", - "utopia-php/migration": "dev-add-project-variable-migration as 1.12.0", + "utopia-php/migration": "dev-add-webhook-migration as 1.12.0", "utopia-php/platform": "^1.0@RC", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index 9b6291a94d..f913336194 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": "5bf93473859f86fbf9438b17cb660331", + "content-hash": "dbbf6239c2d7c6ddccd86d1c54f74ab4", "packages": [ { "name": "adhocore/jwt", @@ -69,16 +69,16 @@ }, { "name": "appwrite/appwrite", - "version": "23.1.0", + "version": "23.1.1", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "2f275921f10ceb7cff99f2d463f7328b296234fa" + "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/2f275921f10ceb7cff99f2d463f7328b296234fa", - "reference": "2f275921f10ceb7cff99f2d463f7328b296234fa", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", + "reference": "fd7c0f0bf5ddf334533534b20ed967cfb400f6ea", "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.0", + "source": "https://github.com/appwrite/sdk-for-php/tree/23.1.1", "url": "https://appwrite.io/support" }, - "time": "2026-05-08T13:44:58+00:00" + "time": "2026-05-12T11:03:36+00:00" }, { "name": "appwrite/php-clamav", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-project-variable-migration", + "version": "dev-add-webhook-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "3376bed6f797a8d48f0107e9a0d8e40745d6914b" + "reference": "7fca4226ae33a60ec334d0dbdc1353c2464c4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/3376bed6f797a8d48f0107e9a0d8e40745d6914b", - "reference": "3376bed6f797a8d48f0107e9a0d8e40745d6914b", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/7fca4226ae33a60ec334d0dbdc1353c2464c4306", + "reference": "7fca4226ae33a60ec334d0dbdc1353c2464c4306", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-project-variable-migration", + "source": "https://github.com/utopia-php/migration/tree/add-webhook-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-14T19:00:51+00:00" + "time": "2026-05-14T19:27:19+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-project-variable-migration", + "version": "dev-add-webhook-migration", "alias": "1.12.0", "alias_normalized": "1.12.0.0" } diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 9de39d75bf..f767a28d9a 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -71,6 +71,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 5, ]) + ->addRule(Resource::TYPE_WEBHOOK, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of webhooks to be migrated.', + 'default' => 0, + 'example' => 5, + ]) ->addRule(Resource::TYPE_SITE, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of sites to be migrated.', From aa44221e56c06cf5d87906bf292e2cc6be699642 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Fri, 15 May 2026 07:25:30 +0100 Subject: [PATCH 2/5] Add E2E test for webhook migration Asserts events/auth round-trip, and that authPassword + signatureKey are not copied from source (sensitive fields regenerated on destination). --- .../Services/Migrations/MigrationsBase.php | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 1d3c93d704..aa7b138190 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2616,6 +2616,87 @@ trait MigrationsBase $this->client->call(Client::METHOD_DELETE, '/project/keys/' . $apiKey['$id'], $sourceHeaders); } + public function testAppwriteMigrationWebhook(): void + { + $sourceHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]; + + $destinationHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getDestinationProject()['$id'], + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]; + + // Unique name so re-runs and parallel suites can't match the wrong webhook + // on the destination list. + $webhookName = 'Test Webhook ' . ID::unique(); + + $createResp = $this->client->call(Client::METHOD_POST, '/webhooks', $sourceHeaders, [ + 'webhookId' => ID::unique(), + 'url' => 'https://example.test/hook', + 'name' => $webhookName, + 'events' => ['users.*.create', 'users.*.delete'], + 'enabled' => true, + 'tls' => true, + 'authUsername' => 'hook-user', + 'authPassword' => 'hook-pass', + ]); + $this->assertEquals(201, $createResp['headers']['status-code']); + $sourceWebhook = $createResp['body']; + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_WEBHOOK, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $this->getProject()['$id'], + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_WEBHOOK], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_WEBHOOK, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_WEBHOOK]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_WEBHOOK]['pending']); + $this->assertGreaterThanOrEqual(1, $result['statusCounters'][Resource::TYPE_WEBHOOK]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_WEBHOOK]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_WEBHOOK]['warning']); + + $listResp = $this->client->call(Client::METHOD_GET, '/webhooks', $destinationHeaders); + $this->assertEquals(200, $listResp['headers']['status-code']); + + $foundWebhook = null; + foreach ($listResp['body']['webhooks'] as $w) { + if ($w['name'] === $webhookName) { + $foundWebhook = $w; + break; + } + } + + $this->assertNotNull($foundWebhook, 'Migrated webhook not found on destination'); + $this->assertEquals($webhookName, $foundWebhook['name']); + $this->assertEquals('https://example.test/hook', $foundWebhook['url']); + $this->assertEqualsCanonicalizing(['users.*.create', 'users.*.delete'], $foundWebhook['events']); + $this->assertTrue($foundWebhook['enabled']); + $this->assertTrue($foundWebhook['security']); + $this->assertEquals('hook-user', $foundWebhook['httpUser']); + // authPassword is sensitive; destination must not blindly copy the source value. + $this->assertNotEquals('hook-pass', $foundWebhook['httpPass'] ?? ''); + // signatureKey is regenerated on the destination — must not equal the source key. + if (!empty($sourceWebhook['signatureKey'])) { + $this->assertNotEquals($sourceWebhook['signatureKey'], $foundWebhook['signatureKey'] ?? ''); + } + + // Cleanup on destination + $this->client->call(Client::METHOD_DELETE, '/webhooks/' . $foundWebhook['$id'], $destinationHeaders); + + // Cleanup on source + $this->client->call(Client::METHOD_DELETE, '/webhooks/' . $sourceWebhook['$id'], $sourceHeaders); + } + /** * Import documents from a CSV file. */ From fdc1a18c7e4ab2dbf63b321d39bb5e5fe0022518 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 10:39:42 +0100 Subject: [PATCH 3/5] Fix migration smoke test and webhook URL for CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ProjectCustom now provisions both api-key and webhook on every project, so testCreateAppwriteMigration must assert both keys in statusCounters. testAppwriteMigrationWebhook fails the URL param's PublicDomain validator with example.test — switched to appwrite.io to match other webhook tests. --- .../Services/Migrations/MigrationsBase.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index f61eb5ffd1..b58f3590bc 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -225,10 +225,18 @@ trait MigrationsBase $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; - $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); - $this->assertEquals(0, $counts['error']); - $this->assertGreaterThan(0, $counts['success']); + // ProjectCustom provisions an api-key and a webhook on each project, so both show up + // here. Other resources stay empty and getStatusCounters strips them. + $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); + $this->assertArrayHasKey(Resource::TYPE_WEBHOOK, $response['statusCounters']); + + $apiKeyCounts = $response['statusCounters'][Resource::TYPE_API_KEY]; + $this->assertEquals(0, $apiKeyCounts['error']); + $this->assertGreaterThan(0, $apiKeyCounts['success']); + + $webhookCounts = $response['statusCounters'][Resource::TYPE_WEBHOOK]; + $this->assertEquals(0, $webhookCounts['error']); + $this->assertGreaterThan(0, $webhookCounts['success']); } /** @@ -2647,7 +2655,7 @@ trait MigrationsBase $createResp = $this->client->call(Client::METHOD_POST, '/webhooks', $sourceHeaders, [ 'webhookId' => ID::unique(), - 'url' => 'https://example.test/hook', + 'url' => 'https://appwrite.io/hook', 'name' => $webhookName, 'events' => ['users.*.create', 'users.*.delete'], 'enabled' => true, @@ -2689,7 +2697,7 @@ trait MigrationsBase $this->assertNotNull($foundWebhook, 'Migrated webhook not found on destination'); $this->assertEquals($webhookName, $foundWebhook['name']); - $this->assertEquals('https://example.test/hook', $foundWebhook['url']); + $this->assertEquals('https://appwrite.io/hook', $foundWebhook['url']); $this->assertEqualsCanonicalizing(['users.*.create', 'users.*.delete'], $foundWebhook['events']); $this->assertTrue($foundWebhook['enabled']); $this->assertTrue($foundWebhook['security']); From 2208b267e6ce2b6eee7379dd091fbfec57344568 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 11:30:24 +0100 Subject: [PATCH 4/5] Fix webhook test field names and relax smoke webhook success assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Webhook response model exposes tls/authUsername/authPassword/secret, not the internal security/httpUser/httpPass/signatureKey — test was reading null on the internal names. authPassword is preserved through migration (only secret is regenerated, since the SDK strips it from list responses). Smoke test: webhook from ProjectCustom collides by name with the destination's own ProjectCustom webhook, so it skips rather than succeeds. Drop the success>0 assertion — error==0 is what we actually care about. --- .../e2e/Services/Migrations/MigrationsBase.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index b58f3590bc..7745609865 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -227,6 +227,8 @@ trait MigrationsBase // ProjectCustom provisions an api-key and a webhook on each project, so both show up // here. Other resources stay empty and getStatusCounters strips them. + // Webhook is name-deduped on the destination — source ProjectCustom's 'Webhook Test' + // collides with destination ProjectCustom's, so it lands in 'skip', not 'success'. $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); $this->assertArrayHasKey(Resource::TYPE_WEBHOOK, $response['statusCounters']); @@ -236,7 +238,6 @@ trait MigrationsBase $webhookCounts = $response['statusCounters'][Resource::TYPE_WEBHOOK]; $this->assertEquals(0, $webhookCounts['error']); - $this->assertGreaterThan(0, $webhookCounts['success']); } /** @@ -2700,13 +2701,13 @@ trait MigrationsBase $this->assertEquals('https://appwrite.io/hook', $foundWebhook['url']); $this->assertEqualsCanonicalizing(['users.*.create', 'users.*.delete'], $foundWebhook['events']); $this->assertTrue($foundWebhook['enabled']); - $this->assertTrue($foundWebhook['security']); - $this->assertEquals('hook-user', $foundWebhook['httpUser']); - // authPassword is sensitive; destination must not blindly copy the source value. - $this->assertNotEquals('hook-pass', $foundWebhook['httpPass'] ?? ''); - // signatureKey is regenerated on the destination — must not equal the source key. - if (!empty($sourceWebhook['signatureKey'])) { - $this->assertNotEquals($sourceWebhook['signatureKey'], $foundWebhook['signatureKey'] ?? ''); + $this->assertTrue($foundWebhook['tls']); + $this->assertEquals('hook-user', $foundWebhook['authUsername']); + $this->assertEquals('hook-pass', $foundWebhook['authPassword']); + // secret is regenerated on the destination because the SDK strips it from list + // responses on read — same caveat as api keys. + if (!empty($sourceWebhook['secret'])) { + $this->assertNotEquals($sourceWebhook['secret'], $foundWebhook['secret'] ?? ''); } // Cleanup on destination From ac6c38c548dab00b246ec04685bdeb5e71d5f1d8 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 21:40:26 +0100 Subject: [PATCH 5/5] 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 fa00def43c..3ce6df3d3a 100644 --- a/composer.lock +++ b/composer.lock @@ -4661,12 +4661,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "ab731ca82d5b9c15c81b4b7b0f2cf8dda1afdcf4" + "reference": "a351e83121d0241737d99102e4d63e15c75da5b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/ab731ca82d5b9c15c81b4b7b0f2cf8dda1afdcf4", - "reference": "ab731ca82d5b9c15c81b4b7b0f2cf8dda1afdcf4", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/a351e83121d0241737d99102e4d63e15c75da5b0", + "reference": "a351e83121d0241737d99102e4d63e15c75da5b0", "shasum": "" }, "require": { @@ -4726,7 +4726,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-webhook-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-14T22:04:01+00:00" + "time": "2026-05-27T20:34:30+00:00" }, { "name": "utopia-php/mongo",