From f25d3df7af31ff675354a19c2db889788146938c Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 11:19:13 +0000 Subject: [PATCH 01/28] Add platform DB access via console-key endpoint --- app/config/scopes/consoleProject.php | 7 ++++ app/controllers/shared/api.php | 17 ++++++++ app/init/constants.php | 3 ++ .../migration-appwrite-console-key.md | 1 + src/Appwrite/Auth/Key.php | 26 +++++++++++- src/Appwrite/Utopia/Response.php | 1 + .../Utopia/Response/Model/MigrationKey.php | 40 +++++++++++++++++++ 7 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/config/scopes/consoleProject.php create mode 100644 docs/references/migrations/migration-appwrite-console-key.md create mode 100644 src/Appwrite/Utopia/Response/Model/MigrationKey.php diff --git a/app/config/scopes/consoleProject.php b/app/config/scopes/consoleProject.php new file mode 100644 index 0000000000..9420486776 --- /dev/null +++ b/app/config/scopes/consoleProject.php @@ -0,0 +1,7 @@ + 'platforms.read', +]; diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index c6499ff9b6..56090f100a 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -334,6 +334,23 @@ Http::init() $scopes = \array_unique($scopes); + // Migration-sourced keys are scoped to a single project's console + // endpoints (e.g. /v1/projects/:projectId/platforms). Verify the + // URL :projectId matches the token's scopedProjectId. + if (!empty($apiKey) && $apiKey->getSource() === KEY_SOURCE_MIGRATION) { + $scopedProjectId = $apiKey->getScopedProjectId(); + + if (empty($scopedProjectId)) { + throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE); + } + + $pathValues = $route->getPathValues($request); + + if (($pathValues['projectId'] ?? '') !== $scopedProjectId) { + throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE); + } + } + $authorization->addRole($role); foreach ($user->getRoles($authorization) as $authRole) { $authorization->addRole($authRole); diff --git a/app/init/constants.php b/app/init/constants.php index c6a5bc853e..73835e5525 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -41,6 +41,7 @@ const APP_LIMIT_LIST_DEFAULT = 25; // Default maximum number of items to return const APP_LIMIT_DATABASE_BATCH = 100; // Default maximum batch size for database operations const APP_LIMIT_DATABASE_TRANSACTION = 100; // Default maximum operations per transaction const APP_KEY_ACCESS = 24 * 60 * 60; // 24 hours +const APP_CONSOLE_KEY_TTL = 120; // 2 minutes const APP_USER_ACCESS = 24 * 60 * 60; // 24 hours const APP_PROJECT_ACCESS = 24 * 60 * 60; // 24 hours const APP_RESOURCE_TOKEN_ACCESS = 24 * 60 * 60; // 24 hours @@ -255,6 +256,8 @@ const API_KEY_STANDARD = 'standard'; const API_KEY_DYNAMIC = 'dynamic'; const API_KEY_ORGANIZATION = 'organization'; const API_KEY_ACCOUNT = 'account'; +// API key source identifiers +const KEY_SOURCE_MIGRATION = 'migration'; // Usage metrics const METRIC_TEAMS = 'teams'; const METRIC_USERS = 'users'; diff --git a/docs/references/migrations/migration-appwrite-console-key.md b/docs/references/migrations/migration-appwrite-console-key.md new file mode 100644 index 0000000000..5fcdda1cc6 --- /dev/null +++ b/docs/references/migrations/migration-appwrite-console-key.md @@ -0,0 +1 @@ +Generate a temporary console-scoped API key for migrating project settings (platforms, keys, schedules). diff --git a/src/Appwrite/Auth/Key.php b/src/Appwrite/Auth/Key.php index 8f645f6f08..8788e6d791 100644 --- a/src/Appwrite/Auth/Key.php +++ b/src/Appwrite/Auth/Key.php @@ -28,6 +28,8 @@ class Key protected bool $projectCheckDisabled = false, protected bool $previewAuthDisabled = false, protected bool $deploymentStatusIgnored = false, + protected string $scopedProjectId = '', + protected string $source = '', ) { } @@ -103,6 +105,16 @@ class Key return $this->projectCheckDisabled; } + public function getScopedProjectId(): string + { + return $this->scopedProjectId; + } + + public function getSource(): string + { + return $this->source; + } + /** * Decode the given secret key into a Key object, containing the project ID, type, role, scopes, and name. * Can be a stored API key or a dynamic key (JWT). @@ -161,7 +173,15 @@ class Key $projectCheckDisabled = $payload['projectCheckDisabled'] ?? false; $previewAuthDisabled = $payload['previewAuthDisabled'] ?? false; $deploymentStatusIgnored = $payload['deploymentStatusIgnored'] ?? false; - $scopes = \array_merge($payload['scopes'] ?? [], $scopes); + $scopedProjectId = $payload['scopedProjectId'] ?? ''; + $source = $payload['source'] ?? ''; + + // Keys with a scoped project are restricted — only use explicit JWT scopes + if (!empty($scopedProjectId)) { + $scopes = $payload['scopes'] ?? []; + } else { + $scopes = \array_merge($payload['scopes'] ?? [], $scopes); + } if (!$projectCheckDisabled && $projectId !== $project->getId()) { return $guestKey; @@ -181,7 +201,9 @@ class Key $bannerDisabled, $projectCheckDisabled, $previewAuthDisabled, - $deploymentStatusIgnored + $deploymentStatusIgnored, + $scopedProjectId, + $source ); case API_KEY_STANDARD: $key = $project->find( diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 682c645047..1dd2a464eb 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -231,6 +231,7 @@ class Response extends SwooleResponse public const MODEL_MIGRATION = 'migration'; public const MODEL_MIGRATION_LIST = 'migrationList'; public const MODEL_MIGRATION_REPORT = 'migrationReport'; + public const MODEL_MIGRATION_KEY = 'migrationKey'; public const MODEL_MIGRATION_FIREBASE_PROJECT = 'firebaseProject'; public const MODEL_MIGRATION_FIREBASE_PROJECT_LIST = 'firebaseProjectList'; diff --git a/src/Appwrite/Utopia/Response/Model/MigrationKey.php b/src/Appwrite/Utopia/Response/Model/MigrationKey.php new file mode 100644 index 0000000000..58cac0379f --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/MigrationKey.php @@ -0,0 +1,40 @@ +addRule('key', [ + 'type' => self::TYPE_STRING, + 'description' => 'Temporary API key for settings migration.', + 'default' => '', + 'example' => 'dynamic_eyJ...', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Migration Key'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_MIGRATION_KEY; + } +} From 01ccee520ba4bd0fa805ed9f1bd4193d6799a430 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 11:20:32 +0000 Subject: [PATCH 02/28] Add platform migration support --- app/controllers/api/migrations.php | 54 +++++++++++++++++++ app/init/configs.php | 1 + app/init/models.php | 2 + composer.json | 2 +- composer.lock | 6 ++- src/Appwrite/Platform/Workers/Migrations.php | 5 +- .../Utopia/Response/Model/MigrationReport.php | 6 +++ 7 files changed, 70 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 5a864ab928..370acb8da8 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -1,5 +1,6 @@ dynamic($migration, Response::MODEL_MIGRATION); }); +Http::get('/v1/migrations/appwrite/console-key') + ->groups(['api', 'migrations']) + ->desc('Generate console API key for migration') + ->label('scope', 'migrations.read') + ->label('sdk', new Method( + namespace: 'migrations', + group: null, + name: 'getAppwriteConsoleKey', + description: '/docs/references/migrations/migration-appwrite-console-key.md', + auth: [AuthType::KEY], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_MIGRATION_KEY, + ) + ] + )) + ->param('resources', [], new ArrayList(new WhiteList(\array_keys(Config::getParam('consoleProjectScopes')))), 'List of resource types to request access for.', true) + ->inject('response') + ->inject('project') + ->action(function (array $resources, Response $response, Document $project) { + $consoleProjectScopes = Config::getParam('consoleProjectScopes'); + + $scopes = empty($resources) + ? \array_values($consoleProjectScopes) + : \array_values(\array_intersect_key($consoleProjectScopes, \array_flip($resources))); + + if (empty($scopes)) { + throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE); + } + + $jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', APP_CONSOLE_KEY_TTL, 0); + $consoleKey = $jwt->encode([ + 'projectId' => 'console', + 'name' => 'Migration Settings Key', + 'source' => KEY_SOURCE_MIGRATION, + 'scopes' => $scopes, + 'disabledMetrics' => [ + METRIC_DATABASES_OPERATIONS_READS, + METRIC_DATABASES_OPERATIONS_WRITES, + METRIC_NETWORK_REQUESTS, + METRIC_NETWORK_INBOUND, + METRIC_NETWORK_OUTBOUND, + ], + 'scopedProjectId' => $project->getId(), + ]); + + $response->dynamic(new Document([ + 'key' => API_KEY_DYNAMIC . '_' . $consoleKey, + ]), Response::MODEL_MIGRATION_KEY); + }); + Http::get('/v1/migrations/appwrite/report') ->groups(['api', 'migrations']) ->desc('Get Appwrite migration report') diff --git a/app/init/configs.php b/app/init/configs.php index 35c8e3899d..cdca9a7632 100644 --- a/app/init/configs.php +++ b/app/init/configs.php @@ -25,6 +25,7 @@ Config::load('roles', __DIR__ . '/../config/roles.php', $configAdapter); // Use Config::load('projectScopes', __DIR__ . '/../config/scopes/project.php', $configAdapter); Config::load('organizationScopes', __DIR__ . '/../config/scopes/organization.php', $configAdapter); Config::load('accountScopes', __DIR__ . '/../config/scopes/account.php', $configAdapter); +Config::load('consoleProjectScopes', __DIR__ . '/../config/scopes/consoleProject.php', $configAdapter); Config::load('services', __DIR__ . '/../config/services.php', $configAdapter); // List of services Config::load('variables', __DIR__ . '/../config/variables.php', $configAdapter); // List of env variables Config::load('regions', __DIR__ . '/../config/regions.php', $configAdapter); // List of available regions diff --git a/app/init/models.php b/app/init/models.php index d432852660..3016d6f8cd 100644 --- a/app/init/models.php +++ b/app/init/models.php @@ -98,6 +98,7 @@ use Appwrite\Utopia\Response\Model\MFARecoveryCodes; use Appwrite\Utopia\Response\Model\MFAType; use Appwrite\Utopia\Response\Model\Migration; use Appwrite\Utopia\Response\Model\MigrationFirebaseProject; +use Appwrite\Utopia\Response\Model\MigrationKey; use Appwrite\Utopia\Response\Model\MigrationReport; use Appwrite\Utopia\Response\Model\Mock; use Appwrite\Utopia\Response\Model\MockNumber; @@ -357,6 +358,7 @@ Response::setModel(new Subscriber()); Response::setModel(new Target()); Response::setModel(new Migration()); Response::setModel(new MigrationReport()); +Response::setModel(new MigrationKey()); Response::setModel(new MigrationFirebaseProject()); // Tests (keep last) diff --git a/composer.json b/composer.json index 3dd24aa29f..37f7ad7442 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.20.*", - "utopia-php/migration": "1.6.*", + "utopia-php/migration": "dev-feat-platform-db-access as 1.5.0", "utopia-php/platform": "0.7.*", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index ccf03ce835..4461a8d2d9 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": "1fb043a556550f62ab27a0aad0b9332a", + "content-hash": "44e4887b0166d881da56e99dfcd284a4", "packages": [ { "name": "adhocore/jwt", @@ -9043,7 +9043,9 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "utopia-php/migration": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 7bc6fe8d32..9e4f76957f 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -246,6 +246,8 @@ class Migrations extends Action $credentials['destinationApiKey'], $this->dbForProject, Config::getParam('collections', [])['databases']['collections'], + $this->dbForPlatform, + $this->project->getSequence(), ), DestinationCSV::getName() => new DestinationCSV( $this->deviceForFiles, @@ -286,9 +288,6 @@ class Migrations extends Action ); } - /** - * @throws Exception - */ protected function generateAPIKey(Document $project): string { $jwt = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 86400, 0); diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 7ebc22d22e..36d77044bd 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -53,6 +53,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 20, ]) + ->addRule(Resource::TYPE_PLATFORM, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of platforms to be migrated.', + 'default' => 0, + 'example' => 5, + ]) ->addRule(Resource::TYPE_SITE, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of sites to be migrated.', From 01c2d0f04ba6eef555b2d993238f2a3f76c6bfad Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 15:31:44 +0000 Subject: [PATCH 03/28] Add expire field to migration console key response --- app/controllers/api/migrations.php | 4 +++- src/Appwrite/Utopia/Response/Model/MigrationKey.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 370acb8da8..a3c89e1055 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -17,6 +17,7 @@ use Utopia\Compression\Algorithms\Zstd; use Utopia\Compression\Compression; use Utopia\Config\Config; use Utopia\Database\Database; +use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Order as OrderException; use Utopia\Database\Exception\Query as QueryException; @@ -741,7 +742,8 @@ Http::get('/v1/migrations/appwrite/console-key') ]); $response->dynamic(new Document([ - 'key' => API_KEY_DYNAMIC . '_' . $consoleKey, + 'key' => API_KEY_DYNAMIC . '_' . $consoleKey, + 'expire' => DateTime::addSeconds(new \DateTime(), APP_CONSOLE_KEY_TTL), ]), Response::MODEL_MIGRATION_KEY); }); diff --git a/src/Appwrite/Utopia/Response/Model/MigrationKey.php b/src/Appwrite/Utopia/Response/Model/MigrationKey.php index 58cac0379f..b4cb829b52 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationKey.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationKey.php @@ -15,6 +15,12 @@ class MigrationKey extends Model 'description' => 'Temporary API key for settings migration.', 'default' => '', 'example' => 'dynamic_eyJ...', + ]) + ->addRule('expire', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Key expiration date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, ]); } From d51130ec8f164b94c043b7a899a006fe445d01c3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 16:21:36 +0000 Subject: [PATCH 04/28] Add E2E test for platform migration --- .../Services/Migrations/MigrationsBase.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 606f9e8127..d818ffd58b 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1170,6 +1170,83 @@ trait MigrationsBase return new CURLFile($tarPath, 'application/x-gzip', \basename($tarPath)); } + /** + * Integrations + */ + public function testAppwriteMigrationPlatform(): void + { + // Create platform on source project + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $this->getProject()['$id'] . '/platforms', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'type' => 'web', + 'name' => 'Test Platform', + 'hostname' => 'localhost', + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertNotEmpty($response['body']['$id']); + + $platform = $response['body']; + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_PLATFORM, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $this->getProject()['$id'], + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_PLATFORM], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_PLATFORM, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PLATFORM]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['warning']); + + // Verify platform on destination project + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertGreaterThan(0, $response['body']['total']); + + $foundPlatform = null; + + foreach ($response['body']['platforms'] as $p) { + if ($p['name'] === 'Test Platform' && $p['type'] === 'web') { + $foundPlatform = $p; + + break; + } + } + + $this->assertNotNull($foundPlatform); + $this->assertEquals('web', $foundPlatform['type']); + $this->assertEquals('Test Platform', $foundPlatform['name']); + $this->assertEquals('localhost', $foundPlatform['hostname']); + + // Cleanup on destination + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms/' . $foundPlatform['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + // Cleanup on source + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/platforms/' . $platform['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + } + /** * Import documents from a CSV file. */ From cdddd438f59ad9a802c2097f80dfb698b0656844 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 16:54:17 +0000 Subject: [PATCH 05/28] Update composer.lock for utopia-php/migration dev branch --- composer.lock | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 4461a8d2d9..40d2776a8a 100644 --- a/composer.lock +++ b/composer.lock @@ -4517,16 +4517,16 @@ }, { "name": "utopia-php/migration", - "version": "1.6.2", + "version": "dev-feat-platform-db-access", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "037bf4b3813d44f1b0990bc124e35b501ed27fca" + "reference": "06ea808b3191b985ebaae105c0fe5569094e68b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/037bf4b3813d44f1b0990bc124e35b501ed27fca", - "reference": "037bf4b3813d44f1b0990bc124e35b501ed27fca", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/06ea808b3191b985ebaae105c0fe5569094e68b6", + "reference": "06ea808b3191b985ebaae105c0fe5569094e68b6", "shasum": "" }, "require": { @@ -4566,9 +4566,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.6.2" + "source": "https://github.com/utopia-php/migration/tree/feat-platform-db-access" }, - "time": "2026-02-25T12:00:11+00:00" + "time": "2026-03-03T16:06:55+00:00" }, { "name": "utopia-php/mongo", @@ -9041,7 +9041,14 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/migration", + "version": "dev-feat-platform-db-access", + "alias": "1.5.0", + "alias_normalized": "1.5.0.0" + } + ], "minimum-stability": "dev", "stability-flags": { "utopia-php/migration": 20 From c6f4fc041f8265ae10787583eb6c5ea55ee5535a Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 18:58:41 +0000 Subject: [PATCH 06/28] Add unit tests for scopedProjectId and source fields in Key::decode() --- app/controllers/api/migrations.php | 2 +- .../Services/Migrations/MigrationsBase.php | 62 ++++++++++++++----- tests/unit/Auth/KeyTest.php | 23 +++++++ 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index a3c89e1055..7a42e5f0e8 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -697,7 +697,7 @@ Http::get('/v1/migrations/:migrationId') Http::get('/v1/migrations/appwrite/console-key') ->groups(['api', 'migrations']) ->desc('Generate console API key for migration') - ->label('scope', 'migrations.read') + ->label('scope', 'migrations.write') ->label('sdk', new Method( namespace: 'migrations', group: null, diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index d818ffd58b..b57a255f59 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1173,13 +1173,32 @@ trait MigrationsBase /** * Integrations */ - public function testAppwriteMigrationPlatform(): void + public function testGetAppwriteConsoleKey(): void { - // Create platform on source project - $response = $this->client->call(Client::METHOD_POST, '/projects/' . $this->getProject()['$id'] . '/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/migrations/appwrite/console-key', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['key']); + $this->assertStringStartsWith('dynamic_', $response['body']['key']); + $this->assertNotEmpty($response['body']['expire']); + $this->assertGreaterThan(new \DateTime(), new \DateTime($response['body']['expire'])); + } + + public function testAppwriteMigrationPlatform(): void + { + $consoleSessionHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + // Create platform on source project + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $this->getProject()['$id'] . '/platforms', $consoleSessionHeaders, [ 'type' => 'web', 'name' => 'Test Platform', 'hostname' => 'localhost', @@ -1209,11 +1228,22 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['warning']); - // Verify platform on destination project - $response = $this->client->call(Client::METHOD_GET, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms', array_merge([ + // Get a console key for the destination project to access console-scoped endpoints + $consoleKeyResponse = $this->client->call(Client::METHOD_GET, '/migrations/appwrite/console-key', [ 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); + 'x-appwrite-project' => $this->getDestinationProject()['$id'], + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]); + + $this->assertEquals(200, $consoleKeyResponse['headers']['status-code']); + $destConsoleKey = $consoleKeyResponse['body']['key']; + + // Verify platform on destination project using console key + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'x-appwrite-key' => $destConsoleKey, + ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']); @@ -1234,17 +1264,15 @@ trait MigrationsBase $this->assertEquals('Test Platform', $foundPlatform['name']); $this->assertEquals('localhost', $foundPlatform['hostname']); - // Cleanup on destination - $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms/' . $foundPlatform['$id'], array_merge([ + // Cleanup on destination using console key + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms/' . $foundPlatform['$id'], [ 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); + 'x-appwrite-project' => 'console', + 'x-appwrite-key' => $destConsoleKey, + ]); - // Cleanup on source - $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/platforms/' . $platform['$id'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); + // Cleanup on source using console project + session auth + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/platforms/' . $platform['$id'], $consoleSessionHeaders); } /** diff --git a/tests/unit/Auth/KeyTest.php b/tests/unit/Auth/KeyTest.php index fc1779efad..8e3f560bc9 100644 --- a/tests/unit/Auth/KeyTest.php +++ b/tests/unit/Auth/KeyTest.php @@ -49,6 +49,7 @@ class KeyTest extends TestCase 'projectCheckDisabled' => true, 'previewAuthDisabled' => true, 'deploymentStatusIgnored' => true, + 'source' => KEY_SOURCE_MIGRATION, ]; $key = static::generateKey($projectId, $usage, $scopes, extra: $extra); $decoded = Key::decode( @@ -70,6 +71,28 @@ class KeyTest extends TestCase $this->assertEquals(true, $decoded->isProjectCheckDisabled()); $this->assertEquals(true, $decoded->isPreviewAuthDisabled()); $this->assertEquals(true, $decoded->isDeploymentStatusIgnored()); + $this->assertEquals(KEY_SOURCE_MIGRATION, $decoded->getSource()); + + // Decode dynamic key with scopedProjectId — scopes must NOT be merged with role scopes + $scopedProjectId = 'scoped-project-123'; + $extra = [ + 'scopedProjectId' => $scopedProjectId, + 'source' => KEY_SOURCE_MIGRATION, + ]; + $key = static::generateKey('console', $usage, $scopes, extra: $extra); + $decoded = Key::decode( + project: new Document(['$id' => 'console']), + team: new Document(), + user: new Document(), + key: $key, + ); + $this->assertEquals('console', $decoded->getProjectId()); + $this->assertEquals(API_KEY_DYNAMIC, $decoded->getType()); + $this->assertEquals(User::ROLE_APPS, $decoded->getRole()); + $this->assertEquals($scopes, $decoded->getScopes()); + $this->assertNotEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); + $this->assertEquals($scopedProjectId, $decoded->getScopedProjectId()); + $this->assertEquals(KEY_SOURCE_MIGRATION, $decoded->getSource()); // Decode invalid dynamic key $invalidKey = API_KEY_DYNAMIC . '_invalid_jwt_token'; From abbc5f90970d714e053d9f689c14a979c219ee70 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 3 Mar 2026 20:33:11 +0000 Subject: [PATCH 07/28] Change console-key endpoint from GET to POST --- app/controllers/api/migrations.php | 6 +++--- tests/e2e/Services/Migrations/MigrationsBase.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 7a42e5f0e8..3516af53d9 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -694,14 +694,14 @@ Http::get('/v1/migrations/:migrationId') $response->dynamic($migration, Response::MODEL_MIGRATION); }); -Http::get('/v1/migrations/appwrite/console-key') +Http::post('/v1/migrations/appwrite/console-key') ->groups(['api', 'migrations']) - ->desc('Generate console API key for migration') + ->desc('Create console API key for migration') ->label('scope', 'migrations.write') ->label('sdk', new Method( namespace: 'migrations', group: null, - name: 'getAppwriteConsoleKey', + name: 'createAppwriteConsoleKey', description: '/docs/references/migrations/migration-appwrite-console-key.md', auth: [AuthType::KEY], responses: [ diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index b57a255f59..e8e533d390 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1175,7 +1175,7 @@ trait MigrationsBase */ public function testGetAppwriteConsoleKey(): void { - $response = $this->client->call(Client::METHOD_GET, '/migrations/appwrite/console-key', [ + $response = $this->client->call(Client::METHOD_POST, '/migrations/appwrite/console-key', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'], @@ -1229,7 +1229,7 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['warning']); // Get a console key for the destination project to access console-scoped endpoints - $consoleKeyResponse = $this->client->call(Client::METHOD_GET, '/migrations/appwrite/console-key', [ + $consoleKeyResponse = $this->client->call(Client::METHOD_POST, '/migrations/appwrite/console-key', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getDestinationProject()['$id'], 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], From b9274e97e17052a03c9c769a225d09816ea775c3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Sat, 14 Mar 2026 23:10:54 +0000 Subject: [PATCH 08/28] Pass projectInternalId to destination migration --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 41773a9138..82de08bbd1 100644 --- a/composer.lock +++ b/composer.lock @@ -4521,12 +4521,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "4939c67c82c03bfcd7aace9d91cccc6e45fc698c" + "reference": "12a4d8eb1d40e292c6592b917679a59b160b6374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/4939c67c82c03bfcd7aace9d91cccc6e45fc698c", - "reference": "4939c67c82c03bfcd7aace9d91cccc6e45fc698c", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/12a4d8eb1d40e292c6592b917679a59b160b6374", + "reference": "12a4d8eb1d40e292c6592b917679a59b160b6374", "shasum": "" }, "require": { @@ -4568,7 +4568,7 @@ "issues": "https://github.com/utopia-php/migration/issues", "source": "https://github.com/utopia-php/migration/tree/feat-platform-db-access" }, - "time": "2026-03-14T10:41:32+00:00" + "time": "2026-03-14T22:37:16+00:00" }, { "name": "utopia-php/mongo", From 8f993428dec0ea71b089cb30a5079f80b9b9e3b0 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 16 Mar 2026 14:25:04 +0000 Subject: [PATCH 09/28] Point utopia-php/migration to add-api-key-migration branch --- composer.json | 2 +- composer.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 41e0c4bc1c..943ad57293 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.20.*", - "utopia-php/migration": "dev-feat-platform-db-access as 1.8.0", + "utopia-php/migration": "dev-add-api-key-migration as 1.8.0", "utopia-php/platform": "0.7.*", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index 82de08bbd1..744dbf245c 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": "4ad48ed13cdfd66a288bb1529e731ead", + "content-hash": "71811c2ce39b1a4cc2e9c17d6e7ab07b", "packages": [ { "name": "adhocore/jwt", @@ -4517,16 +4517,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-feat-platform-db-access", + "version": "dev-add-api-key-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "12a4d8eb1d40e292c6592b917679a59b160b6374" + "reference": "86843355dced5e4ad763b19764a766a3821fb6b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/12a4d8eb1d40e292c6592b917679a59b160b6374", - "reference": "12a4d8eb1d40e292c6592b917679a59b160b6374", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/86843355dced5e4ad763b19764a766a3821fb6b2", + "reference": "86843355dced5e4ad763b19764a766a3821fb6b2", "shasum": "" }, "require": { @@ -4566,9 +4566,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/feat-platform-db-access" + "source": "https://github.com/utopia-php/migration/tree/add-api-key-migration" }, - "time": "2026-03-14T22:37:16+00:00" + "time": "2026-03-14T23:10:53+00:00" }, { "name": "utopia-php/mongo", @@ -9108,7 +9108,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-feat-platform-db-access", + "version": "dev-add-api-key-migration", "alias": "1.8.0", "alias_normalized": "1.8.0.0" } From b0d51cd25f6f6954c768692e46359548474b64d8 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 16 Mar 2026 22:29:13 +0000 Subject: [PATCH 10/28] Add API key migration support and console project scopes --- app/config/scopes/consoleProject.php | 2 + src/Appwrite/Platform/Workers/Migrations.php | 1 + .../Utopia/Response/Model/MigrationReport.php | 6 ++ .../Services/Migrations/MigrationsBase.php | 87 +++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/app/config/scopes/consoleProject.php b/app/config/scopes/consoleProject.php index 9420486776..f19f7998be 100644 --- a/app/config/scopes/consoleProject.php +++ b/app/config/scopes/consoleProject.php @@ -4,4 +4,6 @@ return [ 'platforms' => 'platforms.read', + 'keys' => 'keys.read', + 'keysWrite' => 'keys.write', ]; diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 9a47530630..8b866ededf 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -353,6 +353,7 @@ class Migrations extends Action 'messages.write', 'targets.read', 'targets.write', + 'migrations.write', ] ]); diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index 388630af3f..09380d8628 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -59,6 +59,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 5, ]) + ->addRule(Resource::TYPE_API_KEY, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of API keys to be migrated.', + 'default' => 0, + 'example' => 5, + ]) ->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 569600c01d..6476c26fb7 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1297,6 +1297,93 @@ trait MigrationsBase $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/platforms/' . $platform['$id'], $consoleSessionHeaders); } + public function testAppwriteMigrationApiKey(): void + { + $consoleSessionHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + // Create API key on source project + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $this->getProject()['$id'] . '/keys', $consoleSessionHeaders, [ + 'name' => 'Test API Key', + 'scopes' => ['databases.read', 'databases.write'], + 'expire' => null, + ]); + + $this->assertEquals(201, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertNotEmpty($response['body']['$id']); + + $apiKey = $response['body']; + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_API_KEY, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $this->getProject()['$id'], + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_API_KEY], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_API_KEY, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_API_KEY]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_API_KEY]['pending']); + $this->assertGreaterThanOrEqual(1, $result['statusCounters'][Resource::TYPE_API_KEY]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_API_KEY]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_API_KEY]['warning']); + + // Get a console key for the destination project to access console-scoped endpoints + $consoleKeyResponse = $this->client->call(Client::METHOD_POST, '/migrations/appwrite/console-key', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getDestinationProject()['$id'], + 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], + ]); + + $this->assertEquals(200, $consoleKeyResponse['headers']['status-code']); + $destConsoleKey = $consoleKeyResponse['body']['key']; + + // Verify API key on destination project using console key + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $this->getDestinationProject()['$id'] . '/keys', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'x-appwrite-key' => $destConsoleKey, + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertGreaterThan(0, $response['body']['total']); + + $foundKey = null; + + foreach ($response['body']['keys'] as $k) { + if ($k['name'] === 'Test API Key') { + $foundKey = $k; + + break; + } + } + + $this->assertNotNull($foundKey); + $this->assertEquals('Test API Key', $foundKey['name']); + $this->assertContains('databases.read', $foundKey['scopes']); + $this->assertContains('databases.write', $foundKey['scopes']); + + // Cleanup on destination using console key + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getDestinationProject()['$id'] . '/keys/' . $foundKey['$id'], [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'x-appwrite-key' => $destConsoleKey, + ]); + + // Cleanup on source using console project + session auth + $this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/keys/' . $apiKey['$id'], $consoleSessionHeaders); + } + /** * Import documents from a CSV file. */ From 18fc76007732e9a2dc4e040ae08ae21a0cd87268 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 14 May 2026 11:10:19 +0100 Subject: [PATCH 11/28] Remove stale console-key cleanup leftovers --- docs/references/migrations/migration-appwrite-console-key.md | 1 - src/Appwrite/Auth/Key.php | 1 - 2 files changed, 2 deletions(-) delete mode 100644 docs/references/migrations/migration-appwrite-console-key.md diff --git a/docs/references/migrations/migration-appwrite-console-key.md b/docs/references/migrations/migration-appwrite-console-key.md deleted file mode 100644 index 5fcdda1cc6..0000000000 --- a/docs/references/migrations/migration-appwrite-console-key.md +++ /dev/null @@ -1 +0,0 @@ -Generate a temporary console-scoped API key for migrating project settings (platforms, keys, schedules). diff --git a/src/Appwrite/Auth/Key.php b/src/Appwrite/Auth/Key.php index a8783c1c99..af2bb45c58 100644 --- a/src/Appwrite/Auth/Key.php +++ b/src/Appwrite/Auth/Key.php @@ -163,7 +163,6 @@ class Key $projectCheckDisabled = $payload['projectCheckDisabled'] ?? false; $previewAuthDisabled = $payload['previewAuthDisabled'] ?? false; $deploymentStatusIgnored = $payload['deploymentStatusIgnored'] ?? false; - $scopes = \array_merge($payload['scopes'] ?? [], $scopes); if (!$projectCheckDisabled && $projectId !== $project->getId()) { From 2b652a2b72d9fa04dc9d083b8af7988ed4114f4b Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 14 May 2026 11:25:09 +0100 Subject: [PATCH 12/28] Drop stray trailing comma in Key::decode return --- src/Appwrite/Auth/Key.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Auth/Key.php b/src/Appwrite/Auth/Key.php index af2bb45c58..0cbaefa4b3 100644 --- a/src/Appwrite/Auth/Key.php +++ b/src/Appwrite/Auth/Key.php @@ -183,7 +183,7 @@ class Key $bannerDisabled, $projectCheckDisabled, $previewAuthDisabled, - $deploymentStatusIgnored, + $deploymentStatusIgnored ); case API_KEY_STANDARD: $key = $project->find( From 0cdf7e184019e6d5342175d90574273fbcbab66b Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 14 May 2026 11:27:09 +0100 Subject: [PATCH 13/28] Tighten API key migration E2E assertions Verify scopes match exactly (canonicalizing for order), confirm null expire round-trips empty, and that destination's secret is freshly generated rather than copied from the source. --- tests/e2e/Services/Migrations/MigrationsBase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 9a2aeeeb25..1d3c93d704 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2605,8 +2605,9 @@ trait MigrationsBase $this->assertNotNull($foundKey); $this->assertEquals('Test API Key', $foundKey['name']); - $this->assertContains('databases.read', $foundKey['scopes']); - $this->assertContains('databases.write', $foundKey['scopes']); + $this->assertEqualsCanonicalizing(['databases.read', 'databases.write'], $foundKey['scopes']); + $this->assertEmpty($foundKey['expire']); + $this->assertNotEquals($apiKey['secret'], $foundKey['secret']); // Cleanup on destination $this->client->call(Client::METHOD_DELETE, '/project/keys/' . $foundKey['$id'], $destinationHeaders); From fc3589c1297334820dfb333e5fc9020d91a0d232 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Thu, 14 May 2026 16:02:53 +0100 Subject: [PATCH 14/28] Bump utopia-php/migration lock to 93715c2 --- composer.lock | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index abb2eca686..199710b788 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": "9377e1b56bca8dbaf213ee3572ca15c0", + "content-hash": "70b7a6b3803660b7a8aa1a542f630b02", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "1.12.0", + "version": "dev-add-api-key-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "3ee6e12af256726bddc3a0402c94535132abecc6" + "reference": "93715c256bf57cd93a1ef92e366c19f9a53ff21a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/3ee6e12af256726bddc3a0402c94535132abecc6", - "reference": "3ee6e12af256726bddc3a0402c94535132abecc6", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/93715c256bf57cd93a1ef92e366c19f9a53ff21a", + "reference": "93715c256bf57cd93a1ef92e366c19f9a53ff21a", "shasum": "" }, "require": { @@ -4655,9 +4655,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.12.0" + "source": "https://github.com/utopia-php/migration/tree/add-api-key-migration" }, - "time": "2026-05-14T07:30:09+00:00" + "time": "2026-05-14T14:53:20+00:00" }, { "name": "utopia-php/mongo", @@ -8564,10 +8564,18 @@ "time": "2024-11-07T12:36:22+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/migration", + "version": "dev-add-api-key-migration", + "alias": "1.12.0", + "alias_normalized": "1.12.0.0" + } + ], "minimum-stability": "dev", "stability-flags": { "utopia-php/http": 5, + "utopia-php/migration": 20, "utopia-php/platform": 5 }, "prefer-stable": true, From f4dd1ea2f48e0f6ea457905bc16e3abcf073f4b2 Mon Sep 17 00:00:00 2001 From: premtsd-code Date: Thu, 21 May 2026 08:39:44 +0100 Subject: [PATCH 15/28] 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 1d3c93d704..1081e7a7a2 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 9ca4d9155e386146996838a85e466c88397b7ef3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 08:37:05 +0100 Subject: [PATCH 16/28] Restore assertNotEmpty for statusCounters (completed migration always populated) --- 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 1d3c93d704..1081e7a7a2 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 83ce15deec9e710c540120ed0bc046fa865bb67b Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 09:08:58 +0100 Subject: [PATCH 17/28] Assert apiKey resource specifically in testCreateAppwriteMigration --- tests/e2e/Services/Migrations/MigrationsBase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 1081e7a7a2..7f97278f76 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -224,7 +224,9 @@ trait MigrationsBase $this->assertEquals(Appwrite::getSupportedResources(), $response['resources']); $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - $this->assertNotEmpty($response['statusCounters']); + $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); + $this->assertGreaterThan(0, $response['statusCounters'][Resource::TYPE_API_KEY]['success']); + $this->assertEquals(0, $response['statusCounters'][Resource::TYPE_API_KEY]['error']); } /** From 311b441de21d613088ab61698640fee34603eb82 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 10:04:45 +0100 Subject: [PATCH 18/28] Drop fixture-sensitive statusCounters assertion from smoke test --- tests/e2e/Services/Migrations/MigrationsBase.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 7f97278f76..26bbc19130 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -224,9 +224,6 @@ trait MigrationsBase $this->assertEquals(Appwrite::getSupportedResources(), $response['resources']); $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); - $this->assertGreaterThan(0, $response['statusCounters'][Resource::TYPE_API_KEY]['success']); - $this->assertEquals(0, $response['statusCounters'][Resource::TYPE_API_KEY]['error']); } /** From 00f7cff1e761eaab95945b1622de867829532c1a Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 10:35:22 +0100 Subject: [PATCH 19/28] Clean up all migrated apiKeys from destination, not just the test-created one --- 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 26bbc19130..1d3d83b51d 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2608,8 +2608,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 8ca2bac6b130b230cc39736f126bfdab2e1c9a76 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 10:59:42 +0100 Subject: [PATCH 20/28] Assert statusCounters contains only apiKey for fresh-fixture smoke test --- tests/e2e/Services/Migrations/MigrationsBase.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 1d3d83b51d..f5788ba540 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -224,6 +224,13 @@ trait MigrationsBase $this->assertEquals(Appwrite::getSupportedResources(), $response['resources']); $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); + + // A fresh test project only intrinsically has its auth apiKey — every other + // supported resource type has zero data and gets pruned by Transfer::getStatusCounters. + // So apiKey should be the only entry, successfully migrated with no errors. + $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); + $this->assertEquals(0, $response['statusCounters'][Resource::TYPE_API_KEY]['error']); + $this->assertGreaterThan(0, $response['statusCounters'][Resource::TYPE_API_KEY]['success']); } /** From dee95c740aef6955408d264011c22b0f40750ec3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 11:16:31 +0100 Subject: [PATCH 21/28] Accept skip as valid outcome for auth apiKey (name-collides with destination's own) --- tests/e2e/Services/Migrations/MigrationsBase.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index f5788ba540..4b363b0d3e 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -227,10 +227,14 @@ trait MigrationsBase // A fresh test project only intrinsically has its auth apiKey — every other // supported resource type has zero data and gets pruned by Transfer::getStatusCounters. - // So apiKey should be the only entry, successfully migrated with no errors. + // The auth apiKey itself is name-matched against the destination's auth apiKey on + // import (createApiKey in the destination handler), so it ends up skipped rather + // than successfully created. Either outcome means the resource was processed; an + // error is not. + $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); - $this->assertEquals(0, $response['statusCounters'][Resource::TYPE_API_KEY]['error']); - $this->assertGreaterThan(0, $response['statusCounters'][Resource::TYPE_API_KEY]['success']); + $this->assertEquals(0, $counts['error']); + $this->assertGreaterThan(0, $counts['success'] + $counts['skip']); } /** From edb32d04fe669b3fba4bbedbaf5ba24718db5c15 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 11:26:54 +0100 Subject: [PATCH 22/28] Trim apiKey assertion comment --- tests/e2e/Services/Migrations/MigrationsBase.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 4b363b0d3e..d9f5b0b41e 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -225,12 +225,7 @@ trait MigrationsBase $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - // A fresh test project only intrinsically has its auth apiKey — every other - // supported resource type has zero data and gets pruned by Transfer::getStatusCounters. - // The auth apiKey itself is name-matched against the destination's auth apiKey on - // import (createApiKey in the destination handler), so it ends up skipped rather - // than successfully created. Either outcome means the resource was processed; an - // error is not. + // Auth apiKey name-collides with destination's own and gets skipped — treat success or skip as processed. $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); $this->assertEquals(0, $counts['error']); From 3f4637887fed058b54b607051699c4c3da39eea3 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 11:43:36 +0100 Subject: [PATCH 23/28] Make test project apiKey name unique per project so migration succeeds --- tests/e2e/Scopes/ProjectCustom.php | 2 +- tests/e2e/Services/Migrations/MigrationsBase.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index c34a6527f9..c8a3704d57 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -111,7 +111,7 @@ trait ProjectCustom 'x-appwrite-project' => 'console', ], [ 'keyId' => ID::unique(), - 'name' => 'Demo Project Key', + 'name' => 'Demo Project Key ' . $project['body']['$id'], 'scopes' => [ 'users.read', 'users.write', diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index d9f5b0b41e..c4bfb585a2 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -225,11 +225,10 @@ trait MigrationsBase $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); - // Auth apiKey name-collides with destination's own and gets skipped — treat success or skip as processed. $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); $this->assertEquals(0, $counts['error']); - $this->assertGreaterThan(0, $counts['success'] + $counts['skip']); + $this->assertGreaterThan(0, $counts['success']); } /** From fa723c65ed39a069b2f1c0742a8dc7dc4647850f Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Tue, 26 May 2026 12:19:00 +0100 Subject: [PATCH 24/28] ci: re-trigger workflow From e80ad301f61fe41c73d153d678de27c25f96a201 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 08:34:31 +0100 Subject: [PATCH 25/28] Use released migration dependencies --- composer.json | 11 ++--------- composer.lock | 50 ++++++++++++++------------------------------------ 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index 58b1b3aa28..b78637ccd9 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.20.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "dev-feat-bump-sdk-24 as 1.3.0", + "utopia-php/abuse": "1.3.*", "utopia-php/agents": "2.*", "utopia-php/analytics": "0.15.*", "utopia-php/audit": "^2.4", @@ -75,7 +75,7 @@ "utopia-php/lock": "0.2.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "1.0.*", - "utopia-php/migration": "1.13.*", + "utopia-php/migration": "1.*", "utopia-php/platform": "1.0.0-rc4", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", @@ -112,13 +112,6 @@ "provide": { "ext-phpiredis": "*" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/utopia-php/abuse", - "no-api": true - } - ], "config": { "platform": { }, diff --git a/composer.lock b/composer.lock index a48735d492..335558fa9f 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": "d6519efb540aa0e096aac57f166afd76", + "content-hash": "0c23c30bba86ad84377d4d1abce0992a", "packages": [ { "name": "adhocore/jwt", @@ -3359,16 +3359,16 @@ }, { "name": "utopia-php/abuse", - "version": "dev-feat-bump-sdk-24", + "version": "1.3.1", "source": { "type": "git", - "url": "https://github.com/utopia-php/abuse", - "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764" + "url": "https://github.com/utopia-php/abuse.git", + "reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/5f1b5e2594636ac6c358b16c6dedd1ec6807f764", - "reference": "5f1b5e2594636ac6c358b16c6dedd1ec6807f764", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/00e59c89a1ac5f4ad771695e5dbee020b3c7ac44", + "reference": "00e59c89a1ac5f4ad771695e5dbee020b3c7ac44", "shasum": "" }, "require": { @@ -3391,37 +3391,23 @@ "Utopia\\Abuse\\": "src/Abuse" } }, - "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" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "A simple abuse library to manage application usage limits", "keywords": [ - "abuse", + "Abuse", "framework", "php", "upf", "utopia" ], - "time": "2026-05-20T10:54:49+00:00" + "support": { + "issues": "https://github.com/utopia-php/abuse/issues", + "source": "https://github.com/utopia-php/abuse/tree/1.3.1" + }, + "time": "2026-06-03T07:30:05+00:00" }, { "name": "utopia-php/agents", @@ -8563,17 +8549,9 @@ "time": "2026-05-27T13:05:51+00:00" } ], - "aliases": [ - { - "package": "utopia-php/abuse", - "version": "dev-feat-bump-sdk-24", - "alias": "1.3.0", - "alias_normalized": "1.3.0.0" - } - ], + "aliases": [], "minimum-stability": "dev", "stability-flags": { - "utopia-php/abuse": 20, "utopia-php/http": 5 }, "prefer-stable": true, From 2bc1fbedd7af232b97b015d7436af6b321b8b3b2 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:34:23 +0100 Subject: [PATCH 26/28] Expose project region in response model --- 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 a0256d7cbf146ca671a517e40f40c6eb256b941b Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:46:27 +0100 Subject: [PATCH 27/28] Expose project blocks and console access time --- .../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 57d21e283dfb1b6cb56251e329629d3f5b905bef Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:57:07 +0100 Subject: [PATCH 28/28] Relax migration smoke status counters 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 c4bfb585a2..6509a35de8 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -225,8 +225,8 @@ trait MigrationsBase $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); + $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; - $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); $this->assertEquals(0, $counts['error']); $this->assertGreaterThan(0, $counts['success']); }