1
0
Fork 0
mirror of synced 2024-09-09 14:21:24 +12:00

feat: uncomment tests

This commit is contained in:
Christy Jacob 2022-08-24 23:35:11 +05:30
parent 2b131eec54
commit 5d7fb56d90

View file

@ -314,138 +314,138 @@ trait AccountBase
return $data; return $data;
} }
// /** /**
// * @depends testCreateAccountSession * @depends testCreateAccountSession
// */ */
// public function testGetAccountLogs($data): array public function testGetAccountLogs($data): array
// { {
// sleep(10); sleep(10);
// $session = $data['session'] ?? ''; $session = $data['session'] ?? '';
// $sessionId = $data['sessionId'] ?? ''; $sessionId = $data['sessionId'] ?? '';
// $userId = $data['id'] ?? ''; $userId = $data['id'] ?? '';
// /** /**
// * Test for SUCCESS * Test for SUCCESS
// */ */
// $response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([ $response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
// ])); ]));
// $this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals($response['headers']['status-code'], 200);
// $this->assertIsArray($response['body']['logs']); $this->assertIsArray($response['body']['logs']);
// $this->assertNotEmpty($response['body']['logs']); $this->assertNotEmpty($response['body']['logs']);
// $this->assertCount(3, $response['body']['logs']); $this->assertCount(3, $response['body']['logs']);
// $this->assertIsNumeric($response['body']['total']); $this->assertIsNumeric($response['body']['total']);
// $this->assertContains($response['body']['logs'][1]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]); $this->assertContains($response['body']['logs'][1]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]);
// $this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP)); $this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP));
// $this->assertIsNumeric($response['body']['logs'][1]['time']); $this->assertIsNumeric($response['body']['logs'][1]['time']);
// $this->assertEquals('Windows', $response['body']['logs'][1]['osName']); $this->assertEquals('Windows', $response['body']['logs'][1]['osName']);
// $this->assertEquals('WIN', $response['body']['logs'][1]['osCode']); $this->assertEquals('WIN', $response['body']['logs'][1]['osCode']);
// $this->assertEquals('10', $response['body']['logs'][1]['osVersion']); $this->assertEquals('10', $response['body']['logs'][1]['osVersion']);
// $this->assertEquals('browser', $response['body']['logs'][1]['clientType']); $this->assertEquals('browser', $response['body']['logs'][1]['clientType']);
// $this->assertEquals('Chrome', $response['body']['logs'][1]['clientName']); $this->assertEquals('Chrome', $response['body']['logs'][1]['clientName']);
// $this->assertEquals('CH', $response['body']['logs'][1]['clientCode']); $this->assertEquals('CH', $response['body']['logs'][1]['clientCode']);
// $this->assertEquals('70.0', $response['body']['logs'][1]['clientVersion']); $this->assertEquals('70.0', $response['body']['logs'][1]['clientVersion']);
// $this->assertEquals('Blink', $response['body']['logs'][1]['clientEngine']); $this->assertEquals('Blink', $response['body']['logs'][1]['clientEngine']);
// $this->assertEquals('desktop', $response['body']['logs'][1]['deviceName']); $this->assertEquals('desktop', $response['body']['logs'][1]['deviceName']);
// $this->assertEquals('', $response['body']['logs'][1]['deviceBrand']); $this->assertEquals('', $response['body']['logs'][1]['deviceBrand']);
// $this->assertEquals('', $response['body']['logs'][1]['deviceModel']); $this->assertEquals('', $response['body']['logs'][1]['deviceModel']);
// $this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP)); $this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP));
// $this->assertEquals('--', $response['body']['logs'][1]['countryCode']); $this->assertEquals('--', $response['body']['logs'][1]['countryCode']);
// $this->assertEquals('Unknown', $response['body']['logs'][1]['countryName']); $this->assertEquals('Unknown', $response['body']['logs'][1]['countryName']);
// $this->assertContains($response['body']['logs'][2]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]); $this->assertContains($response['body']['logs'][2]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]);
// $this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP)); $this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP));
// $this->assertIsNumeric($response['body']['logs'][2]['time']); $this->assertIsNumeric($response['body']['logs'][2]['time']);
// $this->assertEquals('Windows', $response['body']['logs'][2]['osName']); $this->assertEquals('Windows', $response['body']['logs'][2]['osName']);
// $this->assertEquals('WIN', $response['body']['logs'][2]['osCode']); $this->assertEquals('WIN', $response['body']['logs'][2]['osCode']);
// $this->assertEquals('10', $response['body']['logs'][2]['osVersion']); $this->assertEquals('10', $response['body']['logs'][2]['osVersion']);
// $this->assertEquals('browser', $response['body']['logs'][2]['clientType']); $this->assertEquals('browser', $response['body']['logs'][2]['clientType']);
// $this->assertEquals('Chrome', $response['body']['logs'][2]['clientName']); $this->assertEquals('Chrome', $response['body']['logs'][2]['clientName']);
// $this->assertEquals('CH', $response['body']['logs'][2]['clientCode']); $this->assertEquals('CH', $response['body']['logs'][2]['clientCode']);
// $this->assertEquals('70.0', $response['body']['logs'][2]['clientVersion']); $this->assertEquals('70.0', $response['body']['logs'][2]['clientVersion']);
// $this->assertEquals('Blink', $response['body']['logs'][2]['clientEngine']); $this->assertEquals('Blink', $response['body']['logs'][2]['clientEngine']);
// $this->assertEquals('desktop', $response['body']['logs'][2]['deviceName']); $this->assertEquals('desktop', $response['body']['logs'][2]['deviceName']);
// $this->assertEquals('', $response['body']['logs'][2]['deviceBrand']); $this->assertEquals('', $response['body']['logs'][2]['deviceBrand']);
// $this->assertEquals('', $response['body']['logs'][2]['deviceModel']); $this->assertEquals('', $response['body']['logs'][2]['deviceModel']);
// $this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP)); $this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP));
// $this->assertEquals('--', $response['body']['logs'][2]['countryCode']); $this->assertEquals('--', $response['body']['logs'][2]['countryCode']);
// $this->assertEquals('Unknown', $response['body']['logs'][2]['countryName']); $this->assertEquals('Unknown', $response['body']['logs'][2]['countryName']);
// $responseLimit = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([ $responseLimit = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
// ]), [ ]), [
// 'limit' => 1 'limit' => 1
// ]); ]);
// $this->assertEquals($responseLimit['headers']['status-code'], 200); $this->assertEquals($responseLimit['headers']['status-code'], 200);
// $this->assertIsArray($responseLimit['body']['logs']); $this->assertIsArray($responseLimit['body']['logs']);
// $this->assertNotEmpty($responseLimit['body']['logs']); $this->assertNotEmpty($responseLimit['body']['logs']);
// $this->assertCount(1, $responseLimit['body']['logs']); $this->assertCount(1, $responseLimit['body']['logs']);
// $this->assertIsNumeric($responseLimit['body']['total']); $this->assertIsNumeric($responseLimit['body']['total']);
// $this->assertEquals($response['body']['logs'][0], $responseLimit['body']['logs'][0]); $this->assertEquals($response['body']['logs'][0], $responseLimit['body']['logs'][0]);
// $responseOffset = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([ $responseOffset = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
// ]), [ ]), [
// 'offset' => 1 'offset' => 1
// ]); ]);
// $this->assertEquals($responseOffset['headers']['status-code'], 200); $this->assertEquals($responseOffset['headers']['status-code'], 200);
// $this->assertIsArray($responseOffset['body']['logs']); $this->assertIsArray($responseOffset['body']['logs']);
// $this->assertNotEmpty($responseOffset['body']['logs']); $this->assertNotEmpty($responseOffset['body']['logs']);
// $this->assertCount(2, $responseOffset['body']['logs']); $this->assertCount(2, $responseOffset['body']['logs']);
// $this->assertIsNumeric($responseOffset['body']['total']); $this->assertIsNumeric($responseOffset['body']['total']);
// $this->assertEquals($response['body']['logs'][1], $responseOffset['body']['logs'][0]); $this->assertEquals($response['body']['logs'][1], $responseOffset['body']['logs'][0]);
// $responseLimitOffset = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([ $responseLimitOffset = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
// ]), [ ]), [
// 'limit' => 1, 'limit' => 1,
// 'offset' => 1 'offset' => 1
// ]); ]);
// $this->assertEquals($responseLimitOffset['headers']['status-code'], 200); $this->assertEquals($responseLimitOffset['headers']['status-code'], 200);
// $this->assertIsArray($responseLimitOffset['body']['logs']); $this->assertIsArray($responseLimitOffset['body']['logs']);
// $this->assertNotEmpty($responseLimitOffset['body']['logs']); $this->assertNotEmpty($responseLimitOffset['body']['logs']);
// $this->assertCount(1, $responseLimitOffset['body']['logs']); $this->assertCount(1, $responseLimitOffset['body']['logs']);
// $this->assertIsNumeric($responseLimitOffset['body']['total']); $this->assertIsNumeric($responseLimitOffset['body']['total']);
// $this->assertEquals($response['body']['logs'][1], $responseLimitOffset['body']['logs'][0]); $this->assertEquals($response['body']['logs'][1], $responseLimitOffset['body']['logs'][0]);
// /** /**
// * Test for FAILURE * Test for FAILURE
// */ */
// $response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([ $response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
// 'origin' => 'http://localhost', 'origin' => 'http://localhost',
// 'content-type' => 'application/json', 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $this->getProject()['$id'],
// ])); ]));
// $this->assertEquals($response['headers']['status-code'], 401); $this->assertEquals($response['headers']['status-code'], 401);
// return $data; return $data;
// } }
// TODO Add tests for OAuth2 session creation // TODO Add tests for OAuth2 session creation