From e42ea02ee118ab1bd60963db288da82ddb8d3458 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 18 May 2026 13:09:13 +0100 Subject: [PATCH 01/20] Add AuthMethods migration support - Bump utopia-php/migration to add-auth-methods-migration dev branch - Add MigrationReport rule for TYPE_AUTH_METHODS - E2E: testAppwriteMigrationAuthMethods flips email-password + JWT on source, runs migration, asserts both land as false on destination --- composer.json | 2 +- composer.lock | 16 +++--- .../Utopia/Response/Model/MigrationReport.php | 6 +++ .../Services/Migrations/MigrationsBase.php | 53 +++++++++++++++++++ 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 1b4c901ebd..65e44fa934 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-webhook-migration as 1.12.0", + "utopia-php/migration": "dev-add-auth-methods-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 f913336194..575864182d 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": "dbbf6239c2d7c6ddccd86d1c54f74ab4", + "content-hash": "9623d2109a32041ca4e395ab55266038", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-webhook-migration", + "version": "dev-add-auth-methods-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "7fca4226ae33a60ec334d0dbdc1353c2464c4306" + "reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/7fca4226ae33a60ec334d0dbdc1353c2464c4306", - "reference": "7fca4226ae33a60ec334d0dbdc1353c2464c4306", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/5224e3ce9a96373dfd83648b5e8e4e4d20b85020", + "reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-webhook-migration", + "source": "https://github.com/utopia-php/migration/tree/add-auth-methods-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-14T19:27:19+00:00" + "time": "2026-05-18T12:08:47+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-webhook-migration", + "version": "dev-add-auth-methods-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 f767a28d9a..3db8d6520d 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -77,6 +77,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 5, ]) + ->addRule(Resource::TYPE_AUTH_METHODS, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of auth-method configs to be migrated (always 0 or 1 — the project-level flag bundle).', + '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 aa7b138190..b629c3962c 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2697,6 +2697,59 @@ trait MigrationsBase $this->client->call(Client::METHOD_DELETE, '/webhooks/' . $sourceWebhook['$id'], $sourceHeaders); } + public function testAppwriteMigrationAuthMethods(): void + { + $consoleHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + // Flip a couple of auth methods on the source so the round-trip is + // observable. Settling on email-password OFF and JWT OFF — the + // remaining flags stay on their server defaults. + $sourceProjectId = $this->getProject()['$id']; + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/email-password', $consoleHeaders, [ + 'status' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/jwt', $consoleHeaders, [ + 'status' => false, + ]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_AUTH_METHODS, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_AUTH_METHODS], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_AUTH_METHODS, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['warning']); + + $destinationProjectId = $this->getDestinationProject()['$id']; + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertFalse($response['body']['authEmailPassword'], 'authEmailPassword should be migrated as false'); + $this->assertFalse($response['body']['authJWT'], 'authJWT should be migrated as false'); + + // Restore source so the test is idempotent. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/email-password', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]); + // Restore destination too. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/email-password', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]); + } + /** * Import documents from a CSV file. */ From 325999fc5b9d7ca3ecebf83115afed68eba90fc1 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 18 May 2026 14:16:04 +0100 Subject: [PATCH 02/20] Add Protocols migration support - Bump utopia-php/migration to add-protocols-migration dev branch - MigrationReport rule for TYPE_PROTOCOLS - E2E: testAppwriteMigrationProtocols flips graphql + websocket on source, runs migration, asserts both land disabled on destination --- composer.json | 2 +- composer.lock | 16 +++--- .../Utopia/Response/Model/MigrationReport.php | 6 +++ .../Services/Migrations/MigrationsBase.php | 50 +++++++++++++++++++ 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 65e44fa934..0250eb1974 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-auth-methods-migration as 1.12.0", + "utopia-php/migration": "dev-add-protocols-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 575864182d..656a3a61eb 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": "9623d2109a32041ca4e395ab55266038", + "content-hash": "13f0750846460bcf452f4c678ba570f8", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-auth-methods-migration", + "version": "dev-add-protocols-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020" + "reference": "d74e8cbd195f341810ec75adaf620447214fc110" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/5224e3ce9a96373dfd83648b5e8e4e4d20b85020", - "reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/d74e8cbd195f341810ec75adaf620447214fc110", + "reference": "d74e8cbd195f341810ec75adaf620447214fc110", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-auth-methods-migration", + "source": "https://github.com/utopia-php/migration/tree/add-protocols-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T12:08:47+00:00" + "time": "2026-05-18T13:09:23+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-auth-methods-migration", + "version": "dev-add-protocols-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 3db8d6520d..22acb9ca13 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -83,6 +83,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_PROTOCOLS, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of protocol configs to be migrated (always 0 or 1 — the project-level REST/GraphQL/WebSocket flags).', + '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 b629c3962c..c3ea8b11a7 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2750,6 +2750,56 @@ trait MigrationsBase $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]); } + public function testAppwriteMigrationProtocols(): void + { + $consoleHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + $sourceProjectId = $this->getProject()['$id']; + // Flip graphql + websocket off on source to make the round-trip observable. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, [ + 'status' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, [ + 'status' => false, + ]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_PROTOCOLS, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_PROTOCOLS], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_PROTOCOLS, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['warning']); + + $destinationProjectId = $this->getDestinationProject()['$id']; + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertFalse($response['body']['protocolStatusForGraphql'], 'GraphQL protocol should be migrated as disabled'); + $this->assertFalse($response['body']['protocolStatusForWebsocket'], 'WebSocket protocol should be migrated as disabled'); + + // Restore both projects so the test is idempotent. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/graphql', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/websocket', $consoleHeaders, ['status' => true]); + } + /** * Import documents from a CSV file. */ From 3e3227399f22539718ad6592b825cb18267d0147 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 18 May 2026 15:21:36 +0100 Subject: [PATCH 03/20] Add Labels migration support - Bump utopia-php/migration to add-labels-migration dev branch - MigrationReport rule for TYPE_LABELS - E2E: testAppwriteMigrationLabels sets unique labels on source via console patch, runs migration, asserts destination has matching set --- composer.json | 2 +- composer.lock | 16 +++--- .../Utopia/Response/Model/MigrationReport.php | 6 +++ .../Services/Migrations/MigrationsBase.php | 53 +++++++++++++++++++ 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 0250eb1974..ccba92ff9d 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-protocols-migration as 1.12.0", + "utopia-php/migration": "dev-add-labels-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 656a3a61eb..f52056dc9a 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": "13f0750846460bcf452f4c678ba570f8", + "content-hash": "e553f40900362e52e8cf7ab59f3628bc", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-protocols-migration", + "version": "dev-add-labels-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "d74e8cbd195f341810ec75adaf620447214fc110" + "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/d74e8cbd195f341810ec75adaf620447214fc110", - "reference": "d74e8cbd195f341810ec75adaf620447214fc110", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", + "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-protocols-migration", + "source": "https://github.com/utopia-php/migration/tree/add-labels-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T13:09:23+00:00" + "time": "2026-05-18T14:18:57+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-protocols-migration", + "version": "dev-add-labels-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 22acb9ca13..f2f5043776 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -89,6 +89,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_LABELS, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of label sets to be migrated (always 0 or 1 — the project-level RBAC label array).', + '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 c3ea8b11a7..af3a5ddb63 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2800,6 +2800,59 @@ trait MigrationsBase $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/websocket', $consoleHeaders, ['status' => true]); } + public function testAppwriteMigrationLabels(): 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']; + + $labels = ['vip-' . \substr(ID::unique(), 0, 8), 'beta-' . \substr(ID::unique(), 0, 8)]; + + // Set labels on source. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId, $consoleHeaders, [ + 'name' => $this->getProject()['name'] ?? 'Test', + 'labels' => $labels, + ]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_LABELS, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_LABELS], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_LABELS, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_LABELS]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['warning']); + + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEqualsCanonicalizing($labels, $response['body']['labels']); + + // Restore both projects. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId, $consoleHeaders, [ + 'name' => $this->getProject()['name'] ?? 'Test', + 'labels' => [], + ]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId, $consoleHeaders, [ + 'name' => $this->getDestinationProject()['name'] ?? 'Test', + 'labels' => [], + ]); + } + /** * Import documents from a CSV file. */ From 20bfc49e6f0d482bc2472c1da2dbac939910fb4c Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 18 May 2026 16:12:43 +0100 Subject: [PATCH 04/20] Add Services migration support - Bump utopia-php/migration to add-services-migration dev branch - MigrationReport rule for TYPE_SERVICES - E2E: testAppwriteMigrationServices disables functions + graphql on source, runs migration, asserts both land disabled on destination --- composer.json | 2 +- composer.lock | 16 +++---- .../Utopia/Response/Model/MigrationReport.php | 6 +++ .../Services/Migrations/MigrationsBase.php | 46 +++++++++++++++++++ 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index ccba92ff9d..9a13d112b3 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-labels-migration as 1.12.0", + "utopia-php/migration": "dev-add-services-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 f52056dc9a..e666b5ffc6 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": "e553f40900362e52e8cf7ab59f3628bc", + "content-hash": "55e6e4d5d59d83661dea4b04e913c986", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-labels-migration", + "version": "dev-add-services-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc" + "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", - "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/2f7270734300d4f5ac450a9bb3d0e11b32986a53", + "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-labels-migration", + "source": "https://github.com/utopia-php/migration/tree/add-services-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T14:18:57+00:00" + "time": "2026-05-18T15:10:10+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-labels-migration", + "version": "dev-add-services-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 f2f5043776..2096a73bda 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -95,6 +95,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_SERVICES, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of service configs to be migrated (always 0 or 1 — the project-level enable/disable flags for all 17 services).', + '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 af3a5ddb63..e061b65f7b 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2853,6 +2853,52 @@ trait MigrationsBase ]); } + public function testAppwriteMigrationServices(): 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']; + + // Disable functions + graphql on source as observable changes. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => false]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => false]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_SERVICES, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_SERVICES], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_SERVICES, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_SERVICES]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['warning']); + + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertFalse($response['body']['serviceStatusForFunctions'], 'Functions service should be migrated as disabled'); + $this->assertFalse($response['body']['serviceStatusForGraphql'], 'GraphQL service should be migrated as disabled'); + + // Restore both projects. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/functions', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); + } + /** * Import documents from a CSV file. */ From 9c7425e6faffbd87bb4a2753326bf375c0350d38 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 18 May 2026 16:51:03 +0100 Subject: [PATCH 05/20] Add Policies migration support - Bump utopia-php/migration to add-policies-migration dev branch - MigrationReport rule for TYPE_POLICIES - E2E: testAppwriteMigrationPolicies covers int (passwordHistory), bool (sessionAlert), and bundled MembershipPrivacy (userEmail) so all three field shapes are exercised end-to-end --- composer.json | 2 +- composer.lock | 16 ++--- .../Utopia/Response/Model/MigrationReport.php | 6 ++ .../Services/Migrations/MigrationsBase.php | 69 +++++++++++++++++++ 4 files changed, 84 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 9a13d112b3..3cbd2068ca 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-services-migration as 1.12.0", + "utopia-php/migration": "dev-add-policies-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 e666b5ffc6..73245b5250 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": "55e6e4d5d59d83661dea4b04e913c986", + "content-hash": "162b26a841e7884be23ca819c80ccb6f", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-services-migration", + "version": "dev-add-policies-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53" + "reference": "eab858e31f0f96c122333b17a441e9a46ff801fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/2f7270734300d4f5ac450a9bb3d0e11b32986a53", - "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/eab858e31f0f96c122333b17a441e9a46ff801fc", + "reference": "eab858e31f0f96c122333b17a441e9a46ff801fc", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-services-migration", + "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T15:10:10+00:00" + "time": "2026-05-18T15:37:59+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-services-migration", + "version": "dev-add-policies-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 2096a73bda..16ceb8341a 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -101,6 +101,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_POLICIES, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of policy bundles to be migrated (always 0 or 1 — the project-level security policies covering password rules, session behavior, user limits, and membership privacy).', + '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 e061b65f7b..115d5e5b72 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2899,6 +2899,75 @@ trait MigrationsBase $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); } + public function testAppwriteMigrationPolicies(): void + { + $sourceProjectId = $this->getProject()['$id']; + $destinationProjectId = $this->getDestinationProject()['$id']; + + // Policies have no /projects/:projectId admin route — they're only + // reachable via project-scoped /v1/project/policies/* with an API key. + $sourceProjectHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $sourceProjectId, + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]; + $destinationProjectHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $destinationProjectId, + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]; + + // Pick three policies that span the field types: int, bool, and + // bundled membership-privacy. + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceProjectHeaders, [ + 'total' => 5, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceProjectHeaders, [ + 'enabled' => true, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceProjectHeaders, [ + 'userEmail' => false, + ]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_POLICIES, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_POLICIES], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_POLICIES, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_POLICIES]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['warning']); + + $passwordHistory = $this->client->call(Client::METHOD_GET, '/project/policies/password-history', $destinationProjectHeaders); + $this->assertSame(200, $passwordHistory['headers']['status-code']); + $this->assertSame(5, $passwordHistory['body']['total'], 'passwordHistory should be migrated as 5'); + + $sessionAlert = $this->client->call(Client::METHOD_GET, '/project/policies/session-alert', $destinationProjectHeaders); + $this->assertSame(200, $sessionAlert['headers']['status-code']); + $this->assertTrue($sessionAlert['body']['enabled'], 'session-alert policy should be migrated as enabled'); + + $membershipPrivacy = $this->client->call(Client::METHOD_GET, '/project/policies/membership-privacy', $destinationProjectHeaders); + $this->assertSame(200, $membershipPrivacy['headers']['status-code']); + $this->assertFalse($membershipPrivacy['body']['userEmail'], 'membership-privacy userEmail should be migrated as false'); + + // Restore both projects to defaults. + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceProjectHeaders, ['total' => 0]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceProjectHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceProjectHeaders, ['userEmail' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $destinationProjectHeaders, ['total' => 0]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $destinationProjectHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $destinationProjectHeaders, ['userEmail' => true]); + } + /** * Import documents from a CSV file. */ From 4105f2fb38188caf4778d3c7e0957d9164581ad7 Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Thu, 21 May 2026 08:39:44 +0100 Subject: [PATCH 06/20] 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 115d5e5b72..f51a938c5e 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 041bbee5f45472052b47ce874e79554eb00831ae Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 21 May 2026 13:35:27 +0100 Subject: [PATCH 07/20] Use unique API key name in migration test + bump migration pin --- composer.lock | 8 ++++---- tests/e2e/Services/Migrations/MigrationsBase.php | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 8634289c82..8c803fa22c 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "16ff6ce143a7aff20bc8c86007264bce4c767ca2" + "reference": "91140887b9ff8efcefe326857115bd37c90db1cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/16ff6ce143a7aff20bc8c86007264bce4c767ca2", - "reference": "16ff6ce143a7aff20bc8c86007264bce4c767ca2", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/91140887b9ff8efcefe326857115bd37c90db1cf", + "reference": "91140887b9ff8efcefe326857115bd37c90db1cf", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-20T12:08:45+00:00" + "time": "2026-05-21T12:22:42+00:00" }, { "name": "utopia-php/mongo", diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index f51a938c5e..f0c8f2963e 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2554,10 +2554,14 @@ trait MigrationsBase 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], ]; + // Unique name so re-runs and parallel suites can't match a stale key + // left behind by a previous crashed run. + $keyName = 'Test API Key ' . ID::unique(); + // Create API key on source project $response = $this->client->call(Client::METHOD_POST, '/project/keys', $sourceHeaders, [ 'keyId' => ID::unique(), - 'name' => 'Test API Key', + 'name' => $keyName, 'scopes' => ['databases.read', 'databases.write'], 'expire' => null, ]); @@ -2596,7 +2600,7 @@ trait MigrationsBase $foundKey = null; foreach ($response['body']['keys'] as $k) { - if ($k['name'] === 'Test API Key') { + if ($k['name'] === $keyName) { $foundKey = $k; break; @@ -2604,7 +2608,7 @@ trait MigrationsBase } $this->assertNotNull($foundKey); - $this->assertEquals('Test API Key', $foundKey['name']); + $this->assertEquals($keyName, $foundKey['name']); $this->assertEqualsCanonicalizing(['databases.read', 'databases.write'], $foundKey['scopes']); $this->assertEmpty($foundKey['expire']); $this->assertNotEquals($apiKey['secret'], $foundKey['secret']); From d565015ac02863c7dbb9ef5b3cffe0acb9709f85 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 13:43:52 +0100 Subject: [PATCH 08/20] Drop api-key test churn from policies branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'Test API Key ' . ID::unique() change in 041bbee5f4 was a defensive hygiene tweak for stale-key flakes that the api-key test never actually hit. Reverting it here so policies→webhook PR diff stays scoped to policies-only changes. --- tests/e2e/Services/Migrations/MigrationsBase.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 3be799f0fc..5d09841633 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2567,14 +2567,10 @@ trait MigrationsBase 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], ]; - // Unique name so re-runs and parallel suites can't match a stale key - // left behind by a previous crashed run. - $keyName = 'Test API Key ' . ID::unique(); - // Create API key on source project $response = $this->client->call(Client::METHOD_POST, '/project/keys', $sourceHeaders, [ 'keyId' => ID::unique(), - 'name' => $keyName, + 'name' => 'Test API Key', 'scopes' => ['databases.read', 'databases.write'], 'expire' => null, ]); @@ -2613,7 +2609,7 @@ trait MigrationsBase $foundKey = null; foreach ($response['body']['keys'] as $k) { - if ($k['name'] === $keyName) { + if ($k['name'] === 'Test API Key') { $foundKey = $k; break; @@ -2621,7 +2617,7 @@ trait MigrationsBase } $this->assertNotNull($foundKey); - $this->assertEquals($keyName, $foundKey['name']); + $this->assertEquals('Test API Key', $foundKey['name']); $this->assertEqualsCanonicalizing(['databases.read', 'databases.write'], $foundKey['scopes']); $this->assertEmpty($foundKey['expire']); $this->assertNotEquals($apiKey['secret'], $foundKey['secret']); From b92040879ad97566c958f6f3ec2956ac9be15673 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 13:59:56 +0100 Subject: [PATCH 09/20] Restore api-key test cleanup that older merge silently dropped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The webhook-side cleanup (delete all migrated keys except the destination's own auth key) got lost during an earlier webhook→policies merge because policies branch had its own modification in the same lines. Restoring to match webhook so PR #12363 diff is policies-scoped only. --- tests/e2e/Services/Migrations/MigrationsBase.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 5d09841633..c5e640aa42 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2622,8 +2622,15 @@ trait MigrationsBase $this->assertEmpty($foundKey['expire']); $this->assertNotEquals($apiKey['secret'], $foundKey['secret']); - // Cleanup on destination - $this->client->call(Client::METHOD_DELETE, '/project/keys/' . $foundKey['$id'], $destinationHeaders); + // Cleanup migrated keys on destination — delete anything that isn't the destination's own auth key, + // otherwise later tests inherit duplicated apiKeys and fail on conflict. + $destinationAuthSecret = $this->getDestinationProject()['apiKey']; + foreach ($response['body']['keys'] as $k) { + if ($k['secret'] === $destinationAuthSecret) { + continue; + } + $this->client->call(Client::METHOD_DELETE, '/project/keys/' . $k['$id'], $destinationHeaders); + } // Cleanup on source $this->client->call(Client::METHOD_DELETE, '/project/keys/' . $apiKey['$id'], $sourceHeaders); From 838ca28faf13c0e8d93c4c2b8a18e7293f88f1e2 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 14:37:16 +0100 Subject: [PATCH 10/20] Expose 'region' attribute in Project response model The region column already exists on the projects collection (platform.php). Exposing it through the response model so SDK consumers (migration source, cloud control plane) can deserialize Project responses from OSS without a 'Missing required field region' deserialization error. Default is 'default' (the same fallback the cloud worker uses when reading source region for cross-region detection). --- src/Appwrite/Utopia/Response/Model/Project.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index c788833e88..29d7964e0a 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -43,6 +43,12 @@ class Project extends Model 'default' => '', 'example' => '1592981250', ]) + ->addRule('region', [ + 'type' => self::TYPE_STRING, + 'description' => 'Project region.', + 'default' => 'default', + 'example' => 'fra', + ]) // Resource: Dev Keys ->addRule('devKeys', [ From 10fec187e28987b77669327d06c35e1c1dd81d44 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 14:51:50 +0100 Subject: [PATCH 11/20] Tighten secret project-variable assertion (Greptile P1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assertNotEquals('real-secret-value', $value) only rules out that exact string — a partial/corrupted leak (e.g. 'real-secret', 'REAL-SECRET-VALUE', hash) would still pass. The documented behavior is the destination stores '' because the source SDK strips secret values from list responses, so assertEmpty is the strictly tighter assertion. --- 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 c5e640aa42..d2b567bc34 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2797,7 +2797,7 @@ trait MigrationsBase $this->assertEquals($secretKey, $foundSecret['key']); // Secret variables: source SDK never returned the real value, so the destination // also stores empty. The original 'real-secret-value' must not have leaked. - $this->assertNotEquals('real-secret-value', $foundSecret['value']); + $this->assertEmpty($foundSecret['value']); $this->assertTrue($foundSecret['secret']); // Cleanup on destination From 4c238307cf55d6ebf554abe4454380f7457fd505 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 15:38:13 +0100 Subject: [PATCH 12/20] Expose 'blocks' and 'consoleAccessedAt' on Project response model The Appwrite PHP SDK Project model (generated from cloud's spec) requires both fields. OSS responses previously omitted them, causing 'Missing required field' deserialization errors when the migration source SDK reads a project from an OSS instance. - 'blocks' defaults to [] (cloud-only feature; OSS responses always empty) - 'consoleAccessedAt' is mapped from the existing 'accessedAt' DB column via a new expandConsoleAccessedAt() filter, matching the expandX pattern already used for smtp/services/protocols/authMethods. --- .../Utopia/Response/Model/Project.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 29d7964e0a..d475cfe5f2 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -179,6 +179,19 @@ class Project extends Model 'example' => new \stdClass(), 'array' => true, ]) + ->addRule('blocks', [ + 'type' => self::TYPE_STRING, + 'description' => 'Project blocks information.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('consoleAccessedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Last time the project was accessed via console.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) ; } @@ -213,10 +226,16 @@ class Project extends Model $this->expandServices($document); $this->expandProtocols($document); $this->expandAuthMethods($document); + $this->expandConsoleAccessedAt($document); return $document; } + private function expandConsoleAccessedAt(Document $document): void + { + $document->setAttribute('consoleAccessedAt', $document->getAttribute('accessedAt', '')); + } + private function expandSmtpFields(Document $document): void { if (!$document->isSet('smtp')) { From 3ab07b32d9bbeff4595837f5bcbe52cb27dfd068 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 16:33:59 +0100 Subject: [PATCH 13/20] Use modern Project response format in auth/protocols/services tests The tests were asserting on legacy flat fields (authEmailPassword, protocolStatusForGraphql, serviceStatusForFunctions) that only exist when the client sends x-appwrite-response-format < 1.9.5 (triggering the V26 filter). Without that header the response carries the modern array shape (authMethods/protocols/services as [{\$id, enabled}, ...]). Switched assertions to array_column(...) lookup against \$id so the tests work against the default (post-V26) response shape. --- tests/e2e/Services/Migrations/MigrationsBase.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index d2b567bc34..fa954fdd4b 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2851,8 +2851,9 @@ trait MigrationsBase $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertFalse($response['body']['authEmailPassword'], 'authEmailPassword should be migrated as false'); - $this->assertFalse($response['body']['authJWT'], 'authJWT should be migrated as false'); + $authMethods = \array_column($response['body']['authMethods'] ?? [], 'enabled', '$id'); + $this->assertFalse($authMethods['email-password'] ?? null, 'email-password auth method should be migrated as false'); + $this->assertFalse($authMethods['jwt'] ?? null, 'jwt auth method should be migrated as false'); // Restore source so the test is idempotent. $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/email-password', $consoleHeaders, ['status' => true]); @@ -2902,8 +2903,9 @@ trait MigrationsBase $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertFalse($response['body']['protocolStatusForGraphql'], 'GraphQL protocol should be migrated as disabled'); - $this->assertFalse($response['body']['protocolStatusForWebsocket'], 'WebSocket protocol should be migrated as disabled'); + $protocols = \array_column($response['body']['protocols'] ?? [], 'enabled', '$id'); + $this->assertFalse($protocols['graphql'] ?? null, 'GraphQL protocol should be migrated as disabled'); + $this->assertFalse($protocols['websocket'] ?? null, 'WebSocket protocol should be migrated as disabled'); // Restore both projects so the test is idempotent. $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, ['status' => true]); @@ -3001,8 +3003,9 @@ trait MigrationsBase $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertFalse($response['body']['serviceStatusForFunctions'], 'Functions service should be migrated as disabled'); - $this->assertFalse($response['body']['serviceStatusForGraphql'], 'GraphQL service should be migrated as disabled'); + $services = \array_column($response['body']['services'] ?? [], 'enabled', '$id'); + $this->assertFalse($services['functions'] ?? null, 'Functions service should be migrated as disabled'); + $this->assertFalse($services['graphql'] ?? null, 'GraphQL service should be migrated as disabled'); // Restore both projects. $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => true]); From 48250dc09a35785c6a87b9c634ad5a9b4e150eda Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 17:15:14 +0100 Subject: [PATCH 14/20] Fix migration tests using wrong PATCH endpoints + body fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The setup mutations on source were silently no-ops because they hit URLs/ fields that don't match the actual endpoints: - auth-methods: PATCH /projects/:id/auth/:method {status} -> PATCH /project/auth-methods/:method {enabled} - protocols: PATCH /projects/:id/api/:protocol {status} -> PATCH /project/protocols/:protocol {enabled} - services: PATCH /projects/:id/service/:service {status} -> PATCH /project/services/:service {enabled} - labels: PATCH /projects/:id {labels:[...]} -> PUT /project/labels {labels:[...]} (the /projects/:id update endpoint doesn't accept labels) Used x-appwrite-project + x-appwrite-mode=admin pattern from ProjectsConsoleClientTest. Labels also switched away from 'vip-…' to plain alphanumeric — the labels validator allowList excludes hyphens. Migration library itself is correct; these were test-setup bugs that masked themselves because the mutations silently failed, so the source project always migrated with default (all-enabled / no-labels) state. --- .../Services/Migrations/MigrationsBase.php | 108 ++++++++++++------ 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index fa954fdd4b..6d45b8edad 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2818,15 +2818,26 @@ trait MigrationsBase 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]; + $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', + ]); + // Flip a couple of auth methods on the source so the round-trip is // observable. Settling on email-password OFF and JWT OFF — the // remaining flags stay on their server defaults. - $sourceProjectId = $this->getProject()['$id']; - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/email-password', $consoleHeaders, [ - 'status' => false, + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceAdminHeaders, [ + 'enabled' => false, ]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/jwt', $consoleHeaders, [ - 'status' => false, + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceAdminHeaders, [ + 'enabled' => false, ]); $result = $this->performMigrationSync([ @@ -2847,7 +2858,6 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['warning']); - $destinationProjectId = $this->getDestinationProject()['$id']; $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); $this->assertEquals(200, $response['headers']['status-code']); @@ -2856,11 +2866,11 @@ trait MigrationsBase $this->assertFalse($authMethods['jwt'] ?? null, 'jwt auth method should be migrated as false'); // Restore source so the test is idempotent. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/email-password', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceAdminHeaders, ['enabled' => true]); // Restore destination too. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/email-password', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $destinationAdminHeaders, ['enabled' => true]); } public function testAppwriteMigrationProtocols(): void @@ -2873,12 +2883,23 @@ trait MigrationsBase ]; $sourceProjectId = $this->getProject()['$id']; - // Flip graphql + websocket off on source to make the round-trip observable. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, [ - 'status' => false, + $destinationProjectId = $this->getDestinationProject()['$id']; + + $sourceAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $sourceProjectId, + 'x-appwrite-mode' => 'admin', ]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, [ - 'status' => false, + $destinationAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $destinationProjectId, + 'x-appwrite-mode' => 'admin', + ]); + + // Flip graphql + websocket off on source to make the round-trip observable. + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceAdminHeaders, [ + 'enabled' => false, + ]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceAdminHeaders, [ + 'enabled' => false, ]); $result = $this->performMigrationSync([ @@ -2899,7 +2920,6 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['warning']); - $destinationProjectId = $this->getDestinationProject()['$id']; $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); $this->assertEquals(200, $response['headers']['status-code']); @@ -2908,10 +2928,10 @@ trait MigrationsBase $this->assertFalse($protocols['websocket'] ?? null, 'WebSocket protocol should be migrated as disabled'); // Restore both projects so the test is idempotent. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/graphql', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/websocket', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $destinationAdminHeaders, ['enabled' => true]); } public function testAppwriteMigrationLabels(): void @@ -2926,11 +2946,20 @@ trait MigrationsBase $sourceProjectId = $this->getProject()['$id']; $destinationProjectId = $this->getDestinationProject()['$id']; - $labels = ['vip-' . \substr(ID::unique(), 0, 8), 'beta-' . \substr(ID::unique(), 0, 8)]; + $sourceAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $sourceProjectId, + 'x-appwrite-mode' => 'admin', + ]); + $destinationAdminHeaders = \array_merge($consoleHeaders, [ + 'x-appwrite-project' => $destinationProjectId, + 'x-appwrite-mode' => 'admin', + ]); - // Set labels on source. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId, $consoleHeaders, [ - 'name' => $this->getProject()['name'] ?? 'Test', + $labels = ['vip' . \substr(ID::unique(), 0, 8), 'beta' . \substr(ID::unique(), 0, 8)]; + + // Set labels on source. The labels endpoint is PUT /project/labels — the + // generic project update endpoint doesn't accept a labels param. + $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceAdminHeaders, [ 'labels' => $labels, ]); @@ -2957,14 +2986,8 @@ trait MigrationsBase $this->assertEqualsCanonicalizing($labels, $response['body']['labels']); // Restore both projects. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId, $consoleHeaders, [ - 'name' => $this->getProject()['name'] ?? 'Test', - 'labels' => [], - ]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId, $consoleHeaders, [ - 'name' => $this->getDestinationProject()['name'] ?? 'Test', - 'labels' => [], - ]); + $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceAdminHeaders, ['labels' => []]); + $this->client->call(Client::METHOD_PUT, '/project/labels', $destinationAdminHeaders, ['labels' => []]); } public function testAppwriteMigrationServices(): void @@ -2979,9 +3002,18 @@ 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', + ]); + // Disable functions + graphql on source as observable changes. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => false]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceAdminHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceAdminHeaders, ['enabled' => false]); $result = $this->performMigrationSync([ 'resources' => [ @@ -3008,10 +3040,10 @@ trait MigrationsBase $this->assertFalse($services['graphql'] ?? null, 'GraphQL service should be migrated as disabled'); // Restore both projects. - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/functions', $consoleHeaders, ['status' => true]); - $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $destinationAdminHeaders, ['enabled' => true]); } public function testAppwriteMigrationPolicies(): void From 5f66950d0fd88e780fd2f15bf05bf57d1c4ca823 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 17:20:18 +0100 Subject: [PATCH 15/20] Use project-scoped /project GET in migration tests instead of /projects/:id The PATCH calls already use project-scoped /project/* with admin headers. Switching the GET to /project keeps the read on the same scope the migration library SDK actually uses, and matches the rest of the test. --- tests/e2e/Services/Migrations/MigrationsBase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 6d45b8edad..1843a17940 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2858,7 +2858,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['warning']); - $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']); $authMethods = \array_column($response['body']['authMethods'] ?? [], 'enabled', '$id'); @@ -2920,7 +2920,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['warning']); - $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']); $protocols = \array_column($response['body']['protocols'] ?? [], 'enabled', '$id'); @@ -2981,7 +2981,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['warning']); - $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->assertEqualsCanonicalizing($labels, $response['body']['labels']); @@ -3033,7 +3033,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['warning']); - $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']); $services = \array_column($response['body']['services'] ?? [], 'enabled', '$id'); $this->assertFalse($services['functions'] ?? null, 'Functions service should be migrated as disabled'); From 2628426b62b43367716b3b67b19c0029d505851d Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 21:40:41 +0100 Subject: [PATCH 16/20] 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 f6d2bae4fb..629237896f 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "91140887b9ff8efcefe326857115bd37c90db1cf" + "reference": "b210eb29ada6458baebd0de91e12208701e6ac60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/91140887b9ff8efcefe326857115bd37c90db1cf", - "reference": "91140887b9ff8efcefe326857115bd37c90db1cf", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/b210eb29ada6458baebd0de91e12208701e6ac60", + "reference": "b210eb29ada6458baebd0de91e12208701e6ac60", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-21T12:22:42+00:00" + "time": "2026-05-27T20:35:10+00:00" }, { "name": "utopia-php/mongo", From 00305218309e3c268cb4ad3340a5b6e0f29863bf Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 27 May 2026 21:56:31 +0100 Subject: [PATCH 17/20] 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..c1e3bf8c98 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": "0701b0612a17ecc72ed4426e0ee95d57", "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-policies-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "a351e83121d0241737d99102e4d63e15c75da5b0" + "reference": "b210eb29ada6458baebd0de91e12208701e6ac60" }, "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/b210eb29ada6458baebd0de91e12208701e6ac60", + "reference": "b210eb29ada6458baebd0de91e12208701e6ac60", "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-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-27T20:34:30+00:00" + "time": "2026-05-27T20:35:10+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-policies-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 7d181fbfccfdb7a9e8eec3325b9f5f5d924c4ed1 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 28 May 2026 13:50:04 +0100 Subject: [PATCH 18/20] Adopt TYPE_PROJECT_* rename from migration library --- composer.lock | 8 ++-- .../Utopia/Response/Model/MigrationReport.php | 6 +-- .../Services/Migrations/MigrationsBase.php | 48 +++++++++---------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/composer.lock b/composer.lock index c1e3bf8c98..5f248ff8c3 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b210eb29ada6458baebd0de91e12208701e6ac60" + "reference": "12eee286a6ac1870765112f7e3d6613352337369" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b210eb29ada6458baebd0de91e12208701e6ac60", - "reference": "b210eb29ada6458baebd0de91e12208701e6ac60", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/12eee286a6ac1870765112f7e3d6613352337369", + "reference": "12eee286a6ac1870765112f7e3d6613352337369", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-27T20:35:10+00:00" + "time": "2026-05-28T11:46:47+00:00" }, { "name": "utopia-php/mongo", diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 16ceb8341a..2342bfa0dd 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -83,19 +83,19 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) - ->addRule(Resource::TYPE_PROTOCOLS, [ + ->addRule(Resource::TYPE_PROJECT_PROTOCOLS, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of protocol configs to be migrated (always 0 or 1 — the project-level REST/GraphQL/WebSocket flags).', 'default' => 0, 'example' => 1, ]) - ->addRule(Resource::TYPE_LABELS, [ + ->addRule(Resource::TYPE_PROJECT_LABELS, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of label sets to be migrated (always 0 or 1 — the project-level RBAC label array).', 'default' => 0, 'example' => 1, ]) - ->addRule(Resource::TYPE_SERVICES, [ + ->addRule(Resource::TYPE_PROJECT_SERVICES, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of service configs to be migrated (always 0 or 1 — the project-level enable/disable flags for all 17 services).', 'default' => 0, diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 1843a17940..a0f5ae05da 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2904,7 +2904,7 @@ trait MigrationsBase $result = $this->performMigrationSync([ 'resources' => [ - Resource::TYPE_PROTOCOLS, + Resource::TYPE_PROJECT_PROTOCOLS, ], 'endpoint' => $this->webEndpoint, 'projectId' => $sourceProjectId, @@ -2912,13 +2912,13 @@ trait MigrationsBase ]); $this->assertEquals('completed', $result['status']); - $this->assertEquals([Resource::TYPE_PROTOCOLS], $result['resources']); - $this->assertArrayHasKey(Resource::TYPE_PROTOCOLS, $result['statusCounters']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['error']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['pending']); - $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['success']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['processing']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['warning']); + $this->assertEquals([Resource::TYPE_PROJECT_PROTOCOLS], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_PROJECT_PROTOCOLS, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['warning']); $response = $this->client->call(Client::METHOD_GET, '/project', $destinationAdminHeaders); @@ -2965,7 +2965,7 @@ trait MigrationsBase $result = $this->performMigrationSync([ 'resources' => [ - Resource::TYPE_LABELS, + Resource::TYPE_PROJECT_LABELS, ], 'endpoint' => $this->webEndpoint, 'projectId' => $sourceProjectId, @@ -2973,13 +2973,13 @@ trait MigrationsBase ]); $this->assertEquals('completed', $result['status']); - $this->assertEquals([Resource::TYPE_LABELS], $result['resources']); - $this->assertArrayHasKey(Resource::TYPE_LABELS, $result['statusCounters']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['error']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['pending']); - $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_LABELS]['success']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['processing']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_LABELS]['warning']); + $this->assertEquals([Resource::TYPE_PROJECT_LABELS], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_PROJECT_LABELS, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['warning']); $response = $this->client->call(Client::METHOD_GET, '/project', $destinationAdminHeaders); $this->assertEquals(200, $response['headers']['status-code']); @@ -3017,7 +3017,7 @@ trait MigrationsBase $result = $this->performMigrationSync([ 'resources' => [ - Resource::TYPE_SERVICES, + Resource::TYPE_PROJECT_SERVICES, ], 'endpoint' => $this->webEndpoint, 'projectId' => $sourceProjectId, @@ -3025,13 +3025,13 @@ trait MigrationsBase ]); $this->assertEquals('completed', $result['status']); - $this->assertEquals([Resource::TYPE_SERVICES], $result['resources']); - $this->assertArrayHasKey(Resource::TYPE_SERVICES, $result['statusCounters']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['error']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['pending']); - $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_SERVICES]['success']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['processing']); - $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['warning']); + $this->assertEquals([Resource::TYPE_PROJECT_SERVICES], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_PROJECT_SERVICES, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['warning']); $response = $this->client->call(Client::METHOD_GET, '/project', $destinationAdminHeaders); $this->assertEquals(200, $response['headers']['status-code']); From 8bba042616f1c4b4091f649609d0719073568da3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 28 May 2026 14:39:20 +0100 Subject: [PATCH 19/20] Bump migration lock to pull Protocols revert --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 5f248ff8c3..614f225f01 100644 --- a/composer.lock +++ b/composer.lock @@ -4679,12 +4679,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "12eee286a6ac1870765112f7e3d6613352337369" + "reference": "7c55885aaa04c53b57110180a303a7689480d4cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/12eee286a6ac1870765112f7e3d6613352337369", - "reference": "12eee286a6ac1870765112f7e3d6613352337369", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/7c55885aaa04c53b57110180a303a7689480d4cf", + "reference": "7c55885aaa04c53b57110180a303a7689480d4cf", "shasum": "" }, "require": { @@ -4744,7 +4744,7 @@ "source": "https://github.com/utopia-php/migration/tree/add-policies-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-28T11:46:47+00:00" + "time": "2026-05-28T13:32:51+00:00" }, { "name": "utopia-php/mongo", From a256b8d5bcd0f7c526b09f4c8ecaa03a6daf84ba Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 28 May 2026 17:02:21 +0100 Subject: [PATCH 20/20] Use API key headers in all /project/* migration tests (drop admin-mode pattern) --- .../Services/Migrations/MigrationsBase.php | 162 ++++++++---------- 1 file changed, 71 insertions(+), 91 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index a0f5ae05da..86d7613d7a 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2811,32 +2811,27 @@ trait MigrationsBase public function testAppwriteMigrationAuthMethods(): 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'], + ]; // Flip a couple of auth methods on the source so the round-trip is // observable. Settling on email-password OFF and JWT OFF — the // remaining flags stay on their server defaults. - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceAdminHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceKeyHeaders, [ 'enabled' => false, ]); - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceAdminHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceKeyHeaders, [ 'enabled' => false, ]); @@ -2858,7 +2853,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_AUTH_METHODS]['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']); $authMethods = \array_column($response['body']['authMethods'] ?? [], 'enabled', '$id'); @@ -2866,39 +2861,34 @@ trait MigrationsBase $this->assertFalse($authMethods['jwt'] ?? null, 'jwt auth method should be migrated as false'); // Restore source so the test is idempotent. - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $sourceKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $sourceKeyHeaders, ['enabled' => true]); // Restore destination too. - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $destinationAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/email-password', $destinationKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/auth-methods/jwt', $destinationKeyHeaders, ['enabled' => true]); } public function testAppwriteMigrationProtocols(): 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'], + ]; // Flip graphql + websocket off on source to make the round-trip observable. - $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceAdminHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceKeyHeaders, [ 'enabled' => false, ]); - $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceAdminHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceKeyHeaders, [ 'enabled' => false, ]); @@ -2920,7 +2910,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_PROTOCOLS]['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']); $protocols = \array_column($response['body']['protocols'] ?? [], 'enabled', '$id'); @@ -2928,38 +2918,33 @@ trait MigrationsBase $this->assertFalse($protocols['websocket'] ?? null, 'WebSocket protocol should be migrated as disabled'); // Restore both projects so the test is idempotent. - $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $destinationAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $sourceKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $sourceKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/graphql', $destinationKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/protocols/websocket', $destinationKeyHeaders, ['enabled' => true]); } public function testAppwriteMigrationLabels(): 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'], + ]; $labels = ['vip' . \substr(ID::unique(), 0, 8), 'beta' . \substr(ID::unique(), 0, 8)]; // Set labels on source. The labels endpoint is PUT /project/labels — the // generic project update endpoint doesn't accept a labels param. - $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceAdminHeaders, [ + $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceKeyHeaders, [ 'labels' => $labels, ]); @@ -2981,39 +2966,34 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_LABELS]['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->assertEqualsCanonicalizing($labels, $response['body']['labels']); // Restore both projects. - $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceAdminHeaders, ['labels' => []]); - $this->client->call(Client::METHOD_PUT, '/project/labels', $destinationAdminHeaders, ['labels' => []]); + $this->client->call(Client::METHOD_PUT, '/project/labels', $sourceKeyHeaders, ['labels' => []]); + $this->client->call(Client::METHOD_PUT, '/project/labels', $destinationKeyHeaders, ['labels' => []]); } public function testAppwriteMigrationServices(): 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'], + ]; // Disable functions + graphql on source as observable changes. - $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceAdminHeaders, ['enabled' => false]); - $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceAdminHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceKeyHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceKeyHeaders, ['enabled' => false]); $result = $this->performMigrationSync([ 'resources' => [ @@ -3033,17 +3013,17 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_SERVICES]['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']); $services = \array_column($response['body']['services'] ?? [], 'enabled', '$id'); $this->assertFalse($services['functions'] ?? null, 'Functions service should be migrated as disabled'); $this->assertFalse($services['graphql'] ?? null, 'GraphQL service should be migrated as disabled'); // Restore both projects. - $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $destinationAdminHeaders, ['enabled' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $destinationAdminHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $sourceKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $sourceKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/functions', $destinationKeyHeaders, ['enabled' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/services/graphql', $destinationKeyHeaders, ['enabled' => true]); } public function testAppwriteMigrationPolicies(): void @@ -3053,12 +3033,12 @@ trait MigrationsBase // Policies have no /projects/:projectId admin route — they're only // reachable via project-scoped /v1/project/policies/* with an API key. - $sourceProjectHeaders = [ + $sourceKeyHeaders = [ 'content-type' => 'application/json', 'x-appwrite-project' => $sourceProjectId, 'x-appwrite-key' => $this->getProject()['apiKey'], ]; - $destinationProjectHeaders = [ + $destinationKeyHeaders = [ 'content-type' => 'application/json', 'x-appwrite-project' => $destinationProjectId, 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], @@ -3066,13 +3046,13 @@ trait MigrationsBase // Pick three policies that span the field types: int, bool, and // bundled membership-privacy. - $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceProjectHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceKeyHeaders, [ 'total' => 5, ]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceProjectHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceKeyHeaders, [ 'enabled' => true, ]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceProjectHeaders, [ + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceKeyHeaders, [ 'userEmail' => false, ]); @@ -3094,25 +3074,25 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_POLICIES]['warning']); - $passwordHistory = $this->client->call(Client::METHOD_GET, '/project/policies/password-history', $destinationProjectHeaders); + $passwordHistory = $this->client->call(Client::METHOD_GET, '/project/policies/password-history', $destinationKeyHeaders); $this->assertSame(200, $passwordHistory['headers']['status-code']); $this->assertSame(5, $passwordHistory['body']['total'], 'passwordHistory should be migrated as 5'); - $sessionAlert = $this->client->call(Client::METHOD_GET, '/project/policies/session-alert', $destinationProjectHeaders); + $sessionAlert = $this->client->call(Client::METHOD_GET, '/project/policies/session-alert', $destinationKeyHeaders); $this->assertSame(200, $sessionAlert['headers']['status-code']); $this->assertTrue($sessionAlert['body']['enabled'], 'session-alert policy should be migrated as enabled'); - $membershipPrivacy = $this->client->call(Client::METHOD_GET, '/project/policies/membership-privacy', $destinationProjectHeaders); + $membershipPrivacy = $this->client->call(Client::METHOD_GET, '/project/policies/membership-privacy', $destinationKeyHeaders); $this->assertSame(200, $membershipPrivacy['headers']['status-code']); $this->assertFalse($membershipPrivacy['body']['userEmail'], 'membership-privacy userEmail should be migrated as false'); // Restore both projects to defaults. - $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceProjectHeaders, ['total' => 0]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceProjectHeaders, ['enabled' => false]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceProjectHeaders, ['userEmail' => true]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $destinationProjectHeaders, ['total' => 0]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $destinationProjectHeaders, ['enabled' => false]); - $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $destinationProjectHeaders, ['userEmail' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $sourceKeyHeaders, ['total' => 0]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $sourceKeyHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $sourceKeyHeaders, ['userEmail' => true]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', $destinationKeyHeaders, ['total' => 0]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', $destinationKeyHeaders, ['enabled' => false]); + $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', $destinationKeyHeaders, ['userEmail' => true]); } /**