1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Fixed storage tests

This commit is contained in:
Eldad Fux 2021-05-04 01:20:40 +03:00
parent d020b62051
commit 507e0327e3
3 changed files with 21 additions and 18 deletions

View file

@ -14,8 +14,6 @@ use Appwrite\Database\Database;
use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Network\Validator\Origin;
use Utopia\Storage\Device\Local;
use Utopia\Storage\Storage;
use Appwrite\Utopia\Response\Filters\V06;
use Utopia\CLI\Console;
use Utopia\Database\Validator\Authorization as Authorization2;

View file

@ -16,12 +16,19 @@ class File extends Model
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('$permissions', [
'type' => Response::MODEL_PERMISSIONS,
'description' => 'File permissions.',
'default' => new \stdClass,
'example' => new \stdClass,
'array' => false,
->addRule('$read', [
'type' => self::TYPE_STRING,
'description' => 'File read permissions.',
'default' => [],
'example' => ['*'],
'array' => true,
])
->addRule('$write', [
'type' => self::TYPE_STRING,
'description' => 'File write permissions.',
'default' => [],
'example' => ['user:608f9da25e7e1'],
'array' => true,
])
->addRule('name', [
'type' => self::TYPE_STRING,

View file

@ -20,7 +20,6 @@ trait StorageBase
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'read' => ['*'],
'write' => ['*'],
'folderId' => 'xyz',
]);
$this->assertEquals($file['headers']['status-code'], 201);
@ -61,10 +60,10 @@ trait StorageBase
//$this->assertEquals('aes-128-gcm', $file1['body']['fileOpenSSLCipher']);
//$this->assertNotEmpty($file1['body']['fileOpenSSLTag']);
//$this->assertNotEmpty($file1['body']['fileOpenSSLIV']);
$this->assertIsArray($file1['body']['$permissions']['read']);
$this->assertIsArray($file1['body']['$permissions']['write']);
$this->assertCount(1, $file1['body']['$permissions']['read']);
$this->assertCount(1, $file1['body']['$permissions']['write']);
$this->assertIsArray($file1['body']['$read']);
$this->assertIsArray($file1['body']['$write']);
$this->assertCount(1, $file1['body']['$read']);
$this->assertCount(1, $file1['body']['$write']);
$file2 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/preview', array_merge([
'content-type' => 'application/json',
@ -101,7 +100,6 @@ trait StorageBase
$this->assertEquals($image->getImageHeight(), $original->getImageHeight());
$this->assertEquals('PNG', $image->getImageFormat());
$file4 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/preview', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -203,10 +201,10 @@ trait StorageBase
//$this->assertEquals('aes-128-gcm', $file['body']['fileOpenSSLCipher']);
//$this->assertNotEmpty($file['body']['fileOpenSSLTag']);
//$this->assertNotEmpty($file['body']['fileOpenSSLIV']);
$this->assertIsArray($file['body']['$permissions']['read']);
$this->assertIsArray($file['body']['$permissions']['write']);
$this->assertCount(1, $file['body']['$permissions']['read']);
$this->assertCount(1, $file['body']['$permissions']['write']);
$this->assertIsArray($file['body']['$read']);
$this->assertIsArray($file['body']['$write']);
$this->assertCount(1, $file['body']['$read']);
$this->assertCount(1, $file['body']['$write']);
/**
* Test for FAILURE