Added first e2e test
This commit is contained in:
parent
81f4293834
commit
4420c85460
|
@ -1264,16 +1264,16 @@ $collections = [
|
|||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'array' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Timeout',
|
||||
'key' => 'timeout',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'type' => Database::SYSTEM_VAR_TYPE_NUMERIC,
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'array' => true,
|
||||
'array' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -38,6 +38,8 @@ $admins = [
|
|||
'users.write',
|
||||
'collections.read',
|
||||
'collections.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'platforms.read',
|
||||
'platforms.write',
|
||||
'keys.read',
|
||||
|
|
|
@ -11,6 +11,8 @@ return [ // List of publicly visible scopes
|
|||
'documents.write',
|
||||
'files.read',
|
||||
'files.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
// 'platforms.read',
|
||||
// 'platforms.write',
|
||||
// 'keys.read',
|
||||
|
|
|
@ -39,7 +39,7 @@ $utopia->post('/v1/functions')
|
|||
'dateUpdated' => time(),
|
||||
'name' => $name,
|
||||
'tag' => '',
|
||||
'vars' => $vars, // Should be encrypted
|
||||
'vars' => '', //$vars, // TODO Should be encrypted
|
||||
'trigger' => $trigger,
|
||||
'events' => $events,
|
||||
'schedule' => $schedule,
|
||||
|
@ -131,7 +131,7 @@ $utopia->put('/v1/functions/:functionId')
|
|||
$function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [
|
||||
'dateUpdated' => time(),
|
||||
'name' => $name,
|
||||
'vars' => $vars, //TODO Should be encrypted
|
||||
'vars' => '', //$vars, //TODO Should be encrypted
|
||||
'trigger' => $trigger,
|
||||
'events' => $events,
|
||||
'schedule' => $schedule,
|
||||
|
|
|
@ -73,6 +73,8 @@ trait ProjectCustom
|
|||
'documents.write',
|
||||
'files.read',
|
||||
'files.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
],
|
||||
|
|
203
tests/e2e/Services/Functions/FunctionsBase.php
Normal file
203
tests/e2e/Services/Functions/FunctionsBase.php
Normal file
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Functions;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
|
||||
trait FunctionsBase
|
||||
{
|
||||
|
||||
|
||||
// /**
|
||||
// * @depends testCreateTeam
|
||||
// */
|
||||
// public function testGetTeam($data):array
|
||||
// {
|
||||
// $id = (isset($data['teamUid'])) ? $data['teamUid'] : '';
|
||||
|
||||
// /**
|
||||
// * Test for SUCCESS
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams/'.$id, array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()));
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertNotEmpty($response['body']['$id']);
|
||||
// $this->assertEquals('Arsenal', $response['body']['name']);
|
||||
// $this->assertGreaterThan(-1, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['dateCreated']);
|
||||
|
||||
// /**
|
||||
// * Test for FAILURE
|
||||
// */
|
||||
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @depends testCreateTeam
|
||||
// */
|
||||
// public function testListTeams($data):array
|
||||
// {
|
||||
// /**
|
||||
// * Test for SUCCESS
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()));
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertGreaterThan(0, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertCount(3, $response['body']['teams']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'limit' => 2,
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertGreaterThan(0, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertCount(2, $response['body']['teams']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'offset' => 1,
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertGreaterThan(0, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertCount(2, $response['body']['teams']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'search' => 'Manchester',
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertGreaterThan(0, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertCount(1, $response['body']['teams']);
|
||||
// $this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'search' => 'United',
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertGreaterThan(0, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertCount(1, $response['body']['teams']);
|
||||
// $this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
|
||||
|
||||
// /**
|
||||
// * Test for FAILURE
|
||||
// */
|
||||
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// public function testUpdateTeam():array
|
||||
// {
|
||||
// /**
|
||||
// * Test for SUCCESS
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'name' => 'Demo'
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(201, $response['headers']['status-code']);
|
||||
// $this->assertNotEmpty($response['body']['$id']);
|
||||
// $this->assertEquals('Demo', $response['body']['name']);
|
||||
// $this->assertGreaterThan(-1, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['dateCreated']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'name' => 'Demo New'
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertNotEmpty($response['body']['$id']);
|
||||
// $this->assertEquals('Demo New', $response['body']['name']);
|
||||
// $this->assertGreaterThan(-1, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['dateCreated']);
|
||||
|
||||
// /**
|
||||
// * Test for FAILURE
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// public function testDeleteTeam():array
|
||||
// {
|
||||
// /**
|
||||
// * Test for SUCCESS
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()), [
|
||||
// 'name' => 'Demo'
|
||||
// ]);
|
||||
|
||||
// $teamUid = $response['body']['$id'];
|
||||
|
||||
// $this->assertEquals(201, $response['headers']['status-code']);
|
||||
// $this->assertNotEmpty($response['body']['$id']);
|
||||
// $this->assertEquals('Demo', $response['body']['name']);
|
||||
// $this->assertGreaterThan(-1, $response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['sum']);
|
||||
// $this->assertIsInt($response['body']['dateCreated']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid, array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()));
|
||||
|
||||
// $this->assertEquals(204, $response['headers']['status-code']);
|
||||
// $this->assertEmpty($response['body']);
|
||||
|
||||
// /**
|
||||
// * Test for FAILURE
|
||||
// */
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid, array_merge([
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// ], $this->getHeaders()));
|
||||
|
||||
// $this->assertEquals(404, $response['headers']['status-code']);
|
||||
|
||||
// return [];
|
||||
// }
|
||||
}
|
44
tests/e2e/Services/Functions/FunctionsCustomClientTest.php
Normal file
44
tests/e2e/Services/Functions/FunctionsCustomClientTest.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Functions;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class FunctionsConsoleClientTest extends Scope
|
||||
{
|
||||
use FunctionsBase;
|
||||
use ProjectCustom;
|
||||
use SideClient;
|
||||
|
||||
public function testCreate():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response1 = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Test',
|
||||
'vars' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
],
|
||||
'trigger' => 'event',
|
||||
'events' => [
|
||||
'account.create',
|
||||
'account.delete',
|
||||
],
|
||||
'schedule' => '* * * * *',
|
||||
'timeout' => 10,
|
||||
]);
|
||||
|
||||
$this->assertEquals(401, $response1['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
65
tests/e2e/Services/Functions/FunctionsCustomServerTest.php
Normal file
65
tests/e2e/Services/Functions/FunctionsCustomServerTest.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Functions;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
|
||||
class FunctionsConsoleServerTest extends Scope
|
||||
{
|
||||
use FunctionsBase;
|
||||
use ProjectCustom;
|
||||
use SideServer;
|
||||
|
||||
public function testCreate():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response1 = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'name' => 'Test',
|
||||
'vars' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
],
|
||||
'trigger' => 'event',
|
||||
'events' => [
|
||||
'account.create',
|
||||
'account.delete',
|
||||
],
|
||||
'schedule' => '* * * * *',
|
||||
'timeout' => 10,
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response1['headers']['status-code']);
|
||||
$this->assertNotEmpty($response1['body']['$id']);
|
||||
$this->assertEquals('Test', $response1['body']['name']);
|
||||
$this->assertIsInt($response1['body']['dateCreated']);
|
||||
$this->assertIsInt($response1['body']['dateUpdated']);
|
||||
$this->assertEquals('', $response1['body']['tag']);
|
||||
// $this->assertEquals([
|
||||
// 'key1' => 'value1',
|
||||
// 'key2' => 'value2',
|
||||
// 'key3' => 'value3',
|
||||
// ], $response1['body']['vars']);
|
||||
$this->assertEquals('event', $response1['body']['trigger']);
|
||||
$this->assertEquals([
|
||||
'account.create',
|
||||
'account.delete',
|
||||
], $response1['body']['events']);
|
||||
$this->assertEquals('* * * * *', $response1['body']['schedule']);
|
||||
$this->assertEquals(10, $response1['body']['timeout']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue