webhook test for update bucket
This commit is contained in:
parent
8c30043bd3
commit
5ebebbd0aa
|
@ -157,6 +157,11 @@ return [
|
|||
'model' => Response::MODEL_BUCKET,
|
||||
'note' => '',
|
||||
],
|
||||
'storage.buckets.update' => [
|
||||
'description' => 'This event triggers when a storage bucket is updated.',
|
||||
'model' => Response::MODEL_BUCKET,
|
||||
'note' => '',
|
||||
],
|
||||
'users.create' => [
|
||||
'description' => 'This event triggers when a user is created from the users API.',
|
||||
'model' => Response::MODEL_USER,
|
||||
|
|
|
@ -127,6 +127,7 @@ trait ProjectCustom
|
|||
'storage.files.update',
|
||||
'storage.files.delete',
|
||||
'storage.buckets.create',
|
||||
'storage.buckets.update',
|
||||
'users.create',
|
||||
'users.update.prefs',
|
||||
'users.update.status',
|
||||
|
|
|
@ -587,4 +587,44 @@ trait WebhooksBase
|
|||
|
||||
return array_merge(['bucketId' => $bucket['body']['$id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreateStorageBucket
|
||||
*/
|
||||
public function testUpdateStorageBucket(array $data): array
|
||||
{
|
||||
$id = $data['bucketId'];
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$bucket = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'name' => 'Test Bucket Updated',
|
||||
'enabled' => false,
|
||||
]);
|
||||
|
||||
$this->assertEquals($bucket['headers']['status-code'], 200);
|
||||
$this->assertNotEmpty($bucket['body']['$id']);
|
||||
|
||||
$webhook = $this->getLastRequest();
|
||||
|
||||
$this->assertEquals($webhook['method'], 'POST');
|
||||
$this->assertEquals($webhook['headers']['Content-Type'], 'application/json');
|
||||
$this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io');
|
||||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Event'], 'storage.buckets.update');
|
||||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], 'not-yet-implemented');
|
||||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']);
|
||||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']);
|
||||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), true);
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals('Test Bucket Updated', $webhook['data']['name']);
|
||||
$this->assertEquals(false, $webhook['data']['enabled']);
|
||||
$this->assertIsArray($webhook['data']['$read']);
|
||||
$this->assertIsArray($webhook['data']['$write']);
|
||||
|
||||
return array_merge(['bucketId' => $bucket['body']['$id']]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue