update tests
This commit is contained in:
parent
45cb05bb31
commit
67ae70ed69
3 changed files with 324 additions and 161 deletions
|
@ -305,7 +305,10 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||||
|
|
||||||
$server->send(
|
$server->send(
|
||||||
$receivers,
|
$receivers,
|
||||||
json_encode($event['data'])
|
json_encode([
|
||||||
|
'type' => 'event',
|
||||||
|
'data' => $event['data']
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (($num = count($receivers)) > 0) {
|
if (($num = count($receivers)) > 0) {
|
||||||
|
@ -421,8 +424,11 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||||
$stats->incr($project->getId(), 'connectionsTotal');
|
$stats->incr($project->getId(), 'connectionsTotal');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$response = [
|
$response = [
|
||||||
|
'type' => 'error',
|
||||||
|
'data' => [
|
||||||
'code' => $th->getCode(),
|
'code' => $th->getCode(),
|
||||||
'message' => $th->getMessage()
|
'message' => $th->getMessage()
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$server->send([$connection], json_encode($response));
|
$server->send([$connection], json_encode($response));
|
||||||
|
@ -504,6 +510,14 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re
|
||||||
$channels = Realtime::convertChannels(array_flip($realtime->connections[$connection]['channels']), $user->getId());
|
$channels = Realtime::convertChannels(array_flip($realtime->connections[$connection]['channels']), $user->getId());
|
||||||
$realtime->subscribe($realtime->connections[$connection]['projectId'], $connection, $roles, $channels);
|
$realtime->subscribe($realtime->connections[$connection]['projectId'], $connection, $roles, $channels);
|
||||||
|
|
||||||
|
$server->send([$connection], json_encode([
|
||||||
|
'type' => 'response',
|
||||||
|
'data' => [
|
||||||
|
'to' => 'authentication',
|
||||||
|
'success' => true
|
||||||
|
]
|
||||||
|
]));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -512,8 +526,11 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$response = [
|
$response = [
|
||||||
|
'type' => 'error',
|
||||||
|
'data' => [
|
||||||
'code' => $th->getCode(),
|
'code' => $th->getCode(),
|
||||||
'message' => $th->getMessage()
|
'message' => $th->getMessage()
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$server->send([$connection], json_encode($response));
|
$server->send([$connection], json_encode($response));
|
||||||
|
|
|
@ -42,15 +42,23 @@ trait RealtimeBase
|
||||||
*/
|
*/
|
||||||
$client = $this->getWebsocket(['documents'], ['origin' => 'http://appwrite.unknown']);
|
$client = $this->getWebsocket(['documents'], ['origin' => 'http://appwrite.unknown']);
|
||||||
$payload = json_decode($client->receive(), true);
|
$payload = json_decode($client->receive(), true);
|
||||||
$this->assertEquals(1008, $payload['code']);
|
|
||||||
$this->assertEquals('Invalid Origin. Register your new client (appwrite.unknown) as a new Web platform on your project console dashboard', $payload['message']);
|
$this->assertArrayHasKey('type', $payload);
|
||||||
|
$this->assertArrayHasKey('data', $payload);
|
||||||
|
$this->assertEquals('error', $payload['type']);
|
||||||
|
$this->assertEquals(1008, $payload['data']['code']);
|
||||||
|
$this->assertEquals('Invalid Origin. Register your new client (appwrite.unknown) as a new Web platform on your project console dashboard', $payload['data']['message']);
|
||||||
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
$client = $this->getWebsocket();
|
$client = $this->getWebsocket();
|
||||||
$payload = json_decode($client->receive(), true);
|
$payload = json_decode($client->receive(), true);
|
||||||
$this->assertEquals(1008, $payload['code']);
|
|
||||||
$this->assertEquals('Missing channels', $payload['message']);
|
$this->assertArrayHasKey('type', $payload);
|
||||||
|
$this->assertArrayHasKey('data', $payload);
|
||||||
|
$this->assertEquals('error', $payload['type']);
|
||||||
|
$this->assertEquals(1008, $payload['data']['code']);
|
||||||
|
$this->assertEquals('Missing channels', $payload['data']['message']);
|
||||||
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
|
@ -60,8 +68,12 @@ trait RealtimeBase
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$payload = json_decode($client->receive(), true);
|
$payload = json_decode($client->receive(), true);
|
||||||
$this->assertEquals(1008, $payload['code']);
|
|
||||||
$this->assertEquals('Missing or unknown project ID', $payload['message']);
|
$this->assertArrayHasKey('type', $payload);
|
||||||
|
$this->assertArrayHasKey('data', $payload);
|
||||||
|
$this->assertEquals('error', $payload['type']);
|
||||||
|
$this->assertEquals(1008, $payload['data']['code']);
|
||||||
|
$this->assertEquals('Missing or unknown project ID', $payload['data']['message']);
|
||||||
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
|
@ -71,8 +83,12 @@ trait RealtimeBase
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$payload = json_decode($client->receive(), true);
|
$payload = json_decode($client->receive(), true);
|
||||||
$this->assertEquals(1008, $payload['code']);
|
|
||||||
$this->assertEquals('Missing or unknown project ID', $payload['message']);
|
$this->assertArrayHasKey('type', $payload);
|
||||||
|
$this->assertArrayHasKey('data', $payload);
|
||||||
|
$this->assertEquals('error', $payload['type']);
|
||||||
|
$this->assertEquals(1008, $payload['data']['code']);
|
||||||
|
$this->assertEquals('Missing or unknown project ID', $payload['data']['message']);
|
||||||
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
$this->expectException(ConnectionException::class); // Check if server disconnnected client
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
@ -95,14 +111,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$client = $this->getWebsocket(['account'], $headers);
|
$client = $this->getWebsocket(['account'], $headers);
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
$this->assertCount(1, $response);
|
$this->assertCount(2, $response);
|
||||||
|
$this->assertArrayHasKey('account', $response);
|
||||||
$this->assertArrayHasKey('account.' . $userId, $response);
|
$this->assertArrayHasKey('account.' . $userId, $response);
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
$client = $this->getWebsocket(['account', 'documents', 'account.123'], $headers);
|
$client = $this->getWebsocket(['account', 'documents', 'account.123'], $headers);
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
$this->assertCount(2, $response);
|
$this->assertCount(3, $response);
|
||||||
$this->assertArrayHasKey('documents', $response);
|
$this->assertArrayHasKey('documents', $response);
|
||||||
|
$this->assertArrayHasKey('account', $response);
|
||||||
$this->assertArrayHasKey('account.' . $userId, $response);
|
$this->assertArrayHasKey('account.' . $userId, $response);
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
|
@ -119,9 +137,11 @@ trait RealtimeBase
|
||||||
'documents.1',
|
'documents.1',
|
||||||
'documents.2',
|
'documents.2',
|
||||||
], $headers);
|
], $headers);
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(11, $response);
|
$this->assertCount(12, $response);
|
||||||
|
$this->assertArrayHasKey('account', $response);
|
||||||
$this->assertArrayHasKey('account.' . $userId, $response);
|
$this->assertArrayHasKey('account.' . $userId, $response);
|
||||||
$this->assertArrayHasKey('files', $response);
|
$this->assertArrayHasKey('files', $response);
|
||||||
$this->assertArrayHasKey('files.1', $response);
|
$this->assertArrayHasKey('files.1', $response);
|
||||||
|
@ -136,6 +156,40 @@ trait RealtimeBase
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAuthenticateMessage()
|
||||||
|
{
|
||||||
|
$user = $this->getUser();
|
||||||
|
$userId = $user['$id'] ?? '';
|
||||||
|
$session = $user['session'] ?? '';
|
||||||
|
$projectId = $this->getProject()['$id'];
|
||||||
|
|
||||||
|
$client = $this->getWebsocket(['account'], [
|
||||||
|
'origin' => 'http://localhost'
|
||||||
|
]);
|
||||||
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
|
$this->assertCount(1, $response);
|
||||||
|
$this->assertArrayHasKey('account', $response);
|
||||||
|
|
||||||
|
$client->send(\json_encode([
|
||||||
|
'type' => 'authentication',
|
||||||
|
'data' => [
|
||||||
|
'session' => $session
|
||||||
|
]
|
||||||
|
]));
|
||||||
|
|
||||||
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('type', $response);
|
||||||
|
$this->assertArrayHasKey('data', $response);
|
||||||
|
$this->assertEquals('response', $response['type']);
|
||||||
|
$this->assertNotEmpty($response['data']);
|
||||||
|
$this->assertEquals('authentication', $response['data']['to']);
|
||||||
|
$this->assertTrue($response['data']['success']);
|
||||||
|
|
||||||
|
$client->close();
|
||||||
|
}
|
||||||
|
|
||||||
public function testChannelAccount()
|
public function testChannelAccount()
|
||||||
{
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
@ -148,7 +202,9 @@ trait RealtimeBase
|
||||||
'cookie' => 'a_session_'.$projectId.'=' . $session
|
'cookie' => 'a_session_'.$projectId.'=' . $session
|
||||||
]);
|
]);
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
$this->assertCount(1, $response);
|
|
||||||
|
$this->assertCount(2, $response);
|
||||||
|
$this->assertArrayHasKey('account', $response);
|
||||||
$this->assertArrayHasKey('account.' . $userId, $response);
|
$this->assertArrayHasKey('account.' . $userId, $response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,14 +223,18 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.update.name', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.update.name', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$this->assertEquals($name, $response['payload']['name']);
|
$this->assertEquals($name, $response['data']['payload']['name']);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,14 +252,18 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.update.password', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.update.password', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$this->assertEquals($name, $response['payload']['name']);
|
$this->assertEquals($name, $response['data']['payload']['name']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Account Email Update
|
* Test Account Email Update
|
||||||
|
@ -216,14 +280,18 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.update.email', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.update.email', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$this->assertEquals('torsten@appwrite.io', $response['payload']['email']);
|
$this->assertEquals('torsten@appwrite.io', $response['data']['payload']['email']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Account Verification Create
|
* Test Account Verification Create
|
||||||
|
@ -239,11 +307,15 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.verification.create', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.verification.create', $response['data']['event']);
|
||||||
|
|
||||||
$lastEmail = $this->getLastEmail();
|
$lastEmail = $this->getLastEmail();
|
||||||
$verification = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
$verification = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
||||||
|
@ -263,11 +335,15 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.verification.update', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.verification.update', $response['data']['event']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Acoount Prefs Update
|
* Test Acoount Prefs Update
|
||||||
|
@ -286,12 +362,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.update.prefs', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.update.prefs', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Account Session Create
|
* Test Account Session Create
|
||||||
|
@ -310,12 +390,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.sessions.create', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.sessions.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Account Session Delete
|
* Test Account Session Delete
|
||||||
|
@ -329,12 +413,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.sessions.delete', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.sessions.delete', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Account Create Recovery
|
* Test Account Create Recovery
|
||||||
|
@ -353,12 +441,16 @@ trait RealtimeBase
|
||||||
$lastEmail = $this->getLastEmail();
|
$lastEmail = $this->getLastEmail();
|
||||||
$recovery = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
$recovery = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.recovery.create', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.recovery.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
|
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
|
@ -373,12 +465,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('account', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('account.' . $userId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('account.recovery.update', $response['event']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertContains('account', $response['data']['channels']);
|
||||||
|
$this->assertContains('account.' . $userId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('account.recovery.update', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
@ -394,6 +490,7 @@ trait RealtimeBase
|
||||||
'cookie' => 'a_session_'.$projectId.'=' . $session
|
'cookie' => 'a_session_'.$projectId.'=' . $session
|
||||||
]);
|
]);
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertCount(2, $response);
|
$this->assertCount(2, $response);
|
||||||
$this->assertArrayHasKey('documents', $response);
|
$this->assertArrayHasKey('documents', $response);
|
||||||
$this->assertArrayHasKey('collections', $response);
|
$this->assertArrayHasKey('collections', $response);
|
||||||
|
@ -431,12 +528,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('collections', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('collections.' . $actors['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('database.collections.create', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('collections', $response['data']['channels']);
|
||||||
|
$this->assertContains('collections.' . $actors['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertEquals('database.collections.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$data = ['actorsId' => $actors['body']['$id']];
|
$data = ['actorsId' => $actors['body']['$id']];
|
||||||
|
|
||||||
|
@ -457,13 +558,17 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(3, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('documents', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('documents.' . $document['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertContains('collections.' . $actors['body']['$id'] . '.documents', $response['channels']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertEquals('database.documents.create', $response['event']);
|
$this->assertCount(3, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertContains('documents', $response['data']['channels']);
|
||||||
|
$this->assertContains('documents.' . $document['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertContains('collections.' . $actors['body']['$id'] . '.documents', $response['data']['channels']);
|
||||||
|
$this->assertEquals('database.documents.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$data['documentId'] = $document['body']['$id'];
|
$data['documentId'] = $document['body']['$id'];
|
||||||
|
|
||||||
|
@ -484,16 +589,20 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(3, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('documents', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('documents.' . $data['documentId'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertContains('collections.' . $data['actorsId'] . '.documents', $response['channels']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertEquals('database.documents.update', $response['event']);
|
$this->assertCount(3, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertContains('documents', $response['data']['channels']);
|
||||||
|
$this->assertContains('documents.' . $data['documentId'], $response['data']['channels']);
|
||||||
|
$this->assertContains('collections.' . $data['actorsId'] . '.documents', $response['data']['channels']);
|
||||||
|
$this->assertEquals('database.documents.update', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$this->assertEquals($response['payload']['firstName'], 'Chris1');
|
$this->assertEquals($response['data']['payload']['firstName'], 'Chris1');
|
||||||
$this->assertEquals($response['payload']['lastName'], 'Evans2');
|
$this->assertEquals($response['data']['payload']['lastName'], 'Evans2');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Document Delete
|
* Test Document Delete
|
||||||
|
@ -520,13 +629,17 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(3, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('documents', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('documents.' . $document['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertContains('collections.' . $data['actorsId'] . '.documents', $response['channels']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertEquals('database.documents.delete', $response['event']);
|
$this->assertCount(3, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertContains('documents', $response['data']['channels']);
|
||||||
|
$this->assertContains('documents.' . $document['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertContains('collections.' . $data['actorsId'] . '.documents', $response['data']['channels']);
|
||||||
|
$this->assertEquals('database.documents.delete', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
@ -560,12 +673,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('files', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('files.' . $file['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('storage.files.create', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('files', $response['data']['channels']);
|
||||||
|
$this->assertContains('files.' . $file['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertEquals('storage.files.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$data = ['fileId' => $file['body']['$id']];
|
$data = ['fileId' => $file['body']['$id']];
|
||||||
|
|
||||||
|
@ -582,12 +699,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('files', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('files.' . $file['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('storage.files.update', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('files', $response['data']['channels']);
|
||||||
|
$this->assertContains('files.' . $file['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertEquals('storage.files.update', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test File Delete
|
* Test File Delete
|
||||||
|
@ -599,12 +720,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('files', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('files.' . $file['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('storage.files.delete', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('files', $response['data']['channels']);
|
||||||
|
$this->assertContains('files.' . $file['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertEquals('storage.files.delete', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
@ -678,21 +803,29 @@ trait RealtimeBase
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
$responseUpdate = json_decode($client->receive(), true);
|
$responseUpdate = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(3, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('executions', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('executions.' . $execution['body']['$id'], $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertContains('functions.' . $execution['body']['functionId'], $response['channels']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertEquals('functions.executions.create', $response['event']);
|
$this->assertCount(3, $response['data']['channels']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertContains('executions', $response['data']['channels']);
|
||||||
|
$this->assertContains('executions.' . $execution['body']['$id'], $response['data']['channels']);
|
||||||
|
$this->assertContains('functions.' . $execution['body']['functionId'], $response['data']['channels']);
|
||||||
|
$this->assertEquals('functions.executions.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $responseUpdate);
|
$this->assertArrayHasKey('type', $responseUpdate);
|
||||||
$this->assertCount(3, $responseUpdate['channels']);
|
$this->assertArrayHasKey('data', $responseUpdate);
|
||||||
$this->assertContains('executions', $responseUpdate['channels']);
|
$this->assertEquals('event', $responseUpdate['type']);
|
||||||
$this->assertContains('executions.' . $execution['body']['$id'], $responseUpdate['channels']);
|
$this->assertNotEmpty($responseUpdate['data']);
|
||||||
$this->assertContains('functions.' . $execution['body']['functionId'], $responseUpdate['channels']);
|
$this->assertArrayHasKey('timestamp', $responseUpdate['data']);
|
||||||
$this->assertEquals('functions.executions.update', $responseUpdate['event']);
|
$this->assertCount(3, $responseUpdate['data']['channels']);
|
||||||
$this->assertNotEmpty($responseUpdate['payload']);
|
$this->assertContains('executions', $responseUpdate['data']['channels']);
|
||||||
|
$this->assertContains('executions.' . $execution['body']['$id'], $responseUpdate['data']['channels']);
|
||||||
|
$this->assertContains('functions.' . $execution['body']['functionId'], $responseUpdate['data']['channels']);
|
||||||
|
$this->assertEquals('functions.executions.update', $responseUpdate['data']['event']);
|
||||||
|
$this->assertNotEmpty($responseUpdate['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
@ -730,12 +863,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('teams', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('teams.' . $teamId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('teams.create', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('teams', $response['data']['channels']);
|
||||||
|
$this->assertContains('teams.' . $teamId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('teams.create', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Team Update
|
* Test Team Update
|
||||||
|
@ -752,12 +889,16 @@ trait RealtimeBase
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('teams', $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertContains('teams.' . $teamId, $response['channels']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertEquals('teams.update', $response['event']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('teams', $response['data']['channels']);
|
||||||
|
$this->assertContains('teams.' . $teamId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('teams.update', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
|
@ -805,12 +946,17 @@ trait RealtimeBase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = json_decode($client->receive(), true);
|
$response = json_decode($client->receive(), true);
|
||||||
$this->assertArrayHasKey('timestamp', $response);
|
|
||||||
$this->assertCount(2, $response['channels']);
|
$this->assertArrayHasKey('type', $response);
|
||||||
$this->assertContains('memberships', $response['channels']);
|
$this->assertArrayHasKey('data', $response);
|
||||||
$this->assertContains('memberships.' . $membershipId, $response['channels']);
|
$this->assertEquals('event', $response['type']);
|
||||||
$this->assertEquals('teams.memberships.update', $response['event']);
|
$this->assertNotEmpty($response['data']);
|
||||||
$this->assertNotEmpty($response['payload']);
|
$this->assertArrayHasKey('timestamp', $response['data']);
|
||||||
|
$this->assertCount(2, $response['data']['channels']);
|
||||||
|
$this->assertContains('memberships', $response['data']['channels']);
|
||||||
|
$this->assertContains('memberships.' . $membershipId, $response['data']['channels']);
|
||||||
|
$this->assertEquals('teams.memberships.update', $response['data']['event']);
|
||||||
|
$this->assertNotEmpty($response['data']['payload']);
|
||||||
|
|
||||||
$client->close();
|
$client->close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,11 @@ class MessagingTest extends TestCase
|
||||||
];
|
];
|
||||||
|
|
||||||
$channels = Realtime::convertChannels($channels, $user->getId());
|
$channels = Realtime::convertChannels($channels, $user->getId());
|
||||||
$this->assertCount(3, $channels);
|
$this->assertCount(4, $channels);
|
||||||
$this->assertArrayHasKey('files', $channels);
|
$this->assertArrayHasKey('files', $channels);
|
||||||
$this->assertArrayHasKey('documents', $channels);
|
$this->assertArrayHasKey('documents', $channels);
|
||||||
$this->assertArrayHasKey('documents.789', $channels);
|
$this->assertArrayHasKey('documents.789', $channels);
|
||||||
$this->assertArrayNotHasKey('account', $channels);
|
$this->assertArrayHasKey('account', $channels);
|
||||||
$this->assertArrayNotHasKey('account.456', $channels);
|
$this->assertArrayNotHasKey('account.456', $channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,12 +187,12 @@ class MessagingTest extends TestCase
|
||||||
|
|
||||||
$channels = Realtime::convertChannels($channels, $user->getId());
|
$channels = Realtime::convertChannels($channels, $user->getId());
|
||||||
|
|
||||||
$this->assertCount(4, $channels);
|
$this->assertCount(5, $channels);
|
||||||
$this->assertArrayHasKey('files', $channels);
|
$this->assertArrayHasKey('files', $channels);
|
||||||
$this->assertArrayHasKey('documents', $channels);
|
$this->assertArrayHasKey('documents', $channels);
|
||||||
$this->assertArrayHasKey('documents.789', $channels);
|
$this->assertArrayHasKey('documents.789', $channels);
|
||||||
$this->assertArrayHasKey('account.123', $channels);
|
$this->assertArrayHasKey('account.123', $channels);
|
||||||
$this->assertArrayNotHasKey('account', $channels);
|
$this->assertArrayHasKey('account', $channels);
|
||||||
$this->assertArrayNotHasKey('account.456', $channels);
|
$this->assertArrayNotHasKey('account.456', $channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue