1
0
Fork 0
mirror of synced 2024-07-03 21:50:34 +12:00

Add test for x-appwrite-id = unique()

This commit is contained in:
Suven-p 2023-05-21 15:43:26 +00:00 committed by GitHub
parent 582698bd03
commit 5108ab7b06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,6 +240,29 @@ trait StorageBase
$this->assertEquals(400, $failedBucket['headers']['status-code']);
/**
* Test for FAILURE set x-appwrite-id to unique()
*/
$source = realpath(__DIR__ . '/../../../resources/logo.png');
$totalSize = \filesize($source);
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
'content-range' => 'bytes 0-' . $size. '/' . $size,
'x-appwrite-id' => 'unique()',
], $this->getHeaders()), [
'fileId' => ID::unique(),
'file' => new CURLFile($source, 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]);
$this->assertEquals(400, $res['headers']['status-code']);
$this->assertEquals('The value for x-appwrite-id header is invalid. Please check the value of the x-appwrite-id header is valid id and not unique().', $res['body']['message']);
return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']];
}