test: remove testConnectionFailureRegionMismatch and mock PATCH route

Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-26 12:46:47 +00:00
co-authored by abnegate
parent 5ff7e2af24
commit 339ecc418d
2 changed files with 0 additions and 98 deletions
-34
View File
@@ -279,40 +279,6 @@ Http::get('/v1/mock/github/callback')
]);
});
Http::patch('/v1/mock/projects/{projectId}/region')
->desc('Update project region (development/testing only)')
->groups(['mock'])
->label('scope', 'public')
->label('docs', false)
->label('mock', true)
->param('projectId', '', new UID(), 'Project ID.')
->param('region', '', new Text(64), 'Region value to set on the project document.')
->inject('response')
->inject('dbForPlatform')
->action(function (string $projectId, string $region, Response $response, Database $dbForPlatform) {
$isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development';
if (!$isDevelopment) {
throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED);
}
$project = $dbForPlatform->getDocument('projects', $projectId);
if ($project->isEmpty()) {
throw new Exception(Exception::PROJECT_NOT_FOUND);
}
$dbForPlatform->updateDocument(
'projects',
$project->getId(),
$project->setAttribute('region', $region)
);
$dbForPlatform->purgeCachedDocument('projects', $project->getId());
$response->json(['projectId' => $project->getId(), 'region' => $region]);
});
Http::shutdown()
->groups(['mock'])
->inject('utopia')
@@ -2,8 +2,6 @@
namespace Tests\E2E\Services\Realtime;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use WebSocket\Client as WebSocketClient;
use WebSocket\ConnectionException;
@@ -152,66 +150,4 @@ trait RealtimeBase
$client->close();
}
public function testConnectionFailureRegionMismatch(): void
{
// Create a team for the mismatched-region project
$team = $this->client->call(Client::METHOD_POST, '/teams', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => 'console',
], [
'teamId' => ID::unique(),
'name' => 'Region Mismatch Test Team',
]);
$this->assertEquals(201, $team['headers']['status-code']);
$teamId = $team['body']['$id'];
// Create a project with the default (matching) region
$project = $this->client->call(Client::METHOD_POST, '/projects', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => 'console',
], [
'projectId' => ID::unique(),
'name' => 'Region Mismatch Project',
'teamId' => $teamId,
]);
$this->assertEquals(201, $project['headers']['status-code']);
$projectId = $project['body']['$id'];
// Force a mismatched region directly in the DB via the mock endpoint (bypasses API validation)
$response = $this->client->call(Client::METHOD_PATCH, '/mock/projects/' . $projectId . '/region', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], [
'region' => 'mismatched-region',
]);
$this->assertEquals(200, $response['headers']['status-code']);
/**
* Test for FAILURE
* A project in a different region should be rejected with an access forbidden error.
*/
$client = $this->getWebsocket(['documents'], [], $projectId);
$payload = json_decode($client->receive(), true);
$this->assertArrayHasKey('type', $payload);
$this->assertArrayHasKey('data', $payload);
$this->assertEquals('error', $payload['type']);
$this->assertEquals(401, $payload['data']['code']);
$this->assertEquals(
'Project is not accessible in this region. Please make sure you are using the correct endpoint',
$payload['data']['message']
);
\usleep(250000); // 250ms
$this->expectException(ConnectionException::class); // Check if server disconnected client
$client->close();
}
}