1
0
Fork 0
mirror of synced 2024-07-05 22:51:24 +12:00

test for bucket file size limit

This commit is contained in:
Damodar Lohani 2021-06-21 12:51:28 +05:45
parent 0f317ffa24
commit 80b9fbd3ef

View file

@ -4,7 +4,6 @@ namespace Tests\E2E\Services\Storage;
use CURLFile;
use Tests\E2E\Client;
use Utopia\Image\Image;
trait StorageBase
{
@ -16,9 +15,10 @@ trait StorageBase
$bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
'x-appwrite-key' => $this->getProject()['apiKey'],
], $this->getHeaders()), [
'name' => 'Test Bucket',
'maximumFileSize' => 2000000, //2MB
'read' => ['role:all'],
'write' => ['role:all'],
]);
@ -56,6 +56,27 @@ trait StorageBase
]);
$this->assertEquals(404, $res['headers']['status-code']);
/**
* Test for FAILURE large file size
*/
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), 'image/png', 'kitten-1.png'),
'read' => ['role:all'],
'write' => ['role:all'],
]);
$this->assertEquals(400, $res['headers']['status-code']);
$this->assertEquals('File size not allowed', $res['body']['message']);
/**
* Test for FAILURE unsupported bucket extension
* TODO awaiting FileType validator update
*/
return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id']];
}
@ -141,7 +162,6 @@ trait StorageBase
'rotation' => '45',
]);
$this->assertEquals(200, $file3['headers']['status-code']);
$this->assertEquals('image/png', $file3['headers']['content-type']);
$this->assertNotEmpty($file3['body']);
@ -369,7 +389,6 @@ trait StorageBase
'rotation' => '45',
]);
$this->assertEquals(200, $file3['headers']['status-code']);
$this->assertEquals('image/png', $file3['headers']['content-type']);
$this->assertNotEmpty($file3['body']);