basic test and fix response model

This commit is contained in:
Damodar Lohani
2024-01-04 07:27:06 +00:00
parent fa40a33631
commit b752d29854
2 changed files with 28 additions and 0 deletions
@@ -34,6 +34,12 @@ class ResourceToken extends Model
'default' => '',
'example' => '1:1',
])
->addRule('resourceType', [
'type' => self::TYPE_STRING,
'description' => 'Resource type.',
'default' => '',
'example' => 'file',
])
->addRule('expire', [
'type' => self::TYPE_DATETIME,
'description' => 'Token expiration date in ISO 8601 format.',
@@ -13,6 +13,9 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
trait StorageBase
{
/**
* @group fileTokens
*/
public function testCreateBucketFile(): array
{
/**
@@ -741,6 +744,25 @@ trait StorageBase
return $data;
}
/**
* @group fileTokens
* @depends testCreateBucketFile
*/
public function testCreateFileToken(array $data): array
{
$bucketId = $data['bucketId'];
$fileId = $data['fileId'];
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/tokens', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(201, $res['headers']['status-code']);
$this->assertEquals('file', $res['body']['resourceType']);
return $data;
}
/**
* @depends testCreateBucketFileZstdCompression
*/