diff --git a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php index b9066c0272..2e1819c615 100644 --- a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php @@ -611,7 +611,7 @@ final class RealtimeConsoleClientTest extends Scope $client = $this->getWebsocket(['console'], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - ], $projectId); + ], $projectId, null, 10); $response = json_decode($client->receive(), true); @@ -915,7 +915,7 @@ final class RealtimeConsoleClientTest extends Scope $client = $this->getWebsocket(['console'], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - ], $projectId); + ], $projectId, null, 10); $response = json_decode($client->receive(), true); @@ -983,7 +983,7 @@ final class RealtimeConsoleClientTest extends Scope $client = $this->getWebsocket(['console'], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - ], 'console'); + ], 'console', null, 10); $response = json_decode($client->receive(), true); @@ -1044,7 +1044,7 @@ final class RealtimeConsoleClientTest extends Scope $client = $this->getWebsocket(['console'], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - ], $projectId); + ], $projectId, null, 30); $response = json_decode($client->receive(), true); diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index 788c008777..c623bdfd90 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -743,6 +743,30 @@ final class RealtimeCustomClientTest extends Scope $this->assertNotEmpty($response['data']['payload']); $client->close(); + + /** + * The password change and password-recovery completion above invalidate + * every existing session of this user, including the one cached in + * self::$user. Re-authenticate the SAME account (its email is now + * torsten@appwrite.io and its password 'test-recovery' after the flow + * above) and refresh only the cached session, so later tests in this + * process keep the same user $id but connect with a valid session + * instead of falling back to a guest connection. + */ + $refreshedSession = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], [ + 'email' => 'torsten@appwrite.io', + 'password' => 'test-recovery', + ]); + + $this->assertEquals(201, $refreshedSession['headers']['status-code']); + + self::$user[$projectId]['email'] = 'torsten@appwrite.io'; + self::$user[$projectId]['session'] = $refreshedSession['cookies']['a_session_' . $projectId]; + self::$user[$projectId]['sessionId'] = $refreshedSession['body']['$id']; } public function testChannelDatabase() @@ -3141,7 +3165,7 @@ final class RealtimeCustomClientTest extends Scope $client = $this->getWebsocket(['documents'], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_' . $projectId . '=' . $session - ]); + ], null, null, 10); $response = json_decode($client->receive(), true); @@ -3408,7 +3432,7 @@ final class RealtimeCustomClientTest extends Scope ], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_' . $projectId . '=' . $session, - ]); + ], null, null, 10); $connected = json_decode($legacyClient->receive(), true); $this->assertEquals('connected', $connected['type']); @@ -3502,7 +3526,7 @@ final class RealtimeCustomClientTest extends Scope ], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_' . $projectId . '=' . $session, - ]); + ], null, null, 10); $connected = json_decode($tablesClient->receive(), true); $this->assertEquals('connected', $connected['type']); @@ -3576,7 +3600,7 @@ final class RealtimeCustomClientTest extends Scope ], [ 'origin' => 'http://localhost', 'cookie' => 'a_session_' . $projectId . '=' . $session, - ]); + ], null, null, 10); $connected = json_decode($documentsClient->receive(), true); $this->assertEquals('connected', $connected['type']); diff --git a/tests/e2e/Services/Realtime/RealtimeQueryBase.php b/tests/e2e/Services/Realtime/RealtimeQueryBase.php index 5ab5c26253..233103b963 100644 --- a/tests/e2e/Services/Realtime/RealtimeQueryBase.php +++ b/tests/e2e/Services/Realtime/RealtimeQueryBase.php @@ -165,7 +165,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::equal('$id', [$targetDocumentId])->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -263,7 +263,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::notEqual('$id', [$excludedDocumentId])->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -358,7 +358,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::greaterThan('score', 50)->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -452,7 +452,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::lessThan('age', 18)->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -546,7 +546,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::greaterThanEqual('priority', 5)->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -658,7 +658,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::lessThanEqual('level', 10)->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -771,7 +771,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::isNull('description')->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -865,7 +865,7 @@ trait RealtimeQueryBase 'cookie' => 'a_session_' . $projectId . '=' . $session, ], null, [ Query::isNotNull('email')->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -976,7 +976,7 @@ trait RealtimeQueryBase Query::equal('status', ['active']), Query::greaterThan('priority', 5) ])->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -1099,7 +1099,7 @@ trait RealtimeQueryBase Query::equal('type', ['urgent']), Query::equal('type', ['critical']) ])->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client); @@ -1233,7 +1233,7 @@ trait RealtimeQueryBase ]), Query::greaterThanEqual('score', 80) ])->toString(), - ]); + ], 10); $this->assertConnectionStatusIfSupported($client);