mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge pull request #12234 from appwrite/chore-improve-project-response-tests
Chore: Improve project GET tests
This commit is contained in:
@@ -787,12 +787,240 @@ class ProjectsConsoleClientTest extends Scope
|
||||
'projectId' => ID::unique(),
|
||||
'name' => 'Project Test',
|
||||
'teamId' => $team['body']['$id'],
|
||||
'region' => System::getEnv('_APP_REGION', 'default')
|
||||
'region' => System::getEnv('_APP_REGION', 'default'),
|
||||
'description' => 'My description',
|
||||
'logo' => 'https://google.com/logo.png',
|
||||
'url' => 'https://myapp.com/',
|
||||
'legalName' => 'Legal company',
|
||||
'legalCountry' => 'Slovakia',
|
||||
'legalState' => 'Custom state',
|
||||
'legalCity' => 'Košice',
|
||||
'legalAddress' => 'Main street 32',
|
||||
'legalTaxId' => 'TAXID_123456'
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$id = $response['body']['$id'];
|
||||
|
||||
// Increase ping 3x
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
'/ping',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
], $this->getHeaders()),
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
// Configure SMTP
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_PATCH,
|
||||
'/project/smtp',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'enabled' => true,
|
||||
'senderName' => 'Custom sender',
|
||||
'senderEmail' => 'email@custom.com',
|
||||
'host' => 'maildev',
|
||||
'port' => 1025,
|
||||
'replyToEmail' => 'replyto@custom.com',
|
||||
'replyToName' => 'Reply sender',
|
||||
],
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Add mock numbers
|
||||
$response = $this->client->call(Client::METHOD_POST, '/project/mock-phones', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'number' => '+421123456789',
|
||||
'otp' => '123456'
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
// Add labels
|
||||
$response = $this->client->call(Client::METHOD_PUT, '/project/labels', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'labels' => ['custom1', 'custom2']
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Create dev keys
|
||||
$response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Custom key 1',
|
||||
'expire' => '2099-05-07 09:23:30.713',
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Custom key 2',
|
||||
'expire' => '2099-05-07 11:23:30.713'
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/project/mock-phones', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'number' => '+420987654321',
|
||||
'otp' => '654321'
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
// Setup custom values for project policies
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-duration', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'duration' => 135
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/user-limit', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'total' => 54
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-limit', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'total' => 7
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-history', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'total' => 9
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-dictionary', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => true
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-personal-data', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => true
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => true
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'userId' => true,
|
||||
'userEmail' => true,
|
||||
'userPhone' => true,
|
||||
'userName' => true,
|
||||
'userMFA' => true,
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-invalidation', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => true
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Create webhook
|
||||
$webhook = $this->client->call(Client::METHOD_POST, '/webhooks', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'webhookId' => 'unique()',
|
||||
'name' => 'Webhook Test',
|
||||
'events' => ['users.*.create', 'users.*.update.email'],
|
||||
'url' => 'https://appwrite.io',
|
||||
'tls' => true,
|
||||
'authUsername' => 'username',
|
||||
'authPassword' => 'password',
|
||||
]);
|
||||
$this->assertEquals(201, $webhook['headers']['status-code']);
|
||||
|
||||
// Create API key
|
||||
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'keyId' => ID::unique(),
|
||||
'name' => 'Key Test',
|
||||
'scopes' => ['teams.read', 'teams.write'],
|
||||
]);
|
||||
$this->assertEquals(201, $key['headers']['status-code']);
|
||||
|
||||
// Create platform
|
||||
$platform = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'platformId' => ID::unique(),
|
||||
'type' => 'web',
|
||||
'name' => 'Web App',
|
||||
'hostname' => 'localhost',
|
||||
]);
|
||||
$this->assertEquals(201, $platform['headers']['status-code']);
|
||||
|
||||
// Configure OAuth provider
|
||||
$oauth = $this->client->call(Client::METHOD_PATCH, '/project/oauth2/github', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'clientId' => 'github-client-id',
|
||||
'clientSecret' => 'github-client-secret',
|
||||
'enabled' => false,
|
||||
]);
|
||||
$this->assertEquals(200, $oauth['headers']['status-code']);
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
@@ -802,10 +1030,452 @@ class ProjectsConsoleClientTest extends Scope
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertEquals($id, $response['body']['$id']);
|
||||
$this->assertEquals('Project Test', $response['body']['name']);
|
||||
|
||||
$this->assertIsString($response['body']['$createdAt']);
|
||||
$this->assertNotEmpty($response['body']['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['$createdAt']));
|
||||
|
||||
$this->assertIsString($response['body']['$updatedAt']);
|
||||
$this->assertNotEmpty($response['body']['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['$updatedAt']));
|
||||
|
||||
$this->assertEquals('My description', $response['body']['description']);
|
||||
$this->assertEquals($team['body']['$id'], $response['body']['teamId']);
|
||||
$this->assertEquals('active', $response['body']['status']);
|
||||
$this->assertEquals('https://google.com/logo.png', $response['body']['logo']);
|
||||
$this->assertEquals('https://myapp.com/', $response['body']['url']);
|
||||
$this->assertEquals('Legal company', $response['body']['legalName']);
|
||||
$this->assertEquals('Slovakia', $response['body']['legalCountry']);
|
||||
$this->assertEquals('Custom state', $response['body']['legalState']);
|
||||
$this->assertEquals('Košice', $response['body']['legalCity']);
|
||||
$this->assertEquals('Main street 32', $response['body']['legalAddress']);
|
||||
$this->assertEquals('TAXID_123456', $response['body']['legalTaxId']);
|
||||
$this->assertEquals(135, $response['body']['authDuration']);
|
||||
$this->assertEquals(54, $response['body']['authLimit']);
|
||||
$this->assertEquals(7, $response['body']['authSessionsLimit']);
|
||||
$this->assertEquals(9, $response['body']['authPasswordHistory']);
|
||||
$this->assertTrue($response['body']['authPasswordDictionary']);
|
||||
$this->assertTrue($response['body']['authPersonalDataCheck']);
|
||||
$this->assertFalse($response['body']['authDisposableEmails']);
|
||||
$this->assertFalse($response['body']['authCanonicalEmails']);
|
||||
$this->assertFalse($response['body']['authFreeEmails']);
|
||||
$this->assertTrue($response['body']['authSessionAlerts']);
|
||||
$this->assertTrue($response['body']['authMembershipsUserName']);
|
||||
$this->assertTrue($response['body']['authMembershipsUserEmail']);
|
||||
$this->assertTrue($response['body']['authMembershipsMfa']);
|
||||
$this->assertTrue($response['body']['authMembershipsUserId']);
|
||||
$this->assertTrue($response['body']['authMembershipsUserPhone']);
|
||||
$this->assertTrue($response['body']['authInvalidateSessions']);
|
||||
$this->assertTrue($response['body']['smtpEnabled']);
|
||||
$this->assertSame('Custom sender', $response['body']['smtpSenderName']);
|
||||
$this->assertSame('email@custom.com', $response['body']['smtpSenderEmail']);
|
||||
$this->assertSame('Reply sender', $response['body']['smtpReplyToName']);
|
||||
$this->assertSame('replyto@custom.com', $response['body']['smtpReplyToEmail']);
|
||||
$this->assertSame('maildev', $response['body']['smtpHost']);
|
||||
$this->assertSame(1025, $response['body']['smtpPort']);
|
||||
$this->assertSame('', $response['body']['smtpUsername']);
|
||||
$this->assertSame('', $response['body']['smtpPassword']); // Write only
|
||||
$this->assertSame('', $response['body']['smtpSecure']);
|
||||
$this->assertSame(3, $response['body']['pingCount']);
|
||||
|
||||
$this->assertIsString($response['body']['pingedAt']);
|
||||
$this->assertNotEmpty($response['body']['pingedAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['pingedAt']));
|
||||
|
||||
$this->assertCount(2, $response['body']['labels']);
|
||||
$this->assertEquals('custom1', $response['body']['labels'][0]);
|
||||
$this->assertEquals('custom2', $response['body']['labels'][1]);
|
||||
|
||||
$this->assertCount(2, $response['body']['devKeys']);
|
||||
$this->assertEquals('Custom key 1', $response['body']['devKeys'][0]['name']);
|
||||
$this->assertEquals('Custom key 2', $response['body']['devKeys'][1]['name']);
|
||||
$this->assertEquals('2099-05-07T09:23:30.713+00:00', $response['body']['devKeys'][0]['expire']);
|
||||
$this->assertEquals('2099-05-07T11:23:30.713+00:00', $response['body']['devKeys'][1]['expire']);
|
||||
|
||||
foreach ($response['body']['devKeys'] as $devKey) {
|
||||
$this->assertIsString($devKey['$id']);
|
||||
$this->assertNotEmpty($devKey['$id']);
|
||||
|
||||
$this->assertIsString($devKey['secret']);
|
||||
$this->assertNotEmpty($devKey['secret']);
|
||||
|
||||
$this->assertIsString($devKey['accessedAt']);
|
||||
$this->assertEmpty($devKey['accessedAt']);
|
||||
|
||||
$this->assertIsString($devKey['$createdAt']);
|
||||
$this->assertNotEmpty($devKey['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($devKey['$createdAt']));
|
||||
|
||||
$this->assertIsString($devKey['$updatedAt']);
|
||||
$this->assertNotEmpty($devKey['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($devKey['$updatedAt']));
|
||||
|
||||
$this->assertIsArray($devKey['sdks']);
|
||||
$this->assertCount(0, $devKey['sdks']);
|
||||
}
|
||||
|
||||
$this->assertCount(2, $response['body']['authMockNumbers']);
|
||||
$this->assertEquals('+421123456789', $response['body']['authMockNumbers'][0]['phone']);
|
||||
$this->assertEquals('+420987654321', $response['body']['authMockNumbers'][1]['phone']);
|
||||
$this->assertEquals('123456', $response['body']['authMockNumbers'][0]['otp']);
|
||||
$this->assertEquals('654321', $response['body']['authMockNumbers'][1]['otp']);
|
||||
|
||||
foreach ($response['body']['authMockNumbers'] as $mockNumber) {
|
||||
$this->assertIsString($mockNumber['$createdAt']);
|
||||
$this->assertNotEmpty($mockNumber['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($mockNumber['$createdAt']));
|
||||
|
||||
$this->assertIsString($mockNumber['$updatedAt']);
|
||||
$this->assertNotEmpty($mockNumber['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($mockNumber['$updatedAt']));
|
||||
|
||||
$this->assertIsString($mockNumber['phone']);
|
||||
$this->assertNotEmpty($mockNumber['phone']);
|
||||
|
||||
$this->assertIsString($mockNumber['otp']);
|
||||
$this->assertNotEmpty($mockNumber['otp']);
|
||||
}
|
||||
|
||||
$this->assertIsArray($response['body']['oAuthProviders']);
|
||||
$this->assertGreaterThan(0, count($response['body']['oAuthProviders']));
|
||||
|
||||
$githubProvider = null;
|
||||
foreach ($response['body']['oAuthProviders'] as $provider) {
|
||||
$this->assertIsString($provider['key']);
|
||||
$this->assertNotEmpty($provider['key']);
|
||||
|
||||
$this->assertIsString($provider['name']);
|
||||
$this->assertIsString($provider['appId']);
|
||||
$this->assertIsString($provider['secret']);
|
||||
$this->assertIsBool($provider['enabled']);
|
||||
|
||||
if ($provider['key'] === 'github') {
|
||||
$githubProvider = $provider;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotNull($githubProvider, 'GitHub provider not found');
|
||||
$this->assertEquals('github-client-id', $githubProvider['appId']);
|
||||
$this->assertEquals('', $githubProvider['secret']); // Write only
|
||||
$this->assertEquals(false, $githubProvider['enabled']);
|
||||
|
||||
$this->assertIsArray($response['body']['platforms']);
|
||||
$this->assertCount(1, $response['body']['platforms']);
|
||||
$this->assertIsString($response['body']['platforms'][0]['$id']);
|
||||
$this->assertNotEmpty($response['body']['platforms'][0]['$id']);
|
||||
$this->assertEquals('Web App', $response['body']['platforms'][0]['name']);
|
||||
$this->assertEquals('web', $response['body']['platforms'][0]['type']);
|
||||
$this->assertEquals('localhost', $response['body']['platforms'][0]['hostname']);
|
||||
|
||||
$this->assertIsString($response['body']['platforms'][0]['$createdAt']);
|
||||
$this->assertNotEmpty($response['body']['platforms'][0]['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['platforms'][0]['$createdAt']));
|
||||
|
||||
$this->assertIsString($response['body']['platforms'][0]['$updatedAt']);
|
||||
$this->assertNotEmpty($response['body']['platforms'][0]['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['platforms'][0]['$updatedAt']));
|
||||
|
||||
$this->assertArrayHasKey('webhooks', $response['body']);
|
||||
$this->assertIsArray($response['body']['webhooks']);
|
||||
$this->assertCount(1, $response['body']['webhooks']);
|
||||
$this->assertIsString($response['body']['webhooks'][0]['$id']);
|
||||
$this->assertNotEmpty($response['body']['webhooks'][0]['$id']);
|
||||
$this->assertEquals('Webhook Test', $response['body']['webhooks'][0]['name']);
|
||||
$this->assertEquals('https://appwrite.io', $response['body']['webhooks'][0]['url']);
|
||||
$this->assertContains('users.*.create', $response['body']['webhooks'][0]['events']);
|
||||
$this->assertContains('users.*.update.email', $response['body']['webhooks'][0]['events']);
|
||||
$this->assertCount(2, $response['body']['webhooks'][0]['events']);
|
||||
$this->assertTrue($response['body']['webhooks'][0]['tls']);
|
||||
$this->assertEquals('username', $response['body']['webhooks'][0]['authUsername']);
|
||||
$this->assertEquals('password', $response['body']['webhooks'][0]['authPassword']);
|
||||
$this->assertTrue($response['body']['webhooks'][0]['enabled']);
|
||||
$this->assertIsString($response['body']['webhooks'][0]['secret']);
|
||||
$this->assertNotEmpty($response['body']['webhooks'][0]['secret']);
|
||||
$this->assertIsString($response['body']['webhooks'][0]['$createdAt']);
|
||||
$this->assertNotEmpty($response['body']['webhooks'][0]['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['webhooks'][0]['$createdAt']));
|
||||
$this->assertIsString($response['body']['webhooks'][0]['$updatedAt']);
|
||||
$this->assertNotEmpty($response['body']['webhooks'][0]['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['webhooks'][0]['$updatedAt']));
|
||||
|
||||
$this->assertArrayHasKey('keys', $response['body']);
|
||||
$this->assertIsArray($response['body']['keys']);
|
||||
$this->assertCount(1, $response['body']['keys']);
|
||||
$this->assertIsString($response['body']['keys'][0]['$id']);
|
||||
$this->assertNotEmpty($response['body']['keys'][0]['$id']);
|
||||
$this->assertEquals('Key Test', $response['body']['keys'][0]['name']);
|
||||
$this->assertContains('teams.read', $response['body']['keys'][0]['scopes']);
|
||||
$this->assertContains('teams.write', $response['body']['keys'][0]['scopes']);
|
||||
$this->assertCount(2, $response['body']['keys'][0]['scopes']);
|
||||
$this->assertNotEmpty($response['body']['keys'][0]['secret']);
|
||||
$this->assertEmpty($response['body']['keys'][0]['accessedAt']);
|
||||
$this->assertIsArray($response['body']['keys'][0]['sdks']);
|
||||
$this->assertCount(0, $response['body']['keys'][0]['sdks']);
|
||||
$this->assertIsString($response['body']['keys'][0]['$createdAt']);
|
||||
$this->assertNotEmpty($response['body']['keys'][0]['$createdAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['keys'][0]['$createdAt']));
|
||||
$this->assertIsString($response['body']['keys'][0]['$updatedAt']);
|
||||
$this->assertNotEmpty($response['body']['keys'][0]['$updatedAt']);
|
||||
$this->assertNotFalse(\strtotime($response['body']['keys'][0]['$updatedAt']));
|
||||
|
||||
$authsKeys = [
|
||||
'authEmailPassword',
|
||||
'authUsersAuthMagicURL',
|
||||
'authEmailOtp',
|
||||
'authAnonymous',
|
||||
'authInvites',
|
||||
'authJWT',
|
||||
'authPhone',
|
||||
];
|
||||
foreach ($authsKeys as $authsKey) {
|
||||
$this->assertTrue($response['body'][$authsKey], 'Auth method should be enabled: ' . $authsKey);
|
||||
}
|
||||
|
||||
$serviceKeys = [
|
||||
'serviceStatusForAccount',
|
||||
'serviceStatusForAvatars',
|
||||
'serviceStatusForDatabases',
|
||||
'serviceStatusForTablesdb',
|
||||
'serviceStatusForLocale',
|
||||
'serviceStatusForHealth',
|
||||
'serviceStatusForProject',
|
||||
'serviceStatusForStorage',
|
||||
'serviceStatusForTeams',
|
||||
'serviceStatusForUsers',
|
||||
'serviceStatusForVcs',
|
||||
'serviceStatusForSites',
|
||||
'serviceStatusForFunctions',
|
||||
'serviceStatusForProxy',
|
||||
'serviceStatusForGraphql',
|
||||
'serviceStatusForMigrations',
|
||||
'serviceStatusForMessaging',
|
||||
];
|
||||
foreach ($serviceKeys as $serviceKey) {
|
||||
$this->assertTrue($response['body'][$serviceKey], 'Service should be enabled: ' . $serviceKey);
|
||||
}
|
||||
|
||||
$protocolKeys = [
|
||||
'protocolStatusForRest',
|
||||
'protocolStatusForGraphql',
|
||||
'protocolStatusForWebsocket',
|
||||
];
|
||||
foreach ($protocolKeys as $protocolKey) {
|
||||
$this->assertTrue($response['body'][$protocolKey], 'Protocol should be enabled: ' . $protocolKey);
|
||||
}
|
||||
|
||||
// Ensure booleans can be falsy
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-dictionary', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => false
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/password-personal-data', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => false
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-alert', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => false
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/membership-privacy', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'userId' => false,
|
||||
'userEmail' => false,
|
||||
'userPhone' => false,
|
||||
'userName' => false,
|
||||
'userMFA' => false,
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/project/policies/session-invalidation', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()), [
|
||||
'enabled' => false
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Toggle auth methods, services, protocols
|
||||
|
||||
$authMethods = ['email-password', 'magic-url', 'email-otp', 'anonymous', 'invites', 'jwt', 'phone'];
|
||||
foreach ($authMethods as $authMethod) {
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_PATCH,
|
||||
'/project/auth-methods/' . $authMethod,
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'enabled' => false,
|
||||
],
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
$protocols = ['rest', 'graphql', 'websocket'];
|
||||
foreach ($protocols as $protocol) {
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_PATCH,
|
||||
'/project/protocols/' . $protocol,
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'enabled' => false,
|
||||
],
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
$services = [
|
||||
'account',
|
||||
'avatars',
|
||||
'databases',
|
||||
'tablesdb',
|
||||
'locale',
|
||||
'health',
|
||||
'project',
|
||||
'storage',
|
||||
'teams',
|
||||
'users',
|
||||
'vcs',
|
||||
'sites',
|
||||
'functions',
|
||||
'proxy',
|
||||
'graphql',
|
||||
'migrations',
|
||||
'messaging',
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_PATCH,
|
||||
'/project/services/' . $service,
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'enabled' => false,
|
||||
],
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
}
|
||||
|
||||
// Configure SMTP
|
||||
$response = $this->client->call(
|
||||
Client::METHOD_PATCH,
|
||||
'/project/smtp',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $id,
|
||||
'x-appwrite-mode' => 'admin',
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'enabled' => false,
|
||||
'host' => 'customhost.com',
|
||||
'port' => 4444,
|
||||
'username' => 'myuser',
|
||||
'password' => 'mypassword',
|
||||
'secure' => 'ssl',
|
||||
],
|
||||
);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
$this->assertFalse($response['body']['authPasswordDictionary']);
|
||||
$this->assertFalse($response['body']['authPersonalDataCheck']);
|
||||
$this->assertFalse($response['body']['authSessionAlerts']);
|
||||
$this->assertFalse($response['body']['authMembershipsUserName']);
|
||||
$this->assertFalse($response['body']['authMembershipsUserEmail']);
|
||||
$this->assertFalse($response['body']['authMembershipsMfa']);
|
||||
$this->assertFalse($response['body']['authMembershipsUserId']);
|
||||
$this->assertFalse($response['body']['authMembershipsUserPhone']);
|
||||
$this->assertFalse($response['body']['authInvalidateSessions']);
|
||||
$this->assertFalse($response['body']['smtpEnabled']);
|
||||
$this->assertSame('customhost.com', $response['body']['smtpHost']);
|
||||
$this->assertSame(4444, $response['body']['smtpPort']);
|
||||
$this->assertSame('myuser', $response['body']['smtpUsername']);
|
||||
$this->assertSame('', $response['body']['smtpPassword']); // Write only
|
||||
$this->assertSame('ssl', $response['body']['smtpSecure']);
|
||||
|
||||
$authsKeys = [
|
||||
'authEmailPassword',
|
||||
'authUsersAuthMagicURL',
|
||||
'authEmailOtp',
|
||||
'authAnonymous',
|
||||
'authInvites',
|
||||
'authJWT',
|
||||
'authPhone',
|
||||
];
|
||||
foreach ($authsKeys as $authsKey) {
|
||||
$this->assertFalse($response['body'][$authsKey], 'Auth method should be disabled: ' . $authsKey);
|
||||
}
|
||||
|
||||
$serviceKeys = [
|
||||
'serviceStatusForAccount',
|
||||
'serviceStatusForAvatars',
|
||||
'serviceStatusForDatabases',
|
||||
'serviceStatusForTablesdb',
|
||||
'serviceStatusForLocale',
|
||||
'serviceStatusForHealth',
|
||||
'serviceStatusForProject',
|
||||
'serviceStatusForStorage',
|
||||
'serviceStatusForTeams',
|
||||
'serviceStatusForUsers',
|
||||
'serviceStatusForVcs',
|
||||
'serviceStatusForSites',
|
||||
'serviceStatusForFunctions',
|
||||
'serviceStatusForProxy',
|
||||
'serviceStatusForGraphql',
|
||||
'serviceStatusForMigrations',
|
||||
'serviceStatusForMessaging',
|
||||
];
|
||||
foreach ($serviceKeys as $serviceKey) {
|
||||
$this->assertFalse($response['body'][$serviceKey], 'Service should be disabled: ' . $serviceKey);
|
||||
}
|
||||
|
||||
$protocolKeys = [
|
||||
'protocolStatusForRest',
|
||||
'protocolStatusForGraphql',
|
||||
'protocolStatusForWebsocket',
|
||||
];
|
||||
foreach ($protocolKeys as $protocolKey) {
|
||||
$this->assertFalse($response['body'][$protocolKey], 'Protocol should be disabled: ' . $protocolKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user