diff --git a/tests/e2e/Services/Project/ProjectConsoleClientTest.php b/tests/e2e/Services/Project/ProjectConsoleClientTest.php index 0ba69c21b6..389e4d800a 100644 --- a/tests/e2e/Services/Project/ProjectConsoleClientTest.php +++ b/tests/e2e/Services/Project/ProjectConsoleClientTest.php @@ -51,6 +51,85 @@ class ProjectConsoleClientTest extends Scope $this->assertSame(404, $getProject['headers']['status-code']); } + public function testGetProject(): void + { + $team = $this->createTeam('Get Project Team'); + $project = $this->createProject($team['body']['$id'], 'Get Project'); + + $response = $this->client->call(Client::METHOD_GET, '/project', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $project['body']['$id'], + ], $this->getHeaders())); + + $this->assertSame(200, $response['headers']['status-code']); + $this->assertSame($project['body']['$id'], $response['body']['$id']); + $this->assertSame('Get Project', $response['body']['name']); + $this->assertSame($team['body']['$id'], $response['body']['teamId']); + $this->assertSame('active', $response['body']['status']); + + // Auth methods + $this->assertIsArray($response['body']['authMethods']); + $this->assertNotEmpty($response['body']['authMethods']); + foreach ($response['body']['authMethods'] as $authMethod) { + $this->assertArrayHasKey('$id', $authMethod); + $this->assertArrayHasKey('enabled', $authMethod); + $this->assertIsBool($authMethod['enabled']); + } + + // Services + $this->assertIsArray($response['body']['services']); + $this->assertNotEmpty($response['body']['services']); + foreach ($response['body']['services'] as $service) { + $this->assertArrayHasKey('$id', $service); + $this->assertArrayHasKey('enabled', $service); + $this->assertIsBool($service['enabled']); + } + + // Protocols + $this->assertIsArray($response['body']['protocols']); + $this->assertNotEmpty($response['body']['protocols']); + foreach ($response['body']['protocols'] as $protocol) { + $this->assertArrayHasKey('$id', $protocol); + $this->assertArrayHasKey('enabled', $protocol); + $this->assertIsBool($protocol['enabled']); + } + + // SMTP defaults + $this->assertFalse($response['body']['smtpEnabled']); + $this->assertSame('', $response['body']['smtpSenderEmail']); + $this->assertSame('', $response['body']['smtpSenderName']); + $this->assertSame('', $response['body']['smtpReplyToEmail']); + $this->assertSame('', $response['body']['smtpReplyToName']); + $this->assertSame('', $response['body']['smtpHost']); + $this->assertSame('', $response['body']['smtpPort']); + $this->assertSame('', $response['body']['smtpUsername']); + $this->assertSame('', $response['body']['smtpPassword']); + $this->assertSame('', $response['body']['smtpSecure']); + + // Other fields + $this->assertIsArray($response['body']['labels']); + $this->assertIsArray($response['body']['devKeys']); + $this->assertSame(0, $response['body']['pingCount']); + + // Ensure old flattened fields are not present + $this->assertArrayNotHasKey('description', $response['body']); + $this->assertArrayNotHasKey('logo', $response['body']); + $this->assertArrayNotHasKey('url', $response['body']); + $this->assertArrayNotHasKey('authDuration', $response['body']); + $this->assertArrayNotHasKey('authLimit', $response['body']); + $this->assertArrayNotHasKey('authSessionsLimit', $response['body']); + $this->assertArrayNotHasKey('authPasswordHistory', $response['body']); + $this->assertArrayNotHasKey('authPasswordDictionary', $response['body']); + $this->assertArrayNotHasKey('authPersonalDataCheck', $response['body']); + $this->assertArrayNotHasKey('authDisposableEmails', $response['body']); + $this->assertArrayNotHasKey('authCanonicalEmails', $response['body']); + $this->assertArrayNotHasKey('authFreeEmails', $response['body']); + $this->assertArrayNotHasKey('oAuthProviders', $response['body']); + $this->assertArrayNotHasKey('platforms', $response['body']); + $this->assertArrayNotHasKey('webhooks', $response['body']); + $this->assertArrayNotHasKey('keys', $response['body']); + } + protected function createTeam(string $name): array { $response = $this->client->call(Client::METHOD_POST, '/teams', $this->getConsoleSessionHeaders(), [