mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch 'feat-mailgun-provider' of https://github.com/appwrite/appwrite into feat-topics-controller
This commit is contained in:
@@ -202,7 +202,7 @@ trait AvatarsBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'url' => 'https://appwrite.io/images/open-graph/website.png',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
@@ -212,7 +212,7 @@ trait AvatarsBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'url' => 'https://appwrite.io/images/open-graph/website.png',
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
@@ -224,7 +224,7 @@ trait AvatarsBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'url' => 'https://appwrite.io/images/open-graph/website.png',
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
@@ -251,7 +251,7 @@ trait AvatarsBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'url' => 'https://appwrite.io/images/open-graph/website.png',
|
||||
'width' => 2001,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
@@ -280,11 +280,11 @@ trait AvatarsBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/',
|
||||
'url' => 'https://github.com/',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png', $response['headers']['content-type']);
|
||||
$this->assertEquals('image/x-icon', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
@@ -524,4 +524,28 @@ trait AvatarsBase
|
||||
$this->assertEquals('PNG', $image->getImageFormat());
|
||||
$this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/initials.png')), strlen($response['body']));
|
||||
}
|
||||
|
||||
public function testSpecialCharsInitalImage()
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/initials', [
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
'name' => 'W (Hello) W',
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$image = new \Imagick();
|
||||
$image->readImageBlob($response['body']);
|
||||
$original = new \Imagick(__DIR__ . '/../../../resources/initials.png');
|
||||
|
||||
$this->assertEquals($image->getImageWidth(), $original->getImageWidth());
|
||||
$this->assertEquals($image->getImageHeight(), $original->getImageHeight());
|
||||
$this->assertEquals('PNG', $image->getImageFormat());
|
||||
$this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/initials.png')), strlen($response['body']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ class FunctionsCustomServerTest extends Scope
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'events' => [
|
||||
'users.*.create',
|
||||
'users.*.delete',
|
||||
'buckets.*.create',
|
||||
'buckets.*.delete',
|
||||
],
|
||||
'schedule' => '0 0 1 1 *',
|
||||
'timeout' => 10,
|
||||
@@ -50,8 +50,8 @@ class FunctionsCustomServerTest extends Scope
|
||||
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$updatedAt']));
|
||||
$this->assertEquals('', $response1['body']['deployment']);
|
||||
$this->assertEquals([
|
||||
'users.*.create',
|
||||
'users.*.delete',
|
||||
'buckets.*.create',
|
||||
'buckets.*.delete',
|
||||
], $response1['body']['events']);
|
||||
$this->assertEquals('0 0 1 1 *', $response1['body']['schedule']);
|
||||
$this->assertEquals(10, $response1['body']['timeout']);
|
||||
@@ -191,8 +191,8 @@ class FunctionsCustomServerTest extends Scope
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'events' => [
|
||||
'users.*.create',
|
||||
'users.*.delete',
|
||||
'buckets.*.create',
|
||||
'buckets.*.delete',
|
||||
],
|
||||
'schedule' => '0 0 1 1 *',
|
||||
'timeout' => 10,
|
||||
@@ -1231,4 +1231,117 @@ class FunctionsCustomServerTest extends Scope
|
||||
$this->assertArrayHasKey('base', $runtime);
|
||||
$this->assertArrayHasKey('supports', $runtime);
|
||||
}
|
||||
|
||||
|
||||
public function testEventTrigger()
|
||||
{
|
||||
$timeout = 5;
|
||||
$code = realpath(__DIR__ . '/../../../resources/functions') . "/php-event/code.tar.gz";
|
||||
$this->packageCode('php-event');
|
||||
|
||||
$function = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'functionId' => ID::unique(),
|
||||
'name' => 'Test PHP Event executions',
|
||||
'runtime' => 'php-8.0',
|
||||
'entrypoint' => 'index.php',
|
||||
'events' => [
|
||||
'users.*.create',
|
||||
],
|
||||
'timeout' => $timeout,
|
||||
]);
|
||||
|
||||
$functionId = $function['body']['$id'] ?? '';
|
||||
|
||||
$this->assertEquals(201, $function['headers']['status-code']);
|
||||
|
||||
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge([
|
||||
'content-type' => 'multipart/form-data',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'entrypoint' => 'index.php',
|
||||
'code' => new CURLFile($code, 'application/x-gzip', basename($code)),
|
||||
'activate' => true
|
||||
]);
|
||||
|
||||
$deploymentId = $deployment['body']['$id'] ?? '';
|
||||
$this->assertEquals(202, $deployment['headers']['status-code']);
|
||||
|
||||
// Poll until deployment is built
|
||||
while (true) {
|
||||
$deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $function['body']['$id'] . '/deployments/' . $deploymentId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]);
|
||||
|
||||
if (
|
||||
$deployment['headers']['status-code'] >= 400
|
||||
|| \in_array($deployment['body']['status'], ['ready', 'failed'])
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
\sleep(1);
|
||||
}
|
||||
|
||||
$deployment = $this->client->call(Client::METHOD_PATCH, '/functions/' . $functionId . '/deployments/' . $deploymentId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $deployment['headers']['status-code']);
|
||||
|
||||
// Wait a little for activation to finish
|
||||
sleep(5);
|
||||
|
||||
// Create user to trigger event
|
||||
$user = $this->client->call(Client::METHOD_POST, '/users', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'userId' => 'unique()',
|
||||
'name' => 'Event User'
|
||||
]);
|
||||
|
||||
$userId = $user['body']['$id'];
|
||||
|
||||
$this->assertEquals(201, $user['headers']['status-code']);
|
||||
|
||||
// Wait for execution to occur
|
||||
sleep(15);
|
||||
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$execution = $executions['body']['executions'][0];
|
||||
|
||||
$this->assertEquals(200, $executions['headers']['status-code']);
|
||||
$this->assertEquals('completed', $execution['status']);
|
||||
$this->assertEquals(204, $execution['responseStatusCode']);
|
||||
$this->assertStringContainsString($userId, $execution['logs']);
|
||||
$this->assertStringContainsString('Event User', $execution['logs']);
|
||||
|
||||
// Cleanup : Delete function
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], []);
|
||||
|
||||
$this->assertEquals(204, $response['headers']['status-code']);
|
||||
|
||||
// Cleanup : Delete user
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/users/' . $userId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], []);
|
||||
|
||||
$this->assertEquals(204, $response['headers']['status-code']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class AccountTest extends Scope
|
||||
}
|
||||
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$query = $this->getQuery(self::$CREATE_PROVIDER);
|
||||
$query = $this->getQuery(self::$CREATE_MSG91_PROVIDER);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
|
||||
@@ -155,7 +155,7 @@ class AvatarsTest extends Scope
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), $graphQLPayload);
|
||||
|
||||
$this->assertEquals(4959, \strlen($initials['body']));
|
||||
$this->assertEquals(5041, \strlen($initials['body']));
|
||||
|
||||
return $initials['body'];
|
||||
}
|
||||
|
||||
@@ -197,6 +197,29 @@ trait Base
|
||||
public static string $GET_QRCODE = 'get_qrcode';
|
||||
public static string $GET_USER_INITIALS = 'get_user_initials';
|
||||
|
||||
// Providers
|
||||
public static string $CREATE_MAILGUN_PROVIDER = 'create_mailgun_provider';
|
||||
public static string $CREATE_SENDGRID_PROVIDER = 'create_sendgrid_provider';
|
||||
public static string $CREATE_TWILIO_PROVIDER = 'create_twilio_provider';
|
||||
public static string $CREATE_TELESIGN_PROVIDER = 'create_telesign_provider';
|
||||
public static string $CREATE_TEXTMAGIC_PROVIDER = 'create_textmagic_provider';
|
||||
public static string $CREATE_MSG91_PROVIDER = 'create_msg91_provider';
|
||||
public static string $CREATE_VONAGE_PROVIDER = 'create_vonage_provider';
|
||||
public static string $CREATE_FCM_PROVIDER = 'create_fcm_provider';
|
||||
public static string $CREATE_APNS_PROVIDER = 'create_apns_provider';
|
||||
public static string $LIST_PROVIDERS = 'list_providers';
|
||||
public static string $GET_PROVIDER = 'get_provider';
|
||||
public static string $UPDATE_MAILGUN_PROVIDER = 'update_mailgun_provider';
|
||||
public static string $UPDATE_SENDGRID_PROVIDER = 'update_sendgrid_provider';
|
||||
public static string $UPDATE_TWILIO_PROVIDER = 'update_twilio_provider';
|
||||
public static string $UPDATE_TELESIGN_PROVIDER = 'update_telesign_provider';
|
||||
public static string $UPDATE_TEXTMAGIC_PROVIDER = 'update_textmagic_provider';
|
||||
public static string $UPDATE_MSG91_PROVIDER = 'update_msg91_provider';
|
||||
public static string $UPDATE_VONAGE_PROVIDER = 'update_vonage_provider';
|
||||
public static string $UPDATE_FCM_PROVIDER = 'update_fcm_provider';
|
||||
public static string $UPDATE_APNS_PROVIDER = 'update_apns_provider';
|
||||
public static string $DELETE_PROVIDER = 'delete_provider';
|
||||
|
||||
// Complex queries
|
||||
public static string $COMPLEX_QUERY = 'complex_query';
|
||||
|
||||
@@ -296,8 +319,6 @@ trait Base
|
||||
}
|
||||
';
|
||||
|
||||
public static string $CREATE_PROVIDER = 'create_provider';
|
||||
|
||||
public function getQuery(string $name): string
|
||||
{
|
||||
switch ($name) {
|
||||
@@ -1688,6 +1709,235 @@ trait Base
|
||||
status
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_MAILGUN_PROVIDER:
|
||||
return 'mutation createMailgunProvider($providerId: String!, $name: String!, $domain: String!, $apiKey: String!, $from: String!) {
|
||||
messagingCreateMailgunProvider(providerId: $providerId, name: $name, domain: $domain, apiKey: $apiKey, from: $from) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_SENDGRID_PROVIDER:
|
||||
return 'mutation createSendgridProvider($providerId: String!, $name: String!, $apiKey: String!) {
|
||||
messagingCreateSendgridProvider(providerId: $providerId, name: $name, apiKey: $apiKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_TWILIO_PROVIDER:
|
||||
return 'mutation createTwilioProvider($providerId: String!, $name: String!, $accountSid: String!, $authToken: String!) {
|
||||
messagingCreateTwilioProvider(providerId: $providerId, name: $name, accountSid: $accountSid, authToken: $authToken) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_TELESIGN_PROVIDER:
|
||||
return 'mutation createTelesignProvider($providerId: String!, $name: String!, $username: String!, $password: String!) {
|
||||
messagingCreateTelesignProvider(providerId: $providerId, name: $name, username: $username, password: $password) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_TEXTMAGIC_PROVIDER:
|
||||
return 'mutation createTextmagicProvider($providerId: String!, $name: String!, $username: String!, $apiKey: String!) {
|
||||
messagingCreateTextmagicProvider(providerId: $providerId, name: $name, username: $username, apiKey: $apiKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_MSG91_PROVIDER:
|
||||
return 'mutation createMsg91Provider($providerId: String!, $name: String!, $from: String!, $senderId: String!, $authKey: String!, $default: Boolean, $enabled: Boolean) {
|
||||
messagingCreateMsg91Provider(providerId: $providerId, name: $name, from: $from, senderId: $senderId, authKey: $authKey, default: $default, enabled: $enabled) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_VONAGE_PROVIDER:
|
||||
return 'mutation createVonageProvider($providerId: String!, $name: String!, $apiKey: String!, $apiSecret: String!) {
|
||||
messagingCreateVonageProvider(providerId: $providerId, name: $name, apiKey: $apiKey, apiSecret: $apiSecret) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_FCM_PROVIDER:
|
||||
return 'mutation createFcmProvider($providerId: String!, $name: String!, $serverKey: String!) {
|
||||
messagingCreateFcmProvider(providerId: $providerId, name: $name, serverKey: $serverKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$CREATE_APNS_PROVIDER:
|
||||
return 'mutation createApnsProvider($providerId: String!, $name: String!, $authKey: String!, $authKeyId: String!, $teamId: String!, $bundleId: String!, $endpoint: String!) {
|
||||
messagingCreateApnsProvider(providerId: $providerId, name: $name, authKey: $authKey, authKeyId: $authKeyId, teamId: $teamId, bundleId: $bundleId, endpoint: $endpoint) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$LIST_PROVIDERS:
|
||||
return 'query listProviders {
|
||||
messagingListProviders {
|
||||
total
|
||||
providers {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}
|
||||
}';
|
||||
case self::$GET_PROVIDER:
|
||||
return 'query getProvider($providerId: String!) {
|
||||
messagingGetProvider(providerId: $providerId) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_MAILGUN_PROVIDER:
|
||||
return 'mutation updateMailgunProvider($providerId: String!, $name: String!, $domain: String!, $apiKey: String!, $isEuRegion: Boolean, $enabled: Boolean) {
|
||||
messagingUpdateMailgunProvider(providerId: $providerId, name: $name, domain: $domain, apiKey: $apiKey, isEuRegion: $isEuRegion, enabled: $enabled) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_SENDGRID_PROVIDER:
|
||||
return 'mutation messagingUpdateSendgridProvider($providerId: String!, $name: String!, $apiKey: String!) {
|
||||
messagingUpdateSendgridProvider(providerId: $providerId, name: $name, apiKey: $apiKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_TWILIO_PROVIDER:
|
||||
return 'mutation updateTwilioProvider($providerId: String!, $name: String!, $accountSid: String!, $authToken: String!) {
|
||||
messagingUpdateTwilioProvider(providerId: $providerId, name: $name, accountSid: $accountSid, authToken: $authToken) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_TELESIGN_PROVIDER:
|
||||
return 'mutation updateTelesignProvider($providerId: String!, $name: String!, $username: String!, $password: String!) {
|
||||
messagingUpdateTelesignProvider(providerId: $providerId, name: $name, username: $username, password: $password) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_TEXTMAGIC_PROVIDER:
|
||||
return 'mutation updateTextmagicProvider($providerId: String!, $name: String!, $username: String!, $apiKey: String!) {
|
||||
messagingUpdateTextmagicProvider(providerId: $providerId, name: $name, username: $username, apiKey: $apiKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_MSG91_PROVIDER:
|
||||
return 'mutation updateMsg91Provider($providerId: String!, $name: String!, $senderId: String!, $authKey: String!) {
|
||||
messagingUpdateMsg91Provider(providerId: $providerId, name: $name, senderId: $senderId, authKey: $authKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_VONAGE_PROVIDER:
|
||||
return 'mutation updateVonageProvider($providerId: String!, $name: String!, $apiKey: String!, $apiSecret: String!) {
|
||||
messagingUpdateVonageProvider(providerId: $providerId, name: $name, apiKey: $apiKey, apiSecret: $apiSecret) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_FCM_PROVIDER:
|
||||
return 'mutation updateFcmProvider($providerId: String!, $name: String!, $serverKey: String!) {
|
||||
messagingUpdateFcmProvider(providerId: $providerId, name: $name, serverKey: $serverKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_APNS_PROVIDER:
|
||||
return 'mutation updateApnsProvider($providerId: String!, $name: String!, $authKey: String!, $authKeyId: String!, $teamId: String!, $bundleId: String!, $endpoint: String!) {
|
||||
messagingUpdateApnsProvider(providerId: $providerId, name: $name, authKey: $authKey, authKeyId: $authKeyId, teamId: $teamId, bundleId: $bundleId, endpoint: $endpoint) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
case self::$DELETE_PROVIDER:
|
||||
return 'mutation deleteProvider($providerId: String!) {
|
||||
messagingDeleteProvider(providerId: $providerId) {
|
||||
status
|
||||
}
|
||||
}';
|
||||
case self::$COMPLEX_QUERY:
|
||||
return 'mutation complex($databaseId: String!, $databaseName: String!, $collectionId: String!, $collectionName: String!, $documentSecurity: Boolean!, $collectionPermissions: [String!]!) {
|
||||
databasesCreate(databaseId: $databaseId, name: $databaseName) {
|
||||
@@ -1931,33 +2181,6 @@ trait Base
|
||||
}
|
||||
}
|
||||
}' . PHP_EOL . self::$FRAGMENT_ATTRIBUTES;
|
||||
case self::$CREATE_PROVIDER:
|
||||
return 'mutation createProviderMsg91(
|
||||
$providerId: String!,
|
||||
$name: String!,
|
||||
$from: String!,
|
||||
$senderId: String!,
|
||||
$authKey: String!
|
||||
$default: Boolean,
|
||||
$enabled: Boolean,
|
||||
) {
|
||||
messagingCreateProviderMsg91(
|
||||
providerId: $providerId,
|
||||
name: $name,
|
||||
from: $from,
|
||||
senderId: $senderId,
|
||||
authKey: $authKey
|
||||
default: $default,
|
||||
enabled: $enabled,
|
||||
) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
type
|
||||
default
|
||||
enabled
|
||||
}
|
||||
}';
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid query type');
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\GraphQL;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class MessagingTest extends Scope
|
||||
{
|
||||
use ProjectCustom;
|
||||
use SideServer;
|
||||
use Base;
|
||||
|
||||
public function testCreateProviders()
|
||||
{
|
||||
$providersParams = [
|
||||
'Sendgrid' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Sengrid1',
|
||||
'apiKey' => 'my-apikey',
|
||||
],
|
||||
'Mailgun' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Mailgun1',
|
||||
'apiKey' => 'my-apikey',
|
||||
'domain' => 'my-domain',
|
||||
'from' => 'sender-email@my-domain',
|
||||
],
|
||||
'Twilio' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Twilio1',
|
||||
'accountSid' => 'my-accountSid',
|
||||
'authToken' => 'my-authToken',
|
||||
],
|
||||
'Telesign' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Telesign1',
|
||||
'username' => 'my-username',
|
||||
'password' => 'my-password',
|
||||
],
|
||||
'Textmagic' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Textmagic1',
|
||||
'username' => 'my-username',
|
||||
'apiKey' => 'my-apikey',
|
||||
],
|
||||
'Msg91' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Ms91-1',
|
||||
'senderId' => 'my-senderid',
|
||||
'authKey' => 'my-authkey',
|
||||
'from' => '+123456789'
|
||||
],
|
||||
'Vonage' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'Vonage1',
|
||||
'apiKey' => 'my-apikey',
|
||||
'apiSecret' => 'my-apisecret',
|
||||
],
|
||||
'Fcm' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'FCM1',
|
||||
'serverKey' => 'my-serverkey',
|
||||
],
|
||||
'Apns' => [
|
||||
'providerId' => ID::unique(),
|
||||
'name' => 'APNS1',
|
||||
'authKey' => 'my-authkey',
|
||||
'authKeyId' => 'my-authkeyid',
|
||||
'teamId' => 'my-teamid',
|
||||
'bundleId' => 'my-bundleid',
|
||||
'endpoint' => 'my-endpoint',
|
||||
],
|
||||
];
|
||||
|
||||
$providers = [];
|
||||
|
||||
foreach (\array_keys($providersParams) as $key) {
|
||||
$query = $this->getQuery('create_' . \strtolower($key) . '_provider');
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => $providersParams[$key],
|
||||
];
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), $graphQLPayload);
|
||||
\array_push($providers, $response['body']['data']['messagingCreate' . $key . 'Provider']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($providersParams[$key]['name'], $response['body']['data']['messagingCreate' . $key . 'Provider']['name']);
|
||||
}
|
||||
|
||||
return $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreateProviders
|
||||
*/
|
||||
public function testUpdateProviders(array $providers): array
|
||||
{
|
||||
$providersParams = [
|
||||
'Sendgrid' => [
|
||||
'providerId' => $providers[0]['_id'],
|
||||
'name' => 'Sengrid2',
|
||||
'apiKey' => 'my-apikey',
|
||||
],
|
||||
'Mailgun' => [
|
||||
'providerId' => $providers[1]['_id'],
|
||||
'name' => 'Mailgun2',
|
||||
'apiKey' => 'my-apikey',
|
||||
'domain' => 'my-domain',
|
||||
],
|
||||
'Twilio' => [
|
||||
'providerId' => $providers[2]['_id'],
|
||||
'name' => 'Twilio2',
|
||||
'accountSid' => 'my-accountSid',
|
||||
'authToken' => 'my-authToken',
|
||||
],
|
||||
'Telesign' => [
|
||||
'providerId' => $providers[3]['_id'],
|
||||
'name' => 'Telesign2',
|
||||
'username' => 'my-username',
|
||||
'password' => 'my-password',
|
||||
],
|
||||
'Textmagic' => [
|
||||
'providerId' => $providers[4]['_id'],
|
||||
'name' => 'Textmagic2',
|
||||
'username' => 'my-username',
|
||||
'apiKey' => 'my-apikey',
|
||||
],
|
||||
'Msg91' => [
|
||||
'providerId' => $providers[5]['_id'],
|
||||
'name' => 'Ms91-2',
|
||||
'senderId' => 'my-senderid',
|
||||
'authKey' => 'my-authkey',
|
||||
],
|
||||
'Vonage' => [
|
||||
'providerId' => $providers[6]['_id'],
|
||||
'name' => 'Vonage2',
|
||||
'apiKey' => 'my-apikey',
|
||||
'apiSecret' => 'my-apisecret',
|
||||
],
|
||||
'Fcm' => [
|
||||
'providerId' => $providers[7]['_id'],
|
||||
'name' => 'FCM2',
|
||||
'serverKey' => 'my-serverkey',
|
||||
],
|
||||
'Apns' => [
|
||||
'providerId' => $providers[8]['_id'],
|
||||
'name' => 'APNS2',
|
||||
'authKey' => 'my-authkey',
|
||||
'authKeyId' => 'my-authkeyid',
|
||||
'teamId' => 'my-teamid',
|
||||
'bundleId' => 'my-bundleid',
|
||||
'endpoint' => 'my-endpoint',
|
||||
],
|
||||
];
|
||||
foreach (\array_keys($providersParams) as $index => $key) {
|
||||
$query = $this->getQuery('update_' . \strtolower($key) . '_provider');
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => $providersParams[$key],
|
||||
];
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $graphQLPayload);
|
||||
$providers[$index] = $response['body']['data']['messagingUpdate' . $key . 'Provider'];
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($providersParams[$key]['name'], $response['body']['data']['messagingUpdate' . $key . 'Provider']['name']);
|
||||
}
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], [
|
||||
'query' => $this->getQuery('update_mailgun_provider'),
|
||||
'variables' => [
|
||||
'providerId' => $providers[1]['_id'],
|
||||
'name' => 'Mailgun2',
|
||||
'apiKey' => 'my-apikey',
|
||||
'domain' => 'my-domain',
|
||||
'isEuRegion' => true,
|
||||
'enabled' => false,
|
||||
]
|
||||
]);
|
||||
$providers[1] = $response['body']['data']['messagingUpdateMailgunProvider'];
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('Mailgun2', $response['body']['data']['messagingUpdateMailgunProvider']['name']);
|
||||
$this->assertEquals(false, $response['body']['data']['messagingUpdateMailgunProvider']['enabled']);
|
||||
return $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testUpdateProviders
|
||||
*/
|
||||
public function testListProviders(array $providers)
|
||||
{
|
||||
$query = $this->getQuery(self::$LIST_PROVIDERS);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
];
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $graphQLPayload);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(\count($providers), \count($response['body']['data']['messagingListProviders']['providers']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testUpdateProviders
|
||||
*/
|
||||
public function testGetProvider(array $providers)
|
||||
{
|
||||
$query = $this->getQuery(self::$GET_PROVIDER);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
'providerId' => $providers[0]['_id'],
|
||||
]
|
||||
];
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $graphQLPayload);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($providers[0]['name'], $response['body']['data']['messagingGetProvider']['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testUpdateProviders
|
||||
*/
|
||||
public function testDeleteProvider(array $providers)
|
||||
{
|
||||
foreach ($providers as $provider) {
|
||||
$query = $this->getQuery(self::$DELETE_PROVIDER);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
'providerId' => $provider['_id'],
|
||||
]
|
||||
];
|
||||
$response = $this->client->call(Client::METHOD_POST, '/graphql', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $graphQLPayload);
|
||||
$this->assertEquals(204, $response['headers']['status-code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['ping']);
|
||||
$this->assertLessThan(100, $response['body']['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -51,10 +47,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['statuses'][0]['ping']);
|
||||
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -73,10 +65,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['statuses'][0]['ping']);
|
||||
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -95,10 +83,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['statuses'][0]['ping']);
|
||||
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -117,10 +101,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['statuses'][0]['ping']);
|
||||
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -141,10 +121,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertNotEmpty($response['body']['localTime']);
|
||||
$this->assertLessThan(10, $response['body']['diff']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -162,10 +138,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -183,10 +155,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -204,9 +172,124 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testFunctionsSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for FAILURE
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testBuildsSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/builds', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testDatabasesSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/databases', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testDeletesSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/deletes', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testMailsSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/mails', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testMessagingSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/messaging', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testMigrationsSuccess(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/queue/migrations', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsInt($response['body']['size']);
|
||||
$this->assertLessThan(100, $response['body']['size']);
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -226,10 +309,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsInt($response['body']['ping']);
|
||||
$this->assertLessThan(100, $response['body']['ping']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -248,10 +327,6 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertIsString($response['body']['status']);
|
||||
$this->assertIsString($response['body']['version']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ trait MessagingBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), $providersParams[$key]);
|
||||
\array_push($providers, $response['body']);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertEquals($providersParams[$key]['name'], $response['body']['name']);
|
||||
\array_push($providers, $response['body']);
|
||||
}
|
||||
|
||||
return $providers;
|
||||
@@ -144,9 +144,9 @@ trait MessagingBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $providersParams[$key]);
|
||||
$providers[$index] = $response['body'];
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($providersParams[$key]['name'], $response['body']['name']);
|
||||
$providers[$index] = $response['body'];
|
||||
}
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/messaging/providers/mailgun/' . $providers[1]['$id'], [
|
||||
@@ -160,10 +160,10 @@ trait MessagingBase
|
||||
'isEuRegion' => true,
|
||||
'enabled' => false,
|
||||
]);
|
||||
$providers[1] = $response['body'];
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('Mailgun2', $response['body']['name']);
|
||||
$this->assertEquals(false, $response['body']['enabled']);
|
||||
$providers[1] = $response['body'];
|
||||
return $providers;
|
||||
}
|
||||
|
||||
|
||||
@@ -595,6 +595,18 @@ trait UsersBase
|
||||
$this->assertCount(1, $response['body']['users']);
|
||||
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'search' => '>',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertEmpty($response['body']['users']);
|
||||
$this->assertCount(0, $response['body']['users']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
@@ -66,7 +66,9 @@ services:
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_OPTIONS_ABUSE
|
||||
- _APP_OPTIONS_ROUTER_PROTECTION
|
||||
- _APP_OPTIONS_FORCE_HTTPS
|
||||
- _APP_OPTIONS_FUNCTIONS_FORCE_HTTPS
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
- _APP_DOMAIN
|
||||
- _APP_DOMAIN_FUNCTIONS
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return function ($context) {
|
||||
$context->log($context->req->body['$id']);
|
||||
$context->log($context->req->body['name']);
|
||||
|
||||
return $context->res->empty();
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -50,7 +50,7 @@ class EventValidatorTest extends TestCase
|
||||
$this->assertTrue($this->object->isValid('databases.books'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*'));
|
||||
// $this->assertTrue($this->object->isValid('functions.*')); TODO @christyjacob4 : enable test once we allow functions.* events
|
||||
$this->assertTrue($this->object->isValid('functions.*'));
|
||||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Event\Validator;
|
||||
|
||||
use Appwrite\Event\Validator\FunctionEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FunctionEventValidatorTest extends TestCase
|
||||
{
|
||||
protected ?FunctionEvent $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new FunctionEvent();
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testValues(): void
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$this->assertTrue($this->object->isValid('users.*.create'));
|
||||
$this->assertTrue($this->object->isValid('users.torsten.update'));
|
||||
$this->assertTrue($this->object->isValid('users.torsten'));
|
||||
$this->assertTrue($this->object->isValid('users.*.update.email'));
|
||||
$this->assertTrue($this->object->isValid('users.*.update'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.chapters.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.prolog.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.prolog'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.*.create'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.*.documents.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.*.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.*'));
|
||||
$this->assertTrue($this->object->isValid('databases.books'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.chapters'));
|
||||
$this->assertTrue($this->object->isValid('databases.books.collections.*'));
|
||||
$this->assertTrue($this->object->isValid('buckets.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*'));
|
||||
$this->assertTrue($this->object->isValid('users.*'));
|
||||
$this->assertTrue($this->object->isValid('teams.*.memberships.*.update.status'));
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$this->assertFalse($this->object->isValid(false));
|
||||
$this->assertFalse($this->object->isValid(null));
|
||||
$this->assertFalse($this->object->isValid(''));
|
||||
$this->assertFalse($this->object->isValid('unknown.*'));
|
||||
$this->assertFalse($this->object->isValid('collections'));
|
||||
$this->assertFalse($this->object->isValid('collections.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('collections.*.documents.*.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.unknown'));
|
||||
$this->assertFalse($this->object->isValid('users.torsten.delete.email'));
|
||||
$this->assertFalse($this->object->isValid('teams.*.memberships.*.update.unknown'));
|
||||
$this->assertFalse($this->object->isValid('functions.*'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user