mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: tests.
This commit is contained in:
+299
-299
File diff suppressed because it is too large
Load Diff
+15
-15
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
@@ -34,7 +34,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -65,7 +65,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
|
||||
$this->assertFalse($database['body']['enabled']);
|
||||
|
||||
$tvShows = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$tvShows = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -83,7 +83,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test when table is disabled but can still modify tables
|
||||
*/
|
||||
$database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/' . $movies['body']['$id'], array_merge([
|
||||
$database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/grids/tables/' . $movies['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -109,7 +109,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
*/
|
||||
$databaseId = $data['databaseId'];
|
||||
|
||||
$tables = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$tables = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()));
|
||||
@@ -131,7 +131,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test when database and table are disabled but can still call get table
|
||||
*/
|
||||
$table = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $moviesCollectionId, array_merge([
|
||||
$table = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $moviesCollectionId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
@@ -156,7 +156,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test When database and table are disabled but can still call update table
|
||||
*/
|
||||
$table = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/' . $moviesCollectionId, array_merge([
|
||||
$table = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/grids/tables/' . $moviesCollectionId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -184,7 +184,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test when database and table are disabled but can still call delete table
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/tables/' . $tvShowsId, array_merge([
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/grids/tables/' . $tvShowsId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
@@ -245,7 +245,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/usage', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/usage', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()), [
|
||||
@@ -254,7 +254,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/randomCollectionId/usage', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/randomCollectionId/usage', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()), [
|
||||
@@ -266,7 +266,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/usage', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/usage', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()), [
|
||||
@@ -289,7 +289,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
@@ -298,7 +298,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -310,7 +310,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -321,7 +321,7 @@ class DatabasesConsoleClientTest extends Scope
|
||||
$this->assertIsArray($logs['body']['logs']);
|
||||
$this->assertIsNumeric($logs['body']['total']);
|
||||
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $data['moviesId'] . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
+50
-50
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
@@ -35,7 +35,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$databaseId = $database['body']['$id'];
|
||||
|
||||
// Collection aliases write to create, update, delete
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -54,7 +54,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $movies['body']['$permissions']);
|
||||
$this->assertContains(Permission::delete(Role::user($this->getUser()['$id'])), $movies['body']['$permissions']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $moviesId . '/columns/string', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $moviesId . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -69,7 +69,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(202, $response['headers']['status-code']);
|
||||
|
||||
// Document aliases write to update, delete
|
||||
$row1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $moviesId . '/rows', array_merge([
|
||||
$row1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $moviesId . '/rows', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -91,7 +91,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
*/
|
||||
|
||||
// Document does not allow create permission
|
||||
$row2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $moviesId . '/rows', array_merge([
|
||||
$row2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $moviesId . '/rows', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -133,7 +133,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
$databaseId = $database['body']['$id'];
|
||||
// Create collection
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -146,7 +146,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
// Add attribute to collection
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/permissionCheck/columns/string', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/permissionCheck/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -161,7 +161,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
sleep(2);
|
||||
|
||||
// Creating document by server, give read permission to our user + some other user
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/permissionCheck/rows', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/permissionCheck/rows', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -182,7 +182,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
// Update document
|
||||
// This is the point of this test. We should be allowed to do this action, and it should not fail on permission check
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -194,7 +194,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
// Get name of the document, should be the new one
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
@@ -203,7 +203,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
// Cleanup to prevent collision with other tests
|
||||
// Delete collection
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/tables/permissionCheck', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/grids/tables/permissionCheck', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -216,7 +216,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
sleep(2);
|
||||
|
||||
// Make sure collection has been deleted
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/permissionCheck', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/permissionCheck', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -242,7 +242,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
|
||||
// Creating collection 1
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -259,7 +259,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating collection 2
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -278,7 +278,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
\sleep(2);
|
||||
|
||||
// Creating two way relationship between collection 1 and collection 2 from collection 1
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -294,7 +294,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
\sleep(3);
|
||||
|
||||
// Update relation from collection 2 to on delete restrict
|
||||
$this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/columns/' . $table1['body']['$id'] . '/relationship', array_merge([
|
||||
$this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table2['body']['$id'] . '/columns/' . $table1['body']['$id'] . '/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -303,7 +303,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Fetching attributes after updating relation to compare
|
||||
$table1Attributes = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'], [
|
||||
$table1Attributes = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'], [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -330,7 +330,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
$databaseId = $database['body']['$id'];
|
||||
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -346,7 +346,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]
|
||||
]);
|
||||
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -364,7 +364,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
\sleep(2);
|
||||
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -382,7 +382,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(202, $relation['headers']['status-code']);
|
||||
$this->assertEquals('same_key', $relation['body']['twoWayKey']);
|
||||
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -401,7 +401,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals('Attribute with the requested key already exists. Attribute keys must be unique, try again with a different key.', $relation['body']['message']);
|
||||
|
||||
// twoWayKey is null TwoWayKey is default
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -419,7 +419,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertArrayHasKey('twoWayKey', $relation['body']);
|
||||
|
||||
// twoWayKey is null, TwoWayKey is default, second POST
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -437,7 +437,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(409, $relation['body']['code']);
|
||||
|
||||
// RelationshipManyToMany
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -456,7 +456,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertArrayHasKey('twoWayKey', $relation['body']);
|
||||
|
||||
// Second RelationshipManyToMany on Same collections
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -490,7 +490,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$databaseId = $database['body']['$id'];
|
||||
|
||||
// Creating collection 1
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -506,7 +506,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating collection 2
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -519,7 +519,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]
|
||||
]);
|
||||
|
||||
$table3 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table3 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -534,7 +534,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]
|
||||
]);
|
||||
|
||||
$table4 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table4 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -547,7 +547,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]
|
||||
]);
|
||||
|
||||
$table5 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
|
||||
$table5 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -563,7 +563,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating one to one relationship from collection 1 to colletion 2
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -576,7 +576,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating one to one relationship from collection 2 to colletion 3
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table2['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -589,7 +589,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating one to one relationship from collection 3 to colletion 4
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table3['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table3['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -602,7 +602,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating one to one relationship from collection 4 to colletion 5
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table4['body']['$id'] . '/columns/relationship', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table4['body']['$id'] . '/columns/relationship', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -614,7 +614,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'key' => $table5['body']['$id']
|
||||
]);
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/string', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -626,7 +626,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'default' => null,
|
||||
]);
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/columns/string', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table2['body']['$id'] . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -638,7 +638,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'default' => null,
|
||||
]);
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table3['body']['$id'] . '/columns/string', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table3['body']['$id'] . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -650,7 +650,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'default' => null,
|
||||
]);
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table4['body']['$id'] . '/columns/string', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table4['body']['$id'] . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -662,7 +662,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
'default' => null,
|
||||
]);
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table5['body']['$id'] . '/columns/string', array_merge([
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table5['body']['$id'] . '/columns/string', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -676,7 +676,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
\sleep(2);
|
||||
// Creating parent document with a child reference to test the permissions
|
||||
$parentDocument = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows', array_merge([
|
||||
$parentDocument = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -705,7 +705,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
$this->assertEquals(201, $parentDocument['headers']['status-code']);
|
||||
// This is the point of the test. We should not need any authorization permission to update the document with same data.
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -734,7 +734,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals($parentDocument['body'], $response['body']);
|
||||
|
||||
// Giving update permission of collection 3 to user.
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/collection3', array_merge([
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/grids/tables/collection3', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -751,7 +751,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// This is the point of this test. We should be allowed to do this action, and it should not fail on permission check
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -780,7 +780,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(11, $response['body'][$table2['body']['$id']]['collection3']['Rating']);
|
||||
|
||||
// We should not be allowed to update the document as we do not have permission for collection 2.
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -797,7 +797,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(401, $response['headers']['status-code']);
|
||||
|
||||
// We should not be allowed to update the document as we do not have permission for collection 2.
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/rows/' . $table2['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table2['body']['$id'] . '/rows/' . $table2['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -809,7 +809,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(401, $response['headers']['status-code']);
|
||||
|
||||
// Removing update permission from collection 3.
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/collection3', array_merge([
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/grids/tables/collection3', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -825,7 +825,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Giving update permission to collection 2.
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/collection2', array_merge([
|
||||
$this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/grids/tables/collection2', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -842,7 +842,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
]);
|
||||
|
||||
// Creating collection 3 new document
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $table3['body']['$id'] . '/rows', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $table3['body']['$id'] . '/rows', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
@@ -856,7 +856,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
// We should be allowed to link a new document from collection 3 to collection 2.
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
@@ -873,7 +873,7 @@ class DatabasesCustomClientTest extends Scope
|
||||
|
||||
|
||||
// We should be allowed to link and create a new document from collection 3 to collection 2.
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
+329
-329
File diff suppressed because it is too large
Load Diff
+19
-19
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
@@ -31,7 +31,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$this->assertEquals('InvalidRowDatabase', $database['body']['name']);
|
||||
|
||||
$databaseId = $database['body']['$id'];
|
||||
$publicMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$publicMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Movies',
|
||||
'permissions' => [
|
||||
@@ -41,7 +41,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
]);
|
||||
$privateMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$privateMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Movies',
|
||||
'permissions' => [],
|
||||
@@ -51,12 +51,12 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$publicTable = ['id' => $publicMovies['body']['$id']];
|
||||
$privateTable = ['id' => $privateMovies['body']['$id']];
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $publicTable['id'] . '/columns/string', $this->getServerHeader(), [
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $publicTable['id'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
]);
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $privateTable['id'] . '/columns/string', $this->getServerHeader(), [
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $privateTable['id'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
@@ -93,14 +93,14 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$privateTableId = $data['privateTableId'];
|
||||
$databaseId = $data['databaseId'];
|
||||
|
||||
$publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $publicTableId . '/rows', $this->getServerHeader(), [
|
||||
$publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $publicTableId . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
],
|
||||
'permissions' => $permissions,
|
||||
]);
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows', $this->getServerHeader(), [
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -114,11 +114,11 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$roles = Authorization::getRoles();
|
||||
Authorization::cleanRoles();
|
||||
|
||||
$publicRows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $publicTableId . '/rows', [
|
||||
$publicRows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $publicTableId . '/rows', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
$privateRows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows', [
|
||||
$privateRows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
@@ -148,7 +148,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$roles = Authorization::getRoles();
|
||||
Authorization::cleanRoles();
|
||||
|
||||
$publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $publicTableId . '/rows', [
|
||||
$publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $publicTableId . '/rows', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
@@ -161,7 +161,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$publicRowId = $publicResponse['body']['$id'];
|
||||
$this->assertEquals(201, $publicResponse['headers']['status-code']);
|
||||
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows', [
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
@@ -174,7 +174,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$this->assertEquals(401, $privateResponse['headers']['status-code']);
|
||||
|
||||
// Create a row in private collection with API key so we can test that update and delete are also not allowed
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows', $this->getServerHeader(), [
|
||||
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -184,7 +184,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$this->assertEquals(201, $privateResponse['headers']['status-code']);
|
||||
$privateRowId = $privateResponse['body']['$id'];
|
||||
|
||||
$publicRow = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $publicTableId . '/rows/' . $publicRowId, [
|
||||
$publicRow = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $publicTableId . '/rows/' . $publicRowId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
@@ -196,7 +196,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$this->assertEquals(200, $publicRow['headers']['status-code']);
|
||||
$this->assertEquals('Thor: Ragnarok', $publicRow['body']['title']);
|
||||
|
||||
$privateRow = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows/' . $privateRowId, [
|
||||
$privateRow = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows/' . $privateRowId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
@@ -207,14 +207,14 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
|
||||
$this->assertEquals(401, $privateRow['headers']['status-code']);
|
||||
|
||||
$publicRow = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/tables/' . $publicTableId . '/rows/' . $publicRowId, [
|
||||
$publicRow = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/grids/tables/' . $publicTableId . '/rows/' . $publicRowId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(204, $publicRow['headers']['status-code']);
|
||||
|
||||
$privateRow = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/tables/' . $privateTableId . '/rows/' . $privateRowId, [
|
||||
$privateRow = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/grids/tables/' . $privateTableId . '/rows/' . $privateRowId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
@@ -240,7 +240,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
$this->assertEquals('GuestPermissionsWrite', $database['body']['name']);
|
||||
|
||||
$databaseId = $database['body']['$id'];
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Movies',
|
||||
'permissions' => [
|
||||
@@ -251,7 +251,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
|
||||
$moviesId = $movies['body']['$id'];
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $moviesId . '/columns/string', $this->getServerHeader(), [
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $moviesId . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
@@ -259,7 +259,7 @@ class DatabasesPermissionsGuestTest extends Scope
|
||||
|
||||
sleep(1);
|
||||
|
||||
$row = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $moviesId . '/rows', [
|
||||
$row = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $moviesId . '/rows', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], [
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
@@ -124,7 +124,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
|
||||
$databaseId = $db['body']['$id'];
|
||||
|
||||
$public = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$public = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Movies',
|
||||
'permissions' => [
|
||||
@@ -138,14 +138,14 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
$this->assertEquals(201, $public['headers']['status-code']);
|
||||
$this->tables = ['public' => $public['body']['$id']];
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $this->tables['public'] . '/columns/string', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $this->tables['public'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
]);
|
||||
$this->assertEquals(202, $response['headers']['status-code']);
|
||||
|
||||
$private = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$private = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Private Movies',
|
||||
'permissions' => [
|
||||
@@ -159,14 +159,14 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
$this->assertEquals(201, $private['headers']['status-code']);
|
||||
$this->tables['private'] = $private['body']['$id'];
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $this->tables['private'] . '/columns/string', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $this->tables['private'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
]);
|
||||
$this->assertEquals(202, $response['headers']['status-code']);
|
||||
|
||||
$doconly = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', $this->getServerHeader(), [
|
||||
$doconly = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::unique(),
|
||||
'name' => 'Row Only Movies',
|
||||
'permissions' => [],
|
||||
@@ -175,7 +175,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
$this->assertEquals(201, $private['headers']['status-code']);
|
||||
$this->tables['doconly'] = $doconly['body']['$id'];
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $this->tables['doconly'] . '/columns/string', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $this->tables['doconly'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
@@ -202,7 +202,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
$tables = $data['tables'];
|
||||
$databaseId = $data['databaseId'];
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $tables['public'] . '/rows', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $tables['public'] . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -211,7 +211,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $tables['private'] . '/rows', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $tables['private'] . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -220,7 +220,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables/' . $tables['doconly'] . '/rows', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/grids/tables/' . $tables['doconly'] . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -232,7 +232,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
/**
|
||||
* Check "any" permission table
|
||||
*/
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $tables['public'] . '/rows', [
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $tables['public'] . '/rows', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
@@ -245,7 +245,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
/**
|
||||
* Check "users" permission table
|
||||
*/
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $tables['private'] . '/rows', [
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $tables['private'] . '/rows', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
@@ -258,7 +258,7 @@ class DatabasesPermissionsMemberTest extends Scope
|
||||
/**
|
||||
* Check "user:user1" row only permission table
|
||||
*/
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $tables['doconly'] . '/rows', [
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/grids/tables/' . $tables['doconly'] . '/rows', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Databases\Tables;
|
||||
namespace Tests\E2E\Services\Databases\Grids;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
@@ -44,7 +44,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
]);
|
||||
$this->assertEquals(201, $db['headers']['status-code']);
|
||||
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables', $this->getServerHeader(), [
|
||||
$table1 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::custom('table1'),
|
||||
'name' => 'Table 1',
|
||||
'permissions' => [
|
||||
@@ -57,13 +57,13 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
|
||||
$this->tables['table1'] = $table1['body']['$id'];
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables/' . $this->tables['table1'] . '/columns/string', $this->getServerHeader(), [
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables/' . $this->tables['table1'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
]);
|
||||
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables', $this->getServerHeader(), [
|
||||
$table2 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables', $this->getServerHeader(), [
|
||||
'tableId' => ID::custom('table2'),
|
||||
'name' => 'Table 2',
|
||||
'permissions' => [
|
||||
@@ -76,7 +76,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
|
||||
$this->tables['table2'] = $table2['body']['$id'];
|
||||
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables/' . $this->tables['table2'] . '/columns/string', $this->getServerHeader(), [
|
||||
$this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables/' . $this->tables['table2'] . '/columns/string', $this->getServerHeader(), [
|
||||
'key' => 'title',
|
||||
'size' => 256,
|
||||
'required' => true,
|
||||
@@ -140,7 +140,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
|
||||
$this->createTables($this->teams);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables/' . $this->tables['table1'] . '/rows', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables/' . $this->tables['table1'] . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Lorem',
|
||||
@@ -148,7 +148,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
]);
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables/' . $this->tables['table2'] . '/rows', $this->getServerHeader(), [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables/' . $this->tables['table2'] . '/rows', $this->getServerHeader(), [
|
||||
'rowId' => ID::unique(),
|
||||
'data' => [
|
||||
'title' => 'Ipsum',
|
||||
@@ -166,7 +166,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
*/
|
||||
public function testReadRows($user, $table, $success, $users)
|
||||
{
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $this->databaseId . '/tables/' . $table . '/rows', [
|
||||
$rows = $this->client->call(Client::METHOD_GET, '/databases/' . $this->databaseId . '/grids/tables/' . $table . '/rows', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
@@ -186,7 +186,7 @@ class DatabasesPermissionsTeamTest extends Scope
|
||||
*/
|
||||
public function testWriteRows($user, $table, $success, $users)
|
||||
{
|
||||
$rows = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/tables/' . $table . '/rows', [
|
||||
$rows = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/grids/tables/' . $table . '/rows', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
Reference in New Issue
Block a user